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

Commit 9bde9af

Browse files
committed
Merge branch '12.0-add-comments' into '12.0'
[FIX]remove first line for the license and add comments See merge request pledra/odoo-product-configurator!84
2 parents a563008 + 958dab6 commit 9bde9af

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

product_configurator/tests/test_product_config.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,19 +544,41 @@ def test_18_onchange_attribute(self):
544544
})
545545
self.productConfigDomainId.compute_domain()
546546
# create attribute value line 1
547-
config_line = self.env['product.config.line'].create({
547+
self.env['product.config.line'].create({
548548
'product_tmpl_id': self.product_tmpl_id.id,
549549
'attribute_line_id': self.attributeLine1.id,
550550
'value_ids': [(6, 0, [
551551
self.attribute_vals_1.id,
552552
self.attribute_vals_2.id])],
553553
'domain_id': self.productConfigDomainId.id
554554
})
555-
with self.assertRaises(ValidationError):
556-
config_line.onchange_attribute()
555+
556+
line_vals = {
557+
'product_tmpl_id': self.product_tmpl_id.id,
558+
'attribute_line_id': self.attributeLine1.id,
559+
'value_ids': [(6, 0, [
560+
self.attribute_vals_1.id,
561+
self.attribute_vals_2.id])],
562+
'domain_id': self.productConfigDomainId.id
563+
}
564+
order_line_obj = self.env['product.config.line']
565+
specs = order_line_obj._onchange_spec()
566+
updates = order_line_obj.onchange(
567+
line_vals, ['attribute_line_id'], specs
568+
)
569+
values = updates.get('value', {})
570+
for name, val in values.items():
571+
if isinstance(val, tuple):
572+
values[name] = val[0]
557573

558574
self.assertFalse(
559-
config_line.value_ids,
575+
values.get('domain_id'),
576+
'Error: If value_ids True\
577+
Method: onchange_attribute()'
578+
)
579+
self.assertEqual(
580+
values.get('value_ids')[0],
581+
(5,),
560582
'Error: If value_ids True\
561583
Method: onchange_attribute()'
562584
)

website_product_configurator/models/sale_order.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
21
import logging
32
from odoo import api, models, _
43
from odoo.http import request
@@ -17,6 +16,7 @@ def _cart_update(self, product_id=None, line_id=None,
1716
self.ensure_one()
1817
product_context = dict(self.env.context)
1918
product_context.setdefault('lang', self.sudo().partner_id.lang)
19+
# BizzAppDev Customization
2020
cfg_product = self.env['product.product'].with_context(
2121
product_context
2222
).browse(int(product_id))
@@ -28,6 +28,7 @@ def _cart_update(self, product_id=None, line_id=None,
2828
set_qty=set_qty,
2929
kwargs=kwargs
3030
)
31+
# BizzAppDev Customization End
3132

3233
SaleOrderLineSudo = self.env['sale.order.line'].sudo().\
3334
with_context(product_context)
@@ -85,9 +86,11 @@ def _cart_update(self, product_id=None, line_id=None,
8586
combination = product_template._get_closest_possible_combination(
8687
received_combination)
8788

89+
# BizzAppDev Customization
8890
# prevent to change variant in cart
8991
# get or create (if dynamic) the correct variant
9092
# product = product_template._create_product_variant(combination)
93+
# BizzAppDev Customization End
9194

9295
if not product:
9396
raise UserError(_(
@@ -204,6 +207,7 @@ def _cart_update(self, product_id=None, line_id=None,
204207
'quantity': quantity,
205208
'date': order.date_order,
206209
'pricelist': order.pricelist_id.id,
210+
'force_company': order.company_id.id,
207211
})
208212
product = self.env['product.product'].with_context(
209213
product_context).browse(product_id)

0 commit comments

Comments
 (0)