Skip to content

Commit

Permalink
[IMP] price_security_planned_price: View cleaning
Browse files Browse the repository at this point in the history
Remove fields that used to be manipulated because they are now treated
in other module
  • Loading branch information
jok-adhoc committed Oct 10, 2023
1 parent 29ad49e commit cbeda59
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
8 changes: 1 addition & 7 deletions price_security_planned_price/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ def _get_view(self, view_id=None, view_type='form', **options):
+ arch.xpath("//field[@name='other_currency_list_price']")
+ arch.xpath("//field[@name='other_currency_id']")
+ arch.xpath("//field[@name='sale_margin']")
+ arch.xpath("//field[@name='sale_surcharge']")
+ arch.xpath("//field[@name='replenishment_cost_type']")
+ arch.xpath("//field[@name='replenishment_cost_last_update']")
+ arch.xpath("//field[@name='replenishment_base_cost']")
+ arch.xpath("//field[@name='replenishment_base_cost_currency_id']")
+ arch.xpath("//field[@name='replenishment_cost']")
+ arch.xpath("//field[@name='replenishment_cost_rule_id']"))
+ arch.xpath("//field[@name='sale_surcharge']"))
for node in readonly_fields:
node.set('readonly', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
Expand Down
8 changes: 1 addition & 7 deletions price_security_planned_price/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ def _get_view(self, view_id=None, view_type='form', **options):
+ arch.xpath("//field[@name='other_currency_list_price']")
+ arch.xpath("//field[@name='other_currency_id']")
+ arch.xpath("//field[@name='sale_margin']")
+ arch.xpath("//field[@name='sale_surcharge']")
+ arch.xpath("//field[@name='replenishment_cost_type']")
+ arch.xpath("//field[@name='replenishment_cost_last_update']")
+ arch.xpath("//field[@name='replenishment_base_cost']")
+ arch.xpath("//field[@name='replenishment_base_cost_currency_id']")
+ arch.xpath("//field[@name='replenishment_cost']")
+ arch.xpath("//field[@name='replenishment_cost_rule_id']"))
+ arch.xpath("//field[@name='sale_surcharge']"))
for node in readonly_fields:
node.set('readonly', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
Expand Down
3 changes: 2 additions & 1 deletion price_security_sale_margin/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def _get_view(self, view_id=None, view_type='form', **options):
if self.env.user.has_group('price_security.group_only_view_sale_price'):
invisible_fields = (arch.xpath("//field[@name='purchase_price']")
+ arch.xpath("//field[@name='margin']")
+ arch.xpath("//field[@name='margin_percent']"))
+ arch.xpath("//field[@name='margin_percent']")
+ arch.xpath("//field[@name='margin_percent']/.."))
for node in invisible_fields:
node.set('invisible', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
Expand Down
9 changes: 9 additions & 0 deletions price_security_sale_margin/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
class SaleOrder(models.Model):
_inherit = 'sale.order.line'

@api.model
def _get_view_cache_key(self, view_id=None, view_type='form', **options):
"""The override of fields_get making fields readonly for price security users
makes the view cache dependent on the fact the user has the group price security or not
"""
key = super()._get_view_cache_key(view_id, view_type, **options)
return key + (self.env.user.has_group('price_security.group_only_view'),) + \
(self.env.user.has_group('price_security.group_only_view_sale_price'),)

@api.model
def _get_view(self, view_id=None, view_type='form', **options):
arch, view = super()._get_view(view_id, view_type, **options)
Expand Down

0 comments on commit cbeda59

Please sign in to comment.