Skip to content
Snippets Groups Projects
Commit f882193b authored by Benjami's avatar Benjami
Browse files

Fix: Acces errors and company.get_users

parent a5b21019
No related branches found
No related tags found
2 merge requests!253[REL] Release 06/11/23,!191V1 imrpvements to CompanyEasyCreation wizard (CRM Lead execution)🙋‍
Pipeline #46556 passed
......@@ -200,6 +200,7 @@ class ResCompany(models.Model):
if role_codes:
users = (
self.env["res.users.role.line"]
.sudo()
.search(
[
("company_id", "=", self.id),
......@@ -212,6 +213,7 @@ class ResCompany(models.Model):
else:
users = (
self.env["res.users.role.line"]
.sudo()
.search(
[
("company_id", "=", self.id),
......@@ -227,6 +229,7 @@ class ResCompany(models.Model):
if wants_platform_admins:
users += (
self.env["res.users.role.line"]
.sudo()
.search(
[
(
......
......@@ -242,14 +242,14 @@ class ResUsers(models.Model):
}
)
# TODO: Strategy refactor i feature/assign_ce_admin branch
# TODO: Strategy refactor?
def make_ce_user(self, company_id, role_name):
role = self.env["res.users.role"].search([("code", "=", role_name)])
current_role = self.env["res.users.role.line"].search(
[
("user_id", "=", self.id),
("active", "=", True),
("company_id", "=", company_id), # .id??
("company_id", "=", company_id.id),
]
)
......@@ -258,7 +258,7 @@ class ResUsers(models.Model):
else:
self.write(
{
"company_ids": [(4, company_id)], # .id??
"company_ids": [(4, company_id.id)],
"role_line_ids": [
(
0,
......@@ -267,7 +267,7 @@ class ResUsers(models.Model):
"user_id": self.id,
"active": True,
"role_id": role.id,
"company_id": company_id, # .id??
"company_id": company_id.id,
},
)
],
......
......@@ -10,3 +10,4 @@ user_role_line_read,user_role_line_read_admin,base_user_role.model_res_users_rol
ir_config_parameter_read,ir_config_parameter_read_admin,base.model_ir_config_parameter,group_admin,1,0,0,0
ir_actions_act_window_read,ir_actions_act_window_read_admin,base.model_ir_actions_act_window,group_admin,1,0,0,0
ir_actions_act_window_view_read,ir_actions_act_window_view_read_admin,base.model_ir_actions_act_window_view,group_admin,1,0,0,0
res_company_modify,res_company_modify_admin,model_res_company,group_admin,1,1,1,0
......@@ -154,6 +154,8 @@ class AccountMulticompanyEasyCreationWiz(models.TransientModel):
product_category_company_share.write(values)
def create_capital_share_product_template(self):
new_company_id = self.new_company_id.id
self_new_company = self.with_company(new_company_id)
# We use sudo to be able to copy the product and not needing to be in the main company
self.new_product_share_template = self.sudo().product_share_template.copy(
{
......@@ -163,7 +165,9 @@ class AccountMulticompanyEasyCreationWiz(models.TransientModel):
"active": True,
}
)
self.new_company_id.initial_subscription_share_amount = self.capital_share
self_new_company.new_company_id.initial_subscription_share_amount = (
self.capital_share
)
def update_values_from_crm_lead(self):
if self.crm_lead_id:
......@@ -229,6 +233,6 @@ class AccountMulticompanyEasyCreationWiz(models.TransientModel):
)
self.with_context(
allowed_company_ids=allowed_company_ids
).chart_template_id.try_loading(company=new_company)
).sudo().chart_template_id.try_loading(company=new_company)
self.create_bank_journals()
self.create_sequences()
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