Using a module to add custom fields to a model

In Chapter 10, Creating Advanced Searches and Dashboards, we added Date Required and Rush Order to our sales order model. Now let's see how we can do exactly the same thing in our module.

In our __init__.py file, we only had one line, the import silkworm command.

To add the Date Required and Rush Order fields to our sales order, we can place the following in the silkworm.py file:

from .import models, fields 
 
class silkworm_sale_order(models.Model): 
    _inherit = 'sale.order' 
 
    daterequired = fields.Date('Date Required') 
    rush = fields.Boolean('Rush Order') 

Please note that these are not custom fields created in Developer Mode proceeded by an x_. In Python, the from command allows you to specify which libraries you wish to utilize in your custom classes. For our simple example, we are only pulling in models and fields.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.37.10