19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:07 +01:00
parent ba20ce7443
commit 768b70e05e
2357 changed files with 1057103 additions and 712486 deletions

View file

@ -5,29 +5,7 @@ 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)."))
class GroupsView(models.Model):
class ResGroups(models.Model):
_inherit = 'res.groups'
@api.model
@ -35,9 +13,26 @@ class GroupsView(models.Model):
# Overridden in order to remove 'Show Full Accounting Features' and
# 'Show Full Accounting Features - Readonly' in the 'res.users' form view to prevent confusion
group_account_user = self.env.ref('account.group_account_user', raise_if_not_found=False)
if group_account_user and group_account_user.category_id.xml_id == 'base.module_category_hidden':
if group_account_user and not group_account_user.privilege_id:
domain += [('id', '!=', group_account_user.id)]
group_account_readonly = self.env.ref('account.group_account_readonly', raise_if_not_found=False)
if group_account_readonly and group_account_readonly.category_id.xml_id == 'base.module_category_hidden':
if group_account_readonly and not group_account_readonly.privilege_id:
domain += [('id', '!=', group_account_readonly.id)]
group_account_basic = self.env.ref('account.group_account_basic', raise_if_not_found=False)
if group_account_basic and not group_account_basic.privilege_id:
domain += [('id', '!=', group_account_basic.id)]
return super().get_application_groups(domain)
@api.model
def _activate_group_account_secured(self):
group_account_secured = self.env.ref('account.group_account_secured', raise_if_not_found=False)
if not group_account_secured:
return
groups_with_access = [
'account.group_account_readonly',
'account.group_account_invoice',
]
for group_name in groups_with_access:
group = self.env.ref(group_name, raise_if_not_found=False)
if group:
group.sudo()._apply_group(group_account_secured)