compute function in many2one field odoo 13 code example

Example: odoo computed many2one

customer_of_division_id = fields.Many2one(compute='_get_division_id', comodel_name='res.partner', string='Customer of the division', store=True) @api.depends('sale_id','partner_id')    def _get_division_id(self):    if self.sale_id:        self.customer_of_division_id = self.sale_id.customer_of_division_id.id            elif self.partner_id:        self.customer_of_division_id = self.partner_id.customer_of_division_id.id

Tags:

Misc Example