Inheriting from the sales application in Odoo

In our class statement, we specify the silkworm_sale_order class, and it has the models.Model parameter. Remember that when learning the Odoo framework, it will take a bit of time to get familiar with the syntax. Right now, you don't have to necessarily understand why you are specifying models.Model; just understand that it is required with most classes:

_inherit= 'sale.order' 

For those new to object-oriented programming in general, the _inherit statement essentially makes the functionality of the Odoo sales application available to your class so you can extend it with your own fields and methods.

Next, we can extend the Odoo sales application with our two custom fields:

daterequired = fields.Date('Date Required', required=True) 
rush = fields.Boolean('Rush Order')

You will note that in the syntax we also specify the data types and provide the labels we want to display in the views inside Odoo. Note that we have also set required=True for the daterequired field so that the user will be forced to provide this data when they create a sales order record if that field is on the view.

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

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