Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
34c8dab
[FIX]remove first line for the license and add comments
bizzappdev Feb 11, 2020
45b0b9f
[FIX]flake8
bizzappdev Feb 12, 2020
805e4a1
[FIX]fix test
bizzappdev Feb 20, 2020
d3497ac
Merge branch '12.0-add-comments' of gitlab.pledra.com:pledra/odoo-pro…
bizzappdev Feb 20, 2020
90fe1c6
[FIX]fix test case for onchange_attribute
bizzappdev Mar 5, 2020
27d8d69
Make the config_session store json-serializable / string key vs int &…
PCatinean May 7, 2020
bd73d4a
Fix missing session update in cfg_session method
PCatinean May 7, 2020
958dab6
Removing unused variables
PCatinean May 7, 2020
a563008
Merge branch '12.0-T01206-redis-session-storage-fix-pc' into '12.0'
PCatinean May 7, 2020
9bde9af
Merge branch '12.0-add-comments' into '12.0'
PCatinean May 7, 2020
9ea1166
[FIX]hide attribute if no value is available
bizzappdev Jun 27, 2020
46cda27
[FIX]add field invisible to hide attribute when boolean ticked and no…
bizzappdev Jun 29, 2020
ae8e9bb
[FIX]change attribute name
bizzappdev Jun 29, 2020
1540d9b
[FIX]hide not availble attributes in backend wizard
bizzappdev Jun 30, 2020
6bfc8d7
Merge branch '12.0-hide-attribute-no-available-value' into '12.0'
PCatinean Jul 20, 2020
e798b22
Merge remote-tracking branch 'github/12.0' into 12.0
PCatinean Jul 20, 2020
64eeb69
[FIX]add fields quantity in product attribute
bizzappdev Jul 15, 2020
b4c494b
[FIX]is quantity ticked and product is there on attribute then add in…
bizzappdev Jul 18, 2020
54fa86b
[FIX]update attr_product on change of quantity
bizzappdev Jul 18, 2020
cc08f6c
[FIX]removed print
bizzappdev Jul 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion product_configurator/models/product_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def onchange_custom_type(self):
def onchange_val_custom_field(self):
if not self.val_custom:
self.custom_type = False
self.quantity = False

@api.onchange('quantity')
def onchange_quantity(self):
if self.quantity:
self.custom_type = "int"

CUSTOM_TYPES = [
('char', 'Char'),
Expand Down Expand Up @@ -101,7 +107,10 @@ def onchange_val_custom_field(self):
"when there is no available attribute values, in the configuration "
"interface"
)

quantity = fields.Boolean(string="Quantity")
attr_product_id = fields.Many2one(
comodel_name="product.product", string="Product"
)
# TODO prevent the same attribute from being defined twice on the
# attribute lines

Expand Down Expand Up @@ -166,6 +175,8 @@ def onchange_attribute(self):
self.multi = self.attribute_id.multi
self.custom = self.attribute_id.val_custom
self.hide = self.attribute_id.hide
self.quantity = self.attribute_id.quantity
self.attr_product_id = self.attribute_id.attr_product_id
# TODO: Remove all dependencies pointed towards the attribute being
# changed

Expand Down Expand Up @@ -202,9 +213,19 @@ def onchange_values(self):
"when there is no available attribute values, in the configuration "
"interface"
)
quantity = fields.Boolean(string="Quantity")
# TODO: Constraint not allowing introducing dependencies that do not exist
# on the product.template

@api.onchange('custom')
def onchange_custom_field(self):
if not self.custom:
self.quantity = False
self.attr_product_id = False
else:
self.quantity = self.attribute_id.quantity
self.attr_product_id = self.attribute_id.attr_product_id

def _search_product_template_value_ids(self, operator, value):
return [('id', operator, value)]

Expand Down
20 changes: 18 additions & 2 deletions product_configurator/models/product_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def get_cfg_price(self, value_ids=None, custom_vals=None):
value_ids = self.value_ids.ids

if custom_vals is None:
custom_vals = {}
custom_vals = self._get_custom_vals_dict()

product_tmpl = self.product_tmpl_id
self = self.with_context({'active_id': product_tmpl.id})
Expand All @@ -834,7 +834,23 @@ def get_cfg_price(self, value_ids=None, custom_vals=None):
pt_attr_value_ids=av_ids,
)
price_extra = sum(extra_prices.values())
return product_tmpl.list_price + price_extra

pricelist = self.env.context.get("pricelist")
if pricelist:
pricelist = self.env["product.pricelist"].browse(pricelist)
else:
pricelist = self.env.user.partner_id.property_product_pricelist
custom_vals_price = 0
for attribute, custom_val in custom_vals.items():
attribute_id = self.env["product.attribute"].browse(attribute)
if attribute_id.quantity and attribute_id.attr_product_id:
custom_vals_price += (
attribute_id.attr_product_id.with_context(
pricelist=pricelist.id
).price * custom_val
)

return product_tmpl.list_price + price_extra + custom_vals_price

def _get_config_image(
self, value_ids=None, custom_vals=None, size=None):
Expand Down
4 changes: 3 additions & 1 deletion product_configurator/views/product_attribute_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,19 @@
<field name="required"/>
<field name="multi" attrs="{'readonly': [('val_custom','=',True)]}" force_save="1"/>
<field name="val_custom" attrs="{'readonly': [('multi', '=', True)]}" force_save="1"/>
<field name="quantity" attrs="{'invisible': [('val_custom', '=', False)], 'required': [('val_custom', '!=', False)]}"/>
</group>
<group>
<field name="uom_id"/>
<field name="attr_product_id" attrs="{'invisible': [('quantity', '=', False)]}"/>
</group>
<field name="description" colspan="4"/>
</group>
</page>
<page string="Custom Values" attrs="{'invisible': [('val_custom', '!=', True)]}" groups="product_configurator.group_product_configurator_manager">
<group>
<group>
<field name="custom_type"/>
<field name="custom_type" attrs="{'readonly': [('quantity', '=', True)]}" force_save="1"/>
<field name="min_val" attrs="{'invisible': [('custom_type','not in',['int','float'])]}"/>
<field name="max_val" attrs="{'invisible': [('custom_type','not in',['int','float'])]}"/>
</group>
Expand Down