Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] price_security_planned_price: Migration to 16.0
- Loading branch information
Showing
6 changed files
with
81 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import product_product | ||
from . import product_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
81
price_security_planned_price/views/product_template_views.xml
This file was deleted.
Oops, something went wrong.