Search code examples
odooopenerp-7openerp-8odoo-8

Where to write new method of python. Either in existing .py files or I need to create a new one?


I am going to write a method in point of sale containing existing .py files. Should I create new python file ? or write new method in existing .py files??


Solution

  • If you need to add a new method to a particular model (e.g. sale.order), then inherit that particular model and add your method in a separate module i.e. custom module.

    class SaleOrder(models.Model):
        _inherit='sale.order'
        @api.multi
        def custom_test_method(self...)
    

    Note: This is in order to migrate to new version or update your code from github. Mostly, any modification to your model needs to be done in a custom module only.