[FW][FIX] analytic: constraint multi-company on distribution model
Before this fix, the constraint did not prevent changing the company to a bad one on an existing field. We also remove the GROUP BY clause as it is useless. Another query was also useless in `analytic_account.py` and has been removed. closes odoo/odoo#105259 Forward-port-of: odoo/odoo#105129 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -102,9 +102,6 @@ class AccountAnalyticAccount(models.Model):
|
||||
self.flush_recordset(['company_id'])
|
||||
self.env['account.analytic.line'].flush_model(['account_id', 'company_id'])
|
||||
|
||||
self._cr.execute('''
|
||||
SELECT line.id, line.company_id, line.account_id FROM account_analytic_line line''')
|
||||
|
||||
self._cr.execute('''
|
||||
SELECT line.account_id
|
||||
FROM account_analytic_line line
|
||||
|
||||
@@ -42,8 +42,8 @@ class AccountAnalyticDistributionModel(models.Model):
|
||||
WHERE account.company_id IS NOT NULL
|
||||
AND (model.company_id IS NULL
|
||||
OR model.company_id != account.company_id)
|
||||
GROUP BY model.id
|
||||
"""
|
||||
self.flush_model(['company_id', 'analytic_distribution'])
|
||||
self.env.cr.execute(query)
|
||||
if self.env.cr.dictfetchone():
|
||||
raise UserError(_('You defined a distribution with analytic account(s) belonging to a specific company but a model shared between companies or with a different company'))
|
||||
|
||||
Reference in New Issue
Block a user