Skip to content

Commit

Permalink
FIX base_grp_backend: precommit and better names in ir.model.access
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Aug 7, 2023
1 parent dea9011 commit 190063c
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 72 deletions.
1 change: 0 additions & 1 deletion base_group_backend/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
"security/ir.model.access.csv",
],
"installable": True,
"application": True
}
3 changes: 1 addition & 2 deletions base_group_backend/demo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from odoo.tools import config

if not config['without_demo']:
if not config["without_demo"]:
from . import backend_dummy_model

11 changes: 8 additions & 3 deletions base_group_backend/demo/backend_dummy_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from odoo import fields, models


class BackendDummyModel(models.Model):
_name = "backend.dummy.model"
_inherit = ["mail.activity.mixin"]
_description = 'Nothing to see here'
_description = "Backend Dummy Model demo"

my_value = fields.Char(name="Value", required=True)
my_other_value = fields.Char(name="Other value", required=True)
date_start = fields.Datetime(name="Date start", required=True, default=fields.Datetime.now)
date_stop = fields.Datetime(name="Date stop", required=True, default=fields.Datetime.now)
date_start = fields.Datetime(
name="Date start", required=True, default=fields.Datetime.now
)
date_stop = fields.Datetime(
name="Date stop", required=True, default=fields.Datetime.now
)
84 changes: 43 additions & 41 deletions base_group_backend/demo/backend_dummy_model.xml
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record id="backend_dummy_model_tree_view" model="ir.ui.view">
<field name="name">Backend dummy tree view</field>
<field name="model">backend.dummy.model</field>
<field name="arch" type="xml">
<tree string="Dummies" create="false" delete="false">
<field name="my_value"/>
<field name="my_other_value"/>
</tree>
</field>
</record>
<record id="action_dummy_list" model="ir.actions.act_window">
<field name="name">Dummies</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">backend.dummy.model</field>
<field name="view_mode">tree,form,kanban,calendar,pivot,graph,activity</field>
<field name="view_id" ref="backend_dummy_model_tree_view" />
</record>
<menuitem
id="menu_dummy_root"
name="Dummy"
sequence="100"
groups="group_backend,base.group_user"
/>
<menuitem
id="menu_dummy_menu"
name="Dummy"
sequence="10"
groups="group_backend,base.group_user"
parent="menu_dummy_root"
/>
<menuitem
id="menu_dummy_list"
name="Dummy list"
sequence="100"
groups="group_backend,base.group_user"
parent="menu_dummy_root"
action="action_dummy_list"
/>
</data>

<record id="backend_dummy_model_tree_view" model="ir.ui.view">
<field name="name">Backend dummy tree view</field>
<field name="model">backend.dummy.model</field>
<field name="arch" type="xml">
<tree create="false" delete="false">
<field name="my_value" />
<field name="my_other_value" />
</tree>
</field>
</record>

<record id="action_dummy_list" model="ir.actions.act_window">
<field name="name">Dummies</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">backend.dummy.model</field>
<field name="view_mode">tree,form,kanban,calendar,pivot,graph,activity</field>
<field name="view_id" ref="backend_dummy_model_tree_view" />
</record>

<menuitem
id="menu_dummy_root"
name="Dummy"
sequence="100"
groups="group_backend,base.group_user"
/>
<menuitem
id="menu_dummy_menu"
name="Dummy"
sequence="10"
groups="group_backend,base.group_user"
parent="menu_dummy_root"
/>
<menuitem
id="menu_dummy_list"
name="Dummy list"
sequence="100"
groups="group_backend,base.group_user"
parent="menu_dummy_root"
action="action_dummy_list"
/>

</odoo>
4 changes: 2 additions & 2 deletions base_group_backend/demo/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_backend_dummy_models","backend_dummy_model all","base_group_backend.model_backend_dummy_model",group_backend,1,0,0,0
"access_backend_dummy_models_all","backend_dummy_model all","base_group_backend.model_backend_dummy_model",base.group_user,1,0,0,0
"backend_dummy_models","backend dummy.model","model_backend_dummy_model",group_backend,1,0,0,0
"backend_dummy_models_user_grp","backend dummy.model user grp","model_backend_dummy_model",base.group_user,1,0,0,0
12 changes: 6 additions & 6 deletions base_group_backend/demo/test-model.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<odoo>
<data>
<record model="backend.dummy.model" id="dummy_model_1">
<field name="my_value">hello</field>
<field name="my_other_value">hello</field>
</record>
</data>

