diff --git a/addons/account_analytic_default_hr_expense/models/hr_expense.py b/addons/account_analytic_default_hr_expense/models/hr_expense.py index 54b8d4c6d44c491539a0d4b8105036a6ecd2759b..7b40dcbbc1e08bd6913447b67c72cab18ed5242c 100644 --- a/addons/account_analytic_default_hr_expense/models/hr_expense.py +++ b/addons/account_analytic_default_hr_expense/models/hr_expense.py @@ -8,9 +8,7 @@ class HrExpense(models.Model): _inherit = 'hr.expense' @api.onchange('product_id', 'date', 'account_id') - def _onchange_product_id(self): - res = super(HrExpense, self)._onchange_product_id() + def _onchange_product_id_date_account_id(self): rec = self.env['account.analytic.default'].sudo().account_get(product_id=self.product_id.id, account_id=self.account_id.id, company_id=self.company_id.id, date=self.date) - self.analytic_account_id = rec.analytic_id.id - self.analytic_tag_ids = rec.analytic_tag_ids.ids - return res + self.analytic_account_id = self.analytic_account_id or rec.analytic_id.id + self.analytic_tag_ids = self.analytic_tag_ids or rec.analytic_tag_ids.ids