Skip to content

Commit b6feec4

Browse files
committed
Remove lot_sequence multivalue
stock.lot is not by company Revert from #059920
1 parent 9ca45d6 commit b6feec4

File tree

3 files changed

+13
-70
lines changed

3 files changed

+13
-70
lines changed

__init__.py

-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,5 @@ def register():
1111
product.ConfigurationDefaultLotSequence,
1212
product.CategoryCompany,
1313
product.Category,
14-
product.TemplateCompany,
15-
product.Template,
16-
product.Product,
1714
stock.Lot,
1815
module='stock_lot_sequence', type_='model')

product.py

+7-65
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ class CategoryCompany(ModelSQL, CompanyValueMixin):
4545
lot_sequence = fields.Many2One(
4646
'ir.sequence', 'Lot Sequence',
4747
domain=[
48-
('sequence_type', '=', Id('stock_lot',
49-
'sequence_type_stock_lot')),
50-
('company', 'in', [Eval('company', -1), None]),
48+
('sequence_type', '=', Id('stock_lot', 'sequence_type_stock_lot')),
49+
('company', '=', None),
5150
])
5251

5352
@classmethod
@@ -56,72 +55,15 @@ def __register__(cls, module_name):
5655

5756
if exist:
5857
backend.TableHandler.table_rename('product_category_company', cls._table)
59-
super(CategoryCompany, cls).__register__(module_name)
58+
super().__register__(module_name)
6059

6160

6261
class Category(CompanyMultiValueMixin, metaclass=PoolMeta):
6362
__name__ = 'product.category'
6463
lot_sequence = fields.MultiValue(fields.Many2One('ir.sequence',
65-
'Lot Sequence', domain=[
66-
('sequence_type', '=', Id('stock_lot',
67-
'sequence_type_stock_lot')),
68-
('company', 'in',
69-
[Eval('context', {}).get('company', -1), None]),
70-
],
71-
states={
72-
'invisible': ~Eval('context', {}).get('company'),
73-
}))
74-
64+
'Lot Sequence', domain=[
65+
('sequence_type', '=', Id('stock_lot', 'sequence_type_stock_lot')),
66+
('company', '=', None),
67+
]))
7568
lot_sequences = fields.One2Many('product.category.lot_sequence',
7669
'category', 'Lot Sequences')
77-
78-
79-
class TemplateCompany(ModelSQL, CompanyValueMixin):
80-
'Template per Company'
81-
__name__ = 'product.template.lot_sequence'
82-
template = fields.Many2One('product.template', 'Template', required=True,
83-
ondelete='CASCADE', context={
84-
'company': Eval('company', -1),
85-
},
86-
depends=['company'])
87-
lot_sequence = fields.Many2One(
88-
'ir.sequence', 'Lot Sequence',
89-
domain=[
90-
('sequence_type', '=', Id('stock_lot',
91-
'sequence_type_stock_lot')),
92-
('company', 'in', [Eval('company', -1), None]),
93-
])
94-
95-
@classmethod
96-
def __register__(cls, module_name):
97-
exist = backend.TableHandler.table_exist('product_template_company')
98-
99-
if exist:
100-
backend.TableHandler.table_rename('product_template_company',
101-
cls._table)
102-
super(TemplateCompany, cls).__register__(module_name)
103-
104-
105-
class Template(metaclass=PoolMeta):
106-
__name__ = 'product.template'
107-
lot_sequences = fields.One2Many('product.template.lot_sequence',
108-
'template', 'Lot Sequences')
109-
110-
@classmethod
111-
def __setup__(cls):
112-
super(Template, cls).__setup__()
113-
# replace m2o field from stock_lot to MultiValue
114-
cls.lot_sequence = fields.MultiValue(fields.Many2One('ir.sequence',
115-
'Lot Sequence', domain=[
116-
('sequence_type', '=', Id('stock_lot',
117-
'sequence_type_stock_lot')),
118-
('company', 'in',
119-
[Eval('context', {}).get('company', -1), None]),
120-
],
121-
states={
122-
'invisible': ~Eval('context', {}).get('company'),
123-
}))
124-
125-
126-
class Product(metaclass=PoolMeta):
127-
__name__ = 'product.product'

tests/test_module.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ def test_lot_sequence(self):
5454

5555
sequence_type = SequenceType(ModelData.get_id('stock_lot',
5656
'sequence_type_stock_lot'))
57-
cat_sequence = Sequence(sequence_type=sequence_type,
57+
cat_sequence = Sequence(
58+
sequence_type=sequence_type,
59+
company=None,
5860
name='Category Sequence')
5961
cat_sequence.save()
6062
sequence_type = SequenceType(ModelData.get_id('stock_lot',
6163
'sequence_type_stock_lot'))
62-
tem_sequence = Sequence(sequence_type=sequence_type,
64+
tem_sequence = Sequence(
65+
sequence_type=sequence_type,
66+
company=None,
6367
name='Template Sequence')
6468
tem_sequence.save()
6569

0 commit comments

Comments
 (0)