Skip to content

Commit

Permalink
[FIX] price_security: make readonly property fields that are included…
Browse files Browse the repository at this point in the history
… in account_multicompany_ux
  • Loading branch information
vib-adhoc authored and nicomacr committed Feb 7, 2023
1 parent 3e0a67f commit 71b2b01
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion price_security/__manifest__.py
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Price Security',
'version': "15.0.1.2.0",
'version': "15.0.1.3.0",
'category': 'Sales Management',
'author': 'ADHOC SA, Odoo Community Association (OCA)',
'website': 'http://www.adhoc.com.ar/',
Expand Down
1 change: 1 addition & 0 deletions price_security/models/__init__.py
Expand Up @@ -7,6 +7,7 @@
from . import discount_restriction
from . import product_pricelist
from . import product_template
from . import res_partner
from . import res_users
from . import sale_order
from . import sale_order_line
27 changes: 27 additions & 0 deletions price_security/models/res_partner.py
@@ -0,0 +1,27 @@
from odoo import api, models
from lxml import etree
import json

class ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def fields_view_get(self, view_id=None, view_type='form',
toolbar=False, submenu=False):
"""
If we came from sale order, we send in context 'force_product_edit'
and we change tree view to make editable and also field qty
"""
res = super().fields_view_get(
view_id=view_id, view_type=view_type,
toolbar=toolbar, submenu=submenu)
if view_type == 'form':
if self.env.user.has_group('price_security.group_restrict_prices'):
doc = etree.XML(res['arch'])
for node in doc.xpath("//group[@name='sale']/div/button[@name='action_company_properties']"):
node.set('invisible', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
modifiers['invisible'] = True
node.set("modifiers", json.dumps(modifiers))
res['arch'] = etree.tostring(doc)
return res

0 comments on commit 71b2b01

Please sign in to comment.