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

@ -33,14 +33,7 @@ class AccountPayment(models.Model):
def action_open_expense(self):
self.ensure_one()
return {
'name': self.expense_ids.name,
'type': 'ir.actions.act_window',
'view_mode': 'form',
'views': [(False, 'form')],
'res_model': 'hr.expense',
'res_id': self.expense_ids.id,
}
return self.expense_ids._get_records_action(name=_("Expenses"))
def _creation_message(self):
# EXTENDS mail

View file

@ -20,9 +20,8 @@ class AccountTax(models.Model):
WHERE EXISTS(
SELECT 1
FROM expense_tax AS exp
WHERE tax_id IN %s
AND account_tax.id = exp.tax_id
)
WHERE account_tax.id = exp.tax_id
) AND id IN %s
""", [tuple(taxes_to_compute)])
used_taxes.update([tax[0] for tax in self.env.cr.fetchall()])

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