19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:00 +01:00
parent a1137a1456
commit e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions

View file

@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.tools import SQL
from odoo.exceptions import UserError
@ -16,17 +17,29 @@ class AccountAnalyticApplicability(models.Model):
ondelete={'expense': 'cascade'},
)
@api.depends('business_domain')
def _compute_display_account_prefix(self):
super()._compute_display_account_prefix()
for applicability in self.filtered(lambda rec: rec.business_domain == 'expense'):
applicability.display_account_prefix = True
class AnalyticAccount(models.Model):
class AccountAnalyticAccount(models.Model):
_inherit = 'account.analytic.account'
@api.ondelete(at_uninstall=False)
def _unlink_except_account_in_analytic_distribution(self):
self.env.cr.execute("""
SELECT id FROM hr_expense
WHERE analytic_distribution::jsonb ?| array[%s]
LIMIT 1
""", ([str(id) for id in self.ids],))
self.env.cr.execute(
SQL(
r"""
SELECT id FROM hr_expense
WHERE %s && %s
LIMIT 1
""",
[str(account_id) for account_id in self.ids],
self.env['hr.expense']._query_analytic_accounts(),
)
)
expense_ids = self.env.cr.fetchall()
if expense_ids:
raise UserError(_("You cannot delete an analytic account that is used in an expense."))