Creating fields dynamically is not a common requirement, but in some cases we do need to create fields dynamically.
There are two ways to create a field in Odoo, one is defined by the Python file class, the other is created manually on the interface, and Odoo distinguishes between the two types of fields through the State field.
Fields created through the interface must start with X_.
The author tried to create a base type field dynamically through a Python file, and the results did not find a suitable method. But after a long time to find out, you can do this by dynamically creating manual fields.
Application:
Domestic human resources applications often need to count each person's payroll, and the composition of the salary is flexible dynamic (although can be fixed, but once the change to change the module code), so it is very difficult to summarize a general table,
It is very easy to do this with the method of dynamically creating fields:
The wage composition in the table is a dynamic one2many, without modifying the code implementation summary matrix:
How Odoo dynamically creates a field