Skip to content

Commit

Permalink
[IMP] l10n_eu_product_adr: refactor security
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRijnhart committed Feb 15, 2022
1 parent 2a42dd3 commit 55ed548
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
3 changes: 2 additions & 1 deletion l10n_eu_product_adr/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"data/adr_label.xml",
"data/adr_packing_instruction.xml",
"data/adr_goods.xml",
"security/res_groups.xml",
"security/ir.model.access.csv",
"views/adr_class_views.xml",
"views/adr_goods_views.xml",
"views/adr_label_views.xml",
Expand All @@ -28,6 +30,5 @@
"views/product_template_views.xml",
"views/product_product_views.xml",
"views/stock_picking_views.xml",
"security/ir.model.access.csv",
],
}
1 change: 1 addition & 0 deletions l10n_eu_product_adr/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class StockMove(models.Model):
compute="_compute_adr_points",
string="ADR Points",
digits="Product Unit of Measure",
compute_sudo=True,
)

@api.depends("product_id", "product_uom_qty")
Expand Down
4 changes: 4 additions & 0 deletions l10n_eu_product_adr/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ Goods*.
The number of ADR points on the picking is based on the product weight field
if it is filled in, or otherwise on the UoM quantity in the product's reference
UoM (presumably Liter or Kilogram).

This module defines an ADR user group and an ADR admin group. Membership of
one of these groups is required to access the product tab with the ADR info.
By default, all inventory users are added to the ADR user group.
16 changes: 8 additions & 8 deletions l10n_eu_product_adr/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_adr_goods_user,access_adr_goods,model_adr_goods,stock.group_stock_user,1,0,0,0
access_adr_goods_manager,access_adr_goods,model_adr_goods,base.group_erp_manager,1,1,1,1
access_adr_class_user,access_adr_class,model_adr_class,stock.group_stock_user,1,0,0,0
access_adr_class_manager,access_adr_class,model_adr_class,base.group_erp_manager,1,1,1,1
access_adr_label_user,access_adr_label,model_adr_label,stock.group_stock_user,1,0,0,0
access_adr_label_manager,access_adr_label,model_adr_label,base.group_erp_manager,1,1,1,1
access_adr_packing_instruction_user,access_adr_packing_instruction,model_adr_packing_instruction,stock.group_stock_user,1,0,0,0
access_adr_packing_instruction_manager,access_adr_packing_instruction,model_adr_packing_instruction,base.group_erp_manager,1,1,1,1
access_adr_goods_user,access_adr_goods,model_adr_goods,group_adr_goods_user,1,0,0,0
access_adr_goods_manager,access_adr_goods,model_adr_goods,group_adr_goods_admin,1,1,1,1
access_adr_class_user,access_adr_class,model_adr_class,group_adr_goods_user,1,0,0,0
access_adr_class_manager,access_adr_class,model_adr_class,group_adr_goods_admin,1,1,1,1
access_adr_label_user,access_adr_label,model_adr_label,group_adr_goods_user,1,0,0,0
access_adr_label_manager,access_adr_label,model_adr_label,group_adr_goods_admin,1,1,1,1
access_adr_packing_instruction_user,access_adr_packing_instruction,model_adr_packing_instruction,group_adr_goods_user,1,0,0,0
access_adr_packing_instruction_manager,access_adr_packing_instruction,model_adr_packing_instruction,group_adr_goods_admin,1,1,1,1
20 changes: 20 additions & 0 deletions l10n_eu_product_adr/security/res_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="group_adr_goods_user" model="res.groups">
<field name="name">ADR Goods User</field>
<field name="category_id" ref="base.module_category_hidden" />
</record>
<record id="group_adr_goods_admin" model="res.groups">
<field name="name">ADR Goods Administrator</field>
<field name="implied_ids" eval="[(4, ref('group_adr_goods_user'))]" />
<field name="category_id" ref="base.module_category_hidden" />
</record>
<data noupdate="1">
<record id="stock.group_stock_user" model="res.groups">
<field name="implied_ids" eval="[(4, ref('group_adr_goods_user'))]" />
</record>
<record id="base.group_erp_manager" model="res.groups">
<field name="implied_ids" eval="[(4, ref('group_adr_goods_admin'))]" />
</record>
</data>
</odoo>
1 change: 1 addition & 0 deletions l10n_eu_product_adr/views/product_product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<field name="name">Dangerous goods settings on variants</field>
<field name="model">product.product</field>
<field name="priority" eval="999" />
<field name="groups_id" eval="[(4, ref('group_adr_goods_user'))]" />
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<page name="adr" position="attributes">
Expand Down
1 change: 1 addition & 0 deletions l10n_eu_product_adr/views/product_template_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.dangerous.class</field>
<field name="model">product.template</field>
<field name="groups_id" eval="[(4, ref('group_adr_goods_user'))]" />
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<xpath expr="//div[@name='options']" position="inside">
Expand Down

0 comments on commit 55ed548

Please sign in to comment.