Hello guys. Thanks a lot for your help. I'm new at Odoo and I need your support :)
There's a better way to code this?
class AccountMove(models.Model):
_inherit = 'account.move'
business_unit_id = fields.Many2one('business.unit', compute='get_sale_order', string='Business Unit')
order_type_id = fields.Many2one('order.type', compute='get_sale_order')
client_order_ref = fields.Char(compute='get_sale_order', readonly=True)
@api.depends('invoice_origin')
def get_sale_order(self):
for move in self:
sale_order = self.env['sale.order'].search([
('name', '=', move.invoice_origin)
])
move.client_order_ref = sale_order.client_order_ref
move.business_unit_id = sale_order.business_unit_id.idAs you can see, there are 3 computes. Theres is a better way to write this code?
Thanks in advance :)