mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] base_global_discount: add specific security group
This way, it will be easier to decide who can set discount or not. The current group scope is too broad.
This commit is contained in:
@@ -13,8 +13,8 @@
|
|||||||
'product',
|
'product',
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
|
||||||
'security/security.xml',
|
'security/security.xml',
|
||||||
|
'security/ir.model.access.csv',
|
||||||
'views/global_discount_views.xml',
|
'views/global_discount_views.xml',
|
||||||
'views/res_partner_views.xml',
|
'views/res_partner_views.xml',
|
||||||
],
|
],
|
||||||
|
|||||||
10
base_global_discount/migrations/12.0.2.0.0/post_migrate.py
Normal file
10
base_global_discount/migrations/12.0.2.0.0/post_migrate.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Copyright 2020 David Vidal
|
||||||
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||||
|
from openupgradelib.openupgrade import migrate
|
||||||
|
|
||||||
|
|
||||||
|
@migrate()
|
||||||
|
def migrate(env, version):
|
||||||
|
"""Put all partner managers as global discount managers"""
|
||||||
|
users = env.ref("base.group_partner_manager").users
|
||||||
|
env.ref("base_global_discount.group_global_discount").users = users
|
||||||
@@ -20,3 +20,15 @@ class ResPartner(models.Model):
|
|||||||
string='Purchase Global Discounts',
|
string='Purchase Global Discounts',
|
||||||
domain=[('discount_scope', '=', 'purchase')],
|
domain=[('discount_scope', '=', 'purchase')],
|
||||||
)
|
)
|
||||||
|
# HACK: Looks like UI doesn't behave well with Many2many fields and
|
||||||
|
# negative groups when the same field is shown. In this case, we want to
|
||||||
|
# show the readonly version to any not in the global discount group.
|
||||||
|
# TODO: Check if it's fixed in future versions
|
||||||
|
customer_global_discount_ids_readonly = fields.Many2many(
|
||||||
|
related="customer_global_discount_ids",
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
|
supplier_global_discount_ids_readonly = fields.Many2many(
|
||||||
|
related="customer_global_discount_ids",
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
To use this module, you need to:
|
To use this module, you need to:
|
||||||
|
|
||||||
|
#. Go to *Settings > Users*, choose yours and set *Manage Global Discounts*.
|
||||||
#. Go to *Settings > Parameters > Global Discounts*
|
#. Go to *Settings > Parameters > Global Discounts*
|
||||||
#. Choose the discount scope (sales or purchases).
|
#. Choose the discount scope (sales or purchases).
|
||||||
#. You can also restrict it to a certain company if needed.
|
#. You can also restrict it to a certain company if needed.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
You can assign global discounts to partners as well:
|
You can assign global discounts to partners as well. You'll need the proper
|
||||||
|
permission (*Manage Global Discounts*):
|
||||||
|
|
||||||
#. Go to a partner that is a company.
|
#. Go to a partner that is a company.
|
||||||
#. Go to the *Sales & Purchases* tab.
|
#. Go to the *Sales & Purchases* tab.
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_global_discount_user,Global Discount Users,model_global_discount,base.group_user,1,0,0,0
|
access_global_discount_user,Global Discount Users,model_global_discount,base.group_user,1,0,0,0
|
||||||
access_global_discount_partner_manager,Global Discount Partner Manager,model_global_discount,base.group_partner_manager,1,1,1,1
|
access_global_discount_manager,Global Discount Manager,model_global_discount,base_global_discount.group_global_discount,1,1,1,1
|
||||||
|
|||||||
|
@@ -12,5 +12,8 @@
|
|||||||
<field name="perm_write" eval="1"/>
|
<field name="perm_write" eval="1"/>
|
||||||
<field name="perm_unlink" eval="1"/>
|
<field name="perm_unlink" eval="1"/>
|
||||||
</record>
|
</record>
|
||||||
|
<record id="group_global_discount" model="res.groups">
|
||||||
|
<field name="name">Manage Global Discounts</field>
|
||||||
|
<field name="category_id" ref="base.module_category_hidden"/>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -41,9 +41,12 @@
|
|||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_global_discount"
|
<menuitem
|
||||||
|
id="menu_global_discount"
|
||||||
action="action_global_discount_tree"
|
action="action_global_discount_tree"
|
||||||
name="Global Discounts"
|
name="Global Discounts"
|
||||||
sequence="1" parent="base.menu_ir_property"/>
|
sequence="1" parent="base.menu_ir_property"
|
||||||
|
groups="base_global_discount.group_global_discount"
|
||||||
|
/>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -8,11 +8,16 @@
|
|||||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<group name="sale" position="inside">
|
<group name="sale" position="inside">
|
||||||
<field name="customer_global_discount_ids" widget="many2many_tags"
|
<field name="customer_global_discount_ids" widget="many2many_tags" groups="base_global_discount.group_global_discount"
|
||||||
|
attrs="{'invisible': [('customer', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"/>
|
||||||
|
<field name="customer_global_discount_ids_readonly" widget="many2many_tags"
|
||||||
|
groups="!base_global_discount.group_global_discount"
|
||||||
attrs="{'invisible': [('customer', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"/>
|
attrs="{'invisible': [('customer', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="purchase" position="inside">
|
<group name="purchase" position="inside">
|
||||||
<field name="supplier_global_discount_ids" widget="many2many_tags"
|
<field name="supplier_global_discount_ids" widget="many2many_tags" groups="base_global_discount.group_global_discount"
|
||||||
|
attrs="{'invisible': [('supplier', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"/>
|
||||||
|
<field name="supplier_global_discount_ids" widget="many2many_tags" groups="!base_global_discount.group_global_discount"
|
||||||
attrs="{'invisible': [('supplier', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"/>
|
attrs="{'invisible': [('supplier', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"/>
|
||||||
</group>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user