<record model="backend.dummy.model" id="dummy_model_1">
<field name="my_value">hello</field>
<field name="my_other_value">hello</field>
</record>

</odoo>
13 changes: 8 additions & 5 deletions base_group_backend/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class Users(models.Model):
_inherit = "res.users"


# TODO: (franz) make it clear why we test with "." group and why the share = True
@api.model
def has_group(self, group_ext_id):
Expand All @@ -33,10 +32,14 @@ def has_group(self, group_ext_id):
return has_base_group_backend
return res

@api.depends('groups_id')
@api.depends("groups_id")
def _compute_share(self):
user_group_id = self.env['ir.model.data']._xmlid_to_res_id('base.group_user')
backend_user_group_id = self.env['ir.model.data']._xmlid_to_res_id('base_group_backend.group_backend')
internal_users = self.filtered_domain([('groups_id', 'in', [user_group_id, backend_user_group_id])])
user_group_id = self.env["ir.model.data"]._xmlid_to_res_id("base.group_user")
backend_user_group_id = self.env["ir.model.data"]._xmlid_to_res_id(
"base_group_backend.group_backend"
)
internal_users = self.filtered_domain(
[("groups_id", "in", [user_group_id, backend_user_group_id])]
)
internal_users.share = False
(self - internal_users).share = True
24 changes: 12 additions & 12 deletions base_group_backend/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_res_users_all,res_users all,model_res_users,group_backend,1,0,0,0
access_res_partners_all,res_partners all,base.model_res_partner,group_backend,1,0,0,0
access_ir_ui_menu_group_user,ir_ui_menu group_user,base.model_ir_ui_menu,group_backend,1,0,0,0
access_ir_filter_user,ir_filters all,base.model_ir_filters,group_backend,1,1,1,1
access_bus_presence,bus.presence,bus.model_bus_presence,group_backend,1,1,1,1
access_mail_channel_member_user,mail.channel.member.user,mail.model_mail_channel_member,group_backend,1,1,1,0
access_mail_channel_user,mail.group.user,mail.model_mail_channel,group_backend,1,1,1,0
access_mail_notification_user,mail.notification.user,mail.model_mail_notification,group_backend,1,1,1,0
access_mail_activity_user,mail.activity.user,mail.model_mail_activity,group_backend,1,1,1,1
access_mail_activity_type_user,mail.activity.type.user,mail.model_mail_activity_type,group_backend,1,0,0,0
access_ir_attachment_group_user,ir_attachment group_user,base.model_ir_attachment,group_backend,1,0,0,0
access_mail_followers_user,mail.followers.user,mail.model_mail_followers,group_backend,1,0,0,0
res_users_backend,backend user res.users,base.model_res_users,group_backend,1,0,0,0
res_partner_backend,backend user res.partner,base.model_res_partner,group_backend,1,0,0,0
ir_ui_menu_backend,backend user ir.ui.menu,base.model_ir_ui_menu,group_backend,1,0,0,0
ir_filter_backend,backend user ir.filters,base.model_ir_filters,group_backend,1,1,1,1
bus_presence_backend,backend user bus.presence,bus.model_bus_presence,group_backend,1,1,1,1
mail_channel_member_backend,backend user mail.channel.member,mail.model_mail_channel_member,group_backend,1,1,1,0
mail_channel_backend,backend user mail.group,mail.model_mail_channel,group_backend,1,1,1,0
mail_notification_backend,backend user mail.notification,mail.model_mail_notification,group_backend,1,1,1,0
mail_activity_backend,backend user mail.activity,mail.model_mail_activity,group_backend,1,1,1,1
mail_activity_type_backend,backend user mail.activity.type,mail.model_mail_activity_type,group_backend,1,0,0,0
ir_attachment_group_backend,backend user ir.attachment,base.model_ir_attachment,group_backend,1,0,0,0
mail_followers_backend,backend user mail.followers,mail.model_mail_followers,group_backend,1,0,0,0

0 comments on commit 190063c

Please sign in to comment.