19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-25 12:00:11 +01:00
parent e1d89e11e3
commit a1f02d8cc7
225 changed files with 2335 additions and 775 deletions

View file

@ -331,14 +331,15 @@ class HrExpense(models.Model):
).ids
)
for expense in self:
if not expense.company_id:
# This would be happening when emptying the required company_id field, triggering the "onchange"s.
# This would lead to fields being set as editable, instead of using the env company,
# recomputing the interface just to be blocked when trying to save we choose not to recompute anything
# and wait for a proper company to be inputted.
continue
if expense.state not in {'draft', 'submitted', 'approved'} and not self.env.su:
# Not editable
if (
not expense.company_id
or (expense.state not in {'draft', 'submitted', 'approved'} and not self.env.su)
):
# When emptying the required company_id field, onchanges are triggered.
# To avoid recomputing the interface without a company (which could
# temporarily make fields editable), we do not recompute anything and wait
# for a proper company to be set. The interface is also made not editable
# when the state is not draft/submitted/approved and the user is not a superuser.
expense.is_editable = False
continue
@ -1081,12 +1082,8 @@ class HrExpense(models.Model):
expense_description = msg_dict.get('subject', '')
if employee.user_id:
company = employee.user_id.company_id
currencies = company.currency_id | employee.user_id.company_ids.mapped('currency_id')
else:
company = employee.company_id
currencies = company.currency_id
company = employee.company_id
currencies = company.currency_id
if not company: # ultimate fallback, since company_id is required on expense
company = self.env.company