Skip to content

Commit

Permalink
portal_sale_distributor: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc committed Jun 27, 2023
1 parent 0b1baf3 commit 6350a64
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 13 deletions.
5 changes: 3 additions & 2 deletions portal_sale_distributor/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import sale_order
from . import mail_thread
from . import ir_action_act_window
from . import mail_thread
from . import product_product
from . import sale_order
24 changes: 24 additions & 0 deletions portal_sale_distributor/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
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 == 'tree':
if self.env.user.has_group('portal_sale_distributor.group_portal_backend_distributor'):
# ocultamos campos de módulos de los cuales no depende
fields = arch.xpath("//field[@name='taxed_lst_price']")
for node in fields:
node.set('invisible', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
modifiers['invisible'] = True
node.set("modifiers", json.dumps(modifiers))
return arch, view
2 changes: 2 additions & 0 deletions portal_sale_distributor/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ 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('portal_sale_distributor.group_portal_backend_distributor'):
# restringimos acceso
fields = (arch.xpath("//field[@name='partner_id']")
+ arch.xpath("//field[@name='partner_invoice_id']")
+ arch.xpath("//field[@name='partner_shipping_id']")
+ arch.xpath("//field[@name='product_id']") #ver
)
for node in fields:
node.set('options', "{'no_create': True, 'no_open': True}")
Expand Down
3 changes: 3 additions & 0 deletions portal_sale_distributor/views/portal_sale_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
<field name="sale_order_template_id" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<xpath expr="//field[@name='order_line']/tree//field[@name='product_uom'][2]" position="attributes">
<attribute name="groups">uom.group_uom,portal_sale_distributor.group_portal_backend_distributor</attribute>
</xpath>
</field>
</record>

Expand Down
5 changes: 0 additions & 5 deletions portal_sale_distributor/views/portal_templates.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<odoo>

<template id="sale_order_link" name="Link to backend" inherit_id="portal.user_dropdown">
<xpath expr="//a[@id='o_logout']" position="before">
<a href="/web" class="dropdown-item" groups="portal_sale_distributor.group_portal_distributor" role="menuitem">My Sale Orders</a>
</xpath>
</template>
<!-- TODO evaluate to implement different since the module account_debt_management it's deprecated in v13 -->
<!-- <template id="portal_my_summary" name="Portal My Summary : Partner Summary" inherit_id="portal.portal_my_home" priority="40">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
Expand Down
15 changes: 15 additions & 0 deletions portal_sale_distributor/views/product_product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@
<field name="virtual_available" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="lst_price" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="categ_id" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="product_tag_ids" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="type" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="uom_id" position="attributes">
<attribute name="groups">uom.group_uom,portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
</field>
</record>
</odoo>
44 changes: 38 additions & 6 deletions portal_sale_distributor/views/product_template_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<record model="ir.actions.act_window" id="action_product_template_portal_tree">
<field name="name">Products</field>
<field name="view_mode">tree</field>
<field name="view_mode">tree,kanban</field>
<field name="res_model">product.template</field>
<field name="view_id" ref="product.product_template_kanban_view"/>
<field name="context">{"portal_products":True, 'create': False}</field>
Expand All @@ -18,6 +18,26 @@
web_icon="portal_sale_distributor,static/description/icon.png"
/>

<record id="product_template_tree_view" model="ir.ui.view">
<field name="name">product.template.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="arch" type="xml">
<field name="list_price" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="categ_id" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="product_tag_ids" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
<field name="uom_id" position="attributes">
<attribute name="groups">uom.group_uom,portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
</field>
</record>

<record id="view_stock_product_template_tree" model="ir.ui.view">
<field name="name">product.template.inherit</field>
<field name="model">product.template</field>
Expand All @@ -32,14 +52,26 @@
</field>
</record>

<record id="product_template_tree_view" model="ir.ui.view">
<field name="name">product.template.inherit</field>
<record id="product_template_kanban_view" model="ir.ui.view">
<field name="name">product.template.product.kanban</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="inherit_id" ref="product.product_template_kanban_view"/>
<field name="arch" type="xml">
<field name="list_price" position="attributes">
<div name="product_lst_price" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</field>
</div>
</field>
</record>

<record id="product_template_kanban_stock_view" model="ir.ui.view">
<field name="name">Product Template Kanban Stock</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_kanban_stock_view"/>
<field name="arch" type="xml">
<div t-if="record.show_on_hand_qty_status_button.raw_value" position="attributes">
<attribute name="groups">!portal_sale_distributor.group_portal_backend_distributor</attribute>
</div>
</field>
</record>

</odoo>

0 comments on commit 6350a64

Please sign in to comment.