diff --git a/models/account.py b/models/account.py index 0c49c77b3bfcb6f51f907c878e9c09a7f6e7ed21..123760cf9fc6aef6f196726755ab3614c2ea7ae5 100644 --- a/models/account.py +++ b/models/account.py @@ -1,7 +1,7 @@ # Copyright 2021- Le Filament (https://le-filament.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class AccountInvoice(models.Model): @@ -33,6 +33,10 @@ class AccountInvoice(models.Model): # ------------------------------------------------------ # Computed fields / Search Fields # ------------------------------------------------------ + @api.onchange("partner_id") + def _update_invoice_default_sale_person(self): + for move in self.filtered("partner_id"): + move.invoice_user_id = move.partner_id.user_id or self.env.user # ------------------------------------------------------ # Onchange / Constraints