Skip to content

Commit

Permalink
[MIG] price_security_planned_price: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc committed Feb 13, 2023
1 parent 00ad9b4 commit d37e85a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 86 deletions.
1 change: 1 addition & 0 deletions price_security_planned_price/__init__.py
Expand Up @@ -2,3 +2,4 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import models
7 changes: 2 additions & 5 deletions price_security_planned_price/__manifest__.py
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Price Security with planned price',
'version': "15.0.1.0.0",
'version': "16.0.1.0.0",
'category': 'Sales Management',
'author': 'ADHOC SA',
'website': 'http://www.adhoc.com.ar/',
Expand All @@ -28,9 +28,6 @@
'price_security',
'product_planned_price',
],
'data': [
'views/product_template_views.xml',
],
'installable': False,
'installable': True,
'auto_install': True,
}
2 changes: 2 additions & 0 deletions price_security_planned_price/models/__init__.py
@@ -0,0 +1,2 @@
from . import product_product
from . import product_template
38 changes: 38 additions & 0 deletions price_security_planned_price/models/product_product.py
@@ -0,0 +1,38 @@
from odoo import models, api
import json


class ProductProduct(models.Model):
_inherit = 'product.product'

@api.model
def _get_view(self, view_id=None, view_type='form', **options):
arch, view = super()._get_view(view_id, view_type, **options)
if view_type == 'form':
if self.env.user.has_group('price_security.group_only_view'):
readonly_fields = (arch.xpath("//field[@name='list_price_type']")
+ arch.xpath("//field[@name='computed_list_price_manual']")
+ 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']"))
for node in readonly_fields:
node.set('readonly', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
modifiers['readonly'] = True
node.set("modifiers", json.dumps(modifiers))
if self.env.user.has_group('price_security.group_only_view_sale_price'):
invisible_fields = (arch.xpath("//group[@name='costing']")
+ arch.xpath("//group[@name='planned_price']"))
for node in invisible_fields:
node.set('invisible', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
modifiers['invisible'] = True
node.set("modifiers", json.dumps(modifiers))
return arch, view
38 changes: 38 additions & 0 deletions price_security_planned_price/models/product_template.py
@@ -0,0 +1,38 @@
from odoo import models, api
import json


class ProductTemplate(models.Model):
_inherit = 'product.template'

@api.model
def _get_view(self, view_id=None, view_type='form', **options):
arch, view = super()._get_view(view_id, view_type, **options)
if view_type == 'form':
if self.env.user.has_group('price_security.group_only_view'):
readonly_fields = (arch.xpath("//field[@name='list_price_type']")
+ arch.xpath("//field[@name='computed_list_price_manual']")
+ 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']"))
for node in readonly_fields:
node.set('readonly', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
modifiers['readonly'] = True
node.set("modifiers", json.dumps(modifiers))
if self.env.user.has_group('price_security.group_only_view_sale_price'):
invisible_fields = (arch.xpath("//group[@name='costing']")
+ arch.xpath("//group[@name='planned_price']"))
for node in invisible_fields:
node.set('invisible', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
modifiers['invisible'] = True
node.set("modifiers", json.dumps(modifiers))
return arch, view
81 changes: 0 additions & 81 deletions price_security_planned_price/views/product_template_views.xml

This file was deleted.

0 comments on commit d37e85a

Please sign in to comment.