mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
NEW product_variant_so_always for 11.0
Adds boolean on the `product.template` form to force the 'dynamic' mode for NOT creating variants on `product.template` save, but rather when added to sale orders.
This commit is contained in:
committed by
Connor Christian
parent
ef4a00ba95
commit
5fe32edd5c
1
product_variant_so_always/tests/__init__.py
Normal file
1
product_variant_so_always/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_product_creation
|
||||
45
product_variant_so_always/tests/test_product_creation.py
Normal file
45
product_variant_so_always/tests/test_product_creation.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from odoo.tests import common
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class TestProductCreation(common.TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestProductCreation, self).setUp()
|
||||
self.attrs = []
|
||||
|
||||
# Create 1000 combinations
|
||||
for a in range(1, 4):
|
||||
attribute = self.env['product.attribute'].create({
|
||||
'name': 'Attr ' + str(a),
|
||||
'type': 'radio',
|
||||
'create_variant': 'always',
|
||||
})
|
||||
self.attrs.append(attribute)
|
||||
for v in range(1, 11):
|
||||
self.env['product.attribute.value'].create({
|
||||
'name': 'Value ' + str(v),
|
||||
'attribute_id': attribute.id,
|
||||
})
|
||||
# Create 1 more...
|
||||
self.env['product.attribute.value'].create({
|
||||
'name': 'Value 11',
|
||||
'attribute_id': self.attrs[0].id,
|
||||
})
|
||||
|
||||
def test_01_product_template(self):
|
||||
product_tmpl = self.env['product.template'].create({
|
||||
'name': 'Test Product',
|
||||
'type': 'product',
|
||||
})
|
||||
attr_line_model = self.env['product.template.attribute.line']
|
||||
for a in self.attrs:
|
||||
attr_line_model.create({
|
||||
'product_tmpl_id': product_tmpl.id,
|
||||
'attribute_id': a.id,
|
||||
'value_ids': [(6, 0, a.value_ids.ids)],
|
||||
})
|
||||
with self.assertRaises(UserError):
|
||||
product_tmpl.create_variant_ids()
|
||||
|
||||
product_tmpl.always_variant_on_so = True
|
||||
product_tmpl.create_variant_ids()
|
||||
Reference in New Issue
Block a user