Skip to content

Commit

Permalink
[IMP] sale_configurator_base: Only prevent direct sol edition if prod…
Browse files Browse the repository at this point in the history
…uct was added by the sale configurator interface
  • Loading branch information
paradoxxxzero committed Apr 4, 2022
1 parent 87c8971 commit cea4e39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion sale_configurator_base/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def onchange_sale_line_sequence(self):
def _fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
""" fields_view_get comes from Model (not AbstractModel) """
"""fields_view_get comes from Model (not AbstractModel)"""
res = super()._fields_view_get(
view_id=view_id,
view_type=view_type,
Expand All @@ -74,7 +74,9 @@ def _fields_view_get(
"readonly": [
"|",
("parent_id", "!=", False),
"&",
("is_configurable", "=", True),
("is_configured", "=", True),
]
},
)
Expand Down Expand Up @@ -132,6 +134,11 @@ class SaleOrderLine(models.Model):
"Line is a configurable Product ?",
compute="_compute_is_configurable",
)
# Technical field to know if the line was created from the
# Add Configurable Product interface
is_configured = fields.Boolean(
"Line is a configured Product ?",
)
report_line_is_empty_parent = fields.Boolean(
compute="_compute_report_line_is_empty_parent",
help="Technical field used in the report to hide subtotals"
Expand Down
11 changes: 9 additions & 2 deletions sale_configurator_base/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<field name="pricelist_id" invisible="1" />
<field name="company_id" invisible="1" />
<field name="state" invisible="1" />
<field name="is_configured" invisible="1" />
<!-- There is some magic here, please look at models/ir_ui_view.py
We dynamically retrieve all field from the sale order form
-->
Expand Down Expand Up @@ -62,11 +63,12 @@
class="btn-primary oe_edit_only oe_left"
states="draft,sent"
context="{'default_order_id': id,
'default_name': '/', }"
'default_name': '/', 'default_is_configured': True}"
/>
</xpath>
<xpath expr="//form/field[@name='display_type']" position="before">
<field name="is_configurable" invisible="1" />
<field name="is_configured" invisible="1" />
</xpath>
<xpath expr="//field[@name='order_line']//tree" position="attributes">
<attribute name="decoration-it">parent_id</attribute>
Expand All @@ -90,6 +92,7 @@
attrs="{'invisible': [('parent_id', '!=', False)]}"
string="Subtotal"
/>
<field name="is_configured" invisible="1" />
<field name="is_configurable" invisible="1" />
<field name="parent_id" invisible="1" />
</xpath>
Expand All @@ -101,7 +104,11 @@
name="open_sale_line_config_base"
type="object"
icon="fa-th"
attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'sent')), ('is_configurable', '=', False)]}"
attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'sent')), '|', ('is_configurable', '=', False), ('is_configured', '=', False)]}"
/>
<button
icon="fa-ban"
attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'sent')), '|', ('is_configurable', '=', False), ('is_configured', '=', True)]}"
/>
</xpath>
<xpath expr="//field[@name='order_line']" position="attributes">
Expand Down

0 comments on commit cea4e39

Please sign in to comment.