diff --git a/base_global_discount/README.rst b/base_global_discount/README.rst
index 3996ceef..17cbdba7 100644
--- a/base_global_discount/README.rst
+++ b/base_global_discount/README.rst
@@ -39,6 +39,7 @@ Configuration
To use this module, you need to:
+#. Go to *Settings > Users*, choose yours and set *Manage Global Discounts*.
#. Go to *Settings > Parameters > Global Discounts*
#. Choose the discount scope (sales or purchases).
#. You can also restrict it to a certain company if needed.
@@ -46,7 +47,8 @@ To use this module, you need to:
Usage
=====
-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 the *Sales & Purchases* tab.
diff --git a/base_global_discount/__manifest__.py b/base_global_discount/__manifest__.py
index c16fc614..67dc352d 100644
--- a/base_global_discount/__manifest__.py
+++ b/base_global_discount/__manifest__.py
@@ -10,8 +10,8 @@
"license": "AGPL-3",
"depends": ["product"],
"data": [
- "security/ir.model.access.csv",
"security/security.xml",
+ "security/ir.model.access.csv",
"views/global_discount_views.xml",
"views/res_partner_views.xml",
],
diff --git a/base_global_discount/i18n/base_global_discount.pot b/base_global_discount/i18n/base_global_discount.pot
index 58ce06fc..52e6ea43 100644
--- a/base_global_discount/i18n/base_global_discount.pot
+++ b/base_global_discount/i18n/base_global_discount.pot
@@ -91,12 +91,24 @@ msgstr ""
msgid "Last Updated on"
msgstr ""
+#. module: base_global_discount
+#: model:res.groups,name:base_global_discount.group_global_discount
+msgid "Manage Global Discounts"
+msgstr ""
+
#. module: base_global_discount
#: model:ir.model.fields,field_description:base_global_discount.field_res_partner__supplier_global_discount_ids
#: model:ir.model.fields,field_description:base_global_discount.field_res_users__supplier_global_discount_ids
+#: model_terms:ir.ui.view,arch_db:base_global_discount.res_partner_form_view
msgid "Purchase Global Discounts"
msgstr ""
+#. module: base_global_discount
+#: model:ir.model.fields,field_description:base_global_discount.field_res_partner__supplier_global_discount_ids_readonly
+#: model:ir.model.fields,field_description:base_global_discount.field_res_users__supplier_global_discount_ids_readonly
+msgid "Purchase Global Discounts (readonly)"
+msgstr ""
+
#. module: base_global_discount
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__purchase
msgid "Purchases"
@@ -105,9 +117,16 @@ msgstr ""
#. module: base_global_discount
#: model:ir.model.fields,field_description:base_global_discount.field_res_partner__customer_global_discount_ids
#: model:ir.model.fields,field_description:base_global_discount.field_res_users__customer_global_discount_ids
+#: model_terms:ir.ui.view,arch_db:base_global_discount.res_partner_form_view
msgid "Sale Global Discounts"
msgstr ""
+#. module: base_global_discount
+#: model:ir.model.fields,field_description:base_global_discount.field_res_partner__customer_global_discount_ids_readonly
+#: model:ir.model.fields,field_description:base_global_discount.field_res_users__customer_global_discount_ids_readonly
+msgid "Sale Global Discounts (readonly)"
+msgstr ""
+
#. module: base_global_discount
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__sale
msgid "Sales"
diff --git a/base_global_discount/models/res_partner.py b/base_global_discount/models/res_partner.py
index 1a01b992..5f504bf2 100644
--- a/base_global_discount/models/res_partner.py
+++ b/base_global_discount/models/res_partner.py
@@ -22,3 +22,17 @@ class ResPartner(models.Model):
string="Purchase Global Discounts",
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 in v14 if it's fixed
+ customer_global_discount_ids_readonly = fields.Many2many(
+ string="Sale Global Discounts (readonly)",
+ related="customer_global_discount_ids",
+ readonly=True,
+ )
+ supplier_global_discount_ids_readonly = fields.Many2many(
+ string="Purchase Global Discounts (readonly)",
+ related="supplier_global_discount_ids",
+ readonly=True,
+ )
diff --git a/base_global_discount/readme/CONFIGURE.rst b/base_global_discount/readme/CONFIGURE.rst
index 0e5cea40..bb80f62d 100644
--- a/base_global_discount/readme/CONFIGURE.rst
+++ b/base_global_discount/readme/CONFIGURE.rst
@@ -1,5 +1,6 @@
To use this module, you need to:
+#. Go to *Settings > Users*, choose yours and set *Manage Global Discounts*.
#. Go to *Settings > Parameters > Global Discounts*
#. Choose the discount scope (sales or purchases).
#. You can also restrict it to a certain company if needed.
diff --git a/base_global_discount/readme/USAGE.rst b/base_global_discount/readme/USAGE.rst
index 5615b886..079332b7 100644
--- a/base_global_discount/readme/USAGE.rst
+++ b/base_global_discount/readme/USAGE.rst
@@ -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 the *Sales & Purchases* tab.
diff --git a/base_global_discount/security/ir.model.access.csv b/base_global_discount/security/ir.model.access.csv
index 33fcbd8f..e6e0d9fa 100644
--- a/base_global_discount/security/ir.model.access.csv
+++ b/base_global_discount/security/ir.model.access.csv
@@ -1,3 +1,3 @@
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_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
diff --git a/base_global_discount/security/security.xml b/base_global_discount/security/security.xml
index eeb722c6..234c7c0e 100644
--- a/base_global_discount/security/security.xml
+++ b/base_global_discount/security/security.xml
@@ -13,4 +13,8 @@
+
+ Manage Global Discounts
+
+
diff --git a/base_global_discount/views/global_discount_views.xml b/base_global_discount/views/global_discount_views.xml
index 5cf4e77a..fd22e925 100644
--- a/base_global_discount/views/global_discount_views.xml
+++ b/base_global_discount/views/global_discount_views.xml
@@ -42,5 +42,6 @@
name="Global Discounts"
sequence="1"
parent="base.menu_ir_property"
+ groups="base_global_discount.group_global_discount"
/>
diff --git a/base_global_discount/views/res_partner_views.xml b/base_global_discount/views/res_partner_views.xml
index 78ec97de..4b64c492 100644
--- a/base_global_discount/views/res_partner_views.xml
+++ b/base_global_discount/views/res_partner_views.xml
@@ -10,6 +10,14 @@
+
@@ -17,6 +25,15 @@
+