summaryrefslogtreecommitdiff
path: root/addons/account/models/res_users.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/account/models/res_users.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/account/models/res_users.py')
-rw-r--r--addons/account/models/res_users.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/addons/account/models/res_users.py b/addons/account/models/res_users.py
new file mode 100644
index 00000000..0cf9d85c
--- /dev/null
+++ b/addons/account/models/res_users.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, models, _
+from odoo.exceptions import ValidationError
+
+
+class Users(models.Model):
+ _inherit = "res.users"
+
+ @api.constrains('groups_id')
+ def _check_one_user_type(self):
+ super(Users, self)._check_one_user_type()
+
+ g1 = self.env.ref('account.group_show_line_subtotals_tax_included', False)
+ g2 = self.env.ref('account.group_show_line_subtotals_tax_excluded', False)
+
+ if not g1 or not g2:
+ # A user cannot be in a non-existant group
+ return
+
+ for user in self:
+ if user._has_multiple_groups([g1.id, g2.id]):
+ raise ValidationError(_("A user cannot have both Tax B2B and Tax B2C.\n"
+ "You should go in General Settings, and choose to display Product Prices\n"
+ "either in 'Tax-Included' or in 'Tax-Excluded' mode\n"
+ "(or switch twice the mode if you are already in the desired one)."))