Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 1540d9b

Browse files
committed
[FIX]hide not availble attributes in backend wizard
1 parent ae8e9bb commit 1540d9b

File tree

9 files changed

+19
-49
lines changed

9 files changed

+19
-49
lines changed

product_configurator/models/product_attribute.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ def onchange_val_custom_field(self):
9595
string='Unit of Measure'
9696
)
9797
image = fields.Binary(string='Image')
98+
hide = fields.Boolean(
99+
string="Invisible",
100+
help="Set in order to make attribute invisible, "
101+
"when there is no available attribute values, in the configuration "
102+
"interface"
103+
)
98104

99105
# TODO prevent the same attribute from being defined twice on the
100106
# attribute lines
@@ -159,6 +165,7 @@ def onchange_attribute(self):
159165
self.required = self.attribute_id.required
160166
self.multi = self.attribute_id.multi
161167
self.custom = self.attribute_id.val_custom
168+
self.hide = self.attribute_id.hide
162169
# TODO: Remove all dependencies pointed towards the attribute being
163170
# changed
164171

@@ -189,6 +196,12 @@ def onchange_values(self):
189196
comodel_name='product.template.attribute.value',
190197
search="_search_product_template_value_ids"
191198
)
199+
hide = fields.Boolean(
200+
string="Invisible",
201+
help="Set in order to make attribute invisible, "
202+
"when there is no available attribute values, in the configuration "
203+
"interface"
204+
)
192205
# TODO: Constraint not allowing introducing dependencies that do not exist
193206
# on the product.template
194207

product_configurator/views/product_attribute_view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<group>
6767
<group>
6868
<!--<field name="type"/> -->
69+
<field name="hide"/>
6970
<field name="required"/>
7071
<field name="multi" attrs="{'readonly': [('val_custom','=',True)]}" force_save="1"/>
7172
<field name="val_custom" attrs="{'readonly': [('multi', '=', True)]}" force_save="1"/>

product_configurator/views/product_view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
context="{'show_attribute': False}"
6464
options="{'no_create': True, 'no_create_edit': True}"
6565
invisible="not context.get('default_config_ok', False)"/>
66+
<field name="hide" invisible="not context.get('default_config_ok', False)"/>
6667
<field name="required" invisible="not context.get('default_config_ok', False)"/>
6768
<field name="multi" invisible="not context.get('default_config_ok', False)" attrs="{'readonly': [('custom','=',True)]}" force_save="1"/>
6869
<field name="custom" invisible="not context.get('default_config_ok', False)" attrs="{'readonly': [('multi','=',True)]}" force_save="1"/>

product_configurator/wizard/product_configurator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ def add_dynamic_fields(self, res, dynamic_fields, wiz):
657657
attrs['readonly'].append(
658658
(dependee_field, 'not in', list(val_ids)))
659659

660+
if not attr_line.custom and attr_line.hide:
661+
attrs['invisible'].append(
662+
(dependee_field, 'not in', list(val_ids)))
663+
660664
if attr_line.required and not attr_line.custom:
661665
attrs['required'].append(
662666
(dependee_field, 'in', list(val_ids)))

website_product_configurator/__manifest__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
'data/config_form_templates.xml',
1616
'data/cron.xml',
1717
'views/assets.xml',
18-
"views/product_attribute_view.xml",
1918
'views/product_view.xml',
2019
'views/templates.xml',
2120
'views/res_config_settings_view.xml',

website_product_configurator/models/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
from . import res_config_settings
33
from . import sale_order
44
from . import product_template
5-
from . import product_attribute

website_product_configurator/models/product_attribute.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

website_product_configurator/views/product_attribute_view.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

website_product_configurator/views/product_view.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
<xpath expr="//notebook/page[@name='configurator']//field[@name='config_step_line_ids']//tree//field[@name='attribute_line_ids']" position="after">
1111
<field name="website_tmpl_id"/>
1212
</xpath>
13-
<xpath expr="//field[@name='attribute_line_ids']//tree//field[@name='required']" position="before">
14-
<field name="hide" invisible="not context.get('default_config_ok', False)"/>
15-
</xpath>
1613
</field>
1714
</record>
1815

0 commit comments

Comments
 (0)