summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/project/i18n/project.pot8
-rw-r--r--addons/project/models/analytic_account.py6
2 files changed, 14 insertions, 0 deletions
diff --git a/addons/project/i18n/project.pot b/addons/project/i18n/project.pot
index 323a2b5ad01..fd7341d2cae 100644
--- a/addons/project/i18n/project.pot
+++ b/addons/project/i18n/project.pot
@@ -3211,6 +3211,14 @@ msgid ""
msgstr ""
#. module: project
+#: code:addons/project/models/analytic_account.py:0
+#, python-format
+msgid ""
+"You cannot change the company of an analytical account if it is related to a"
+" project."
+msgstr ""
+
+#. module: project
#: code:addons/project/models/project.py:0
#, python-format
msgid ""
diff --git a/addons/project/models/analytic_account.py b/addons/project/models/analytic_account.py
index 794f882c318..5ff33265efa 100644
--- a/addons/project/models/analytic_account.py
+++ b/addons/project/models/analytic_account.py
@@ -19,6 +19,12 @@ class AccountAnalyticAccount(models.Model):
for account in self:
account.project_count = mapping.get(account.id, 0)
+ @api.constrains('company_id')
+ def _check_company_id(self):
+ for record in self:
+ if record.project_ids:
+ raise UserError(_('You cannot change the company of an analytical account if it is related to a project.'))
+
def unlink(self):
projects = self.env['project.project'].search([('analytic_account_id', 'in', self.ids)])
has_tasks = self.env['project.task'].search_count([('project_id', 'in', projects.ids)])