Skip to content
Snippets Groups Projects
Commit 49bf7d14 authored by Thibault Francois's avatar Thibault Francois
Browse files

[FIX] analytic: constraint should only apply on current recordset


Before this commit, if a single analytic line in the database
has an inconsistent company with it's anlytic account, all creation
of an analytic account was impossible because the constraint
_check_company_consistency is checked on the entire table.

This commit restrict the _check_company_consistency only
on the current record set.

closes odoo/odoo#115698

Signed-off-by: default avatarWilliam André (wan) <wan@odoo.com>
parent cf8952aa
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,8 @@ class AccountAnalyticAccount(models.Model):
FROM account_analytic_line line
JOIN account_analytic_account account ON line.account_id = account.id
WHERE line.company_id != account.company_id and account.company_id IS NOT NULL
''')
AND account.id IN %s
''', [tuple(self.ids)])
if self._cr.fetchone():
raise UserError(_("You can't set a different company on your analytic account since there are some analytic items linked to it."))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment