Use explicit list of product types for stock move
issue10225 review361481002
This commit is contained in:
1 parent
f5a7149336
commit
347d928aff
2 files changed
+20
-10
No files matched your search
@@ -45,10 +45,7 @@ class BOMInput(ModelSQL, ModelView):
|
||||
|
||||
bom = fields.Many2One('production.bom', 'BOM', required=True,
|
||||
select=1, ondelete='CASCADE')
|
||||
product = fields.Many2One('product.product', 'Product',
|
||||
required=True, domain=[
|
||||
('type', '!=', 'service'),
|
||||
])
|
||||
product = fields.Many2One('product.product', 'Product', required=True)
|
||||
uom_category = fields.Function(fields.Many2One(
|
||||
'product.uom.category', 'Uom Category'), 'on_change_with_uom_category')
|
||||
uom = fields.Many2One('product.uom', 'Uom', required=True,
|
||||
@@ -68,6 +65,7 @@ class BOMInput(ModelSQL, ModelView):
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(BOMInput, cls).__setup__()
|
||||
cls.product.domain = [('type', 'in', cls.get_product_types())]
|
||||
cls.__access__.add('bom')
|
||||
t = cls.__table__()
|
||||
cls._sql_constraints = [
|
||||
@@ -75,6 +73,10 @@ class BOMInput(ModelSQL, ModelView):
|
||||
'production.msg_product_bom_unique'),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def get_product_types(cls):
|
||||
return ['goods', 'assets']
|
||||
|
||||
@fields.depends('product', 'uom')
|
||||
def on_change_product(self):
|
||||
if self.product:
|
||||
|
||||
+14
-6
@@ -10,11 +10,19 @@ from trytond.pool import PoolMeta
|
||||
|
||||
class Template(metaclass=PoolMeta):
|
||||
__name__ = 'product.template'
|
||||
producible = fields.Boolean(
|
||||
"Producible", states={
|
||||
'invisible': Eval('type') == 'service',
|
||||
},
|
||||
depends=['type'])
|
||||
producible = fields.Boolean("Producible")
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls.producible.states = {
|
||||
'invisible': ~Eval('type').in_(cls.get_producible_types()),
|
||||
}
|
||||
cls.producible.depends = ['type']
|
||||
|
||||
@classmethod
|
||||
def get_producible_types(cls):
|
||||
return ['goods', 'assets']
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
@@ -102,7 +110,7 @@ class ProductionLeadTime(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
|
||||
product = fields.Many2One('product.product', 'Product',
|
||||
ondelete='CASCADE', select=True, required=True,
|
||||
domain=[
|
||||
('type', '!=', 'service'),
|
||||
('producible', '=', True),
|
||||
])
|
||||
bom = fields.Many2One('production.bom', 'BOM', ondelete='CASCADE',
|
||||
domain=[
|
||||
|
||||
Reference in new issue
Block a user