[FIX] sale: sale_count
- Create a user with Inventory access but no Sales access - Access a product An AccessError is raised because the user doesn't have access to `sale.report`. We hide the stat button if user has no access to Sales, and moreover we do not compute the sales count in this case. opw-1815436
This commit is contained in:
committed by
Nicolas Martinelli
parent
91be355bf9
commit
26325dc943
@@ -10,6 +10,8 @@ class ProductProduct(models.Model):
|
||||
@api.multi
|
||||
def _sales_count(self):
|
||||
r = {}
|
||||
if not self.user_has_groups('sales_team.group_sale_salesman'):
|
||||
return r
|
||||
domain = [
|
||||
('state', 'in', ['sale', 'done']),
|
||||
('product_id', 'in', self.ids),
|
||||
|
||||
@@ -649,7 +649,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<button name="toggle_active" position="before">
|
||||
<button class="oe_stat_button" name="%(action_product_sale_list)d"
|
||||
type="action" icon="fa-usd">
|
||||
type="action" icon="fa-usd" groups="sales_team.group_sale_salesman">
|
||||
<field string="Sales" name="sales_count" widget="statinfo" />
|
||||
</button>
|
||||
</button>
|
||||
@@ -671,7 +671,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<button name="toggle_active" position="before">
|
||||
<button class="oe_stat_button" name="action_view_sales"
|
||||
type="object" icon="fa-usd">
|
||||
type="object" icon="fa-usd" groups="sales_team.group_sale_salesman">
|
||||
<field string="Sales" name="sales_count" widget="statinfo" />
|
||||
</button>
|
||||
</button>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<button name="action_view_orderpoints" position="after">
|
||||
<button class="oe_stat_button" name="action_view_sales"
|
||||
type="object" icon="fa-usd">
|
||||
type="object" icon="fa-usd" groups="sales_team.group_sale_salesman">
|
||||
<field string="Sales" name="sales_count" widget="statinfo" />
|
||||
</button>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user