Add output products to process and add domain on product form
This commit is contained in:
parent
4f5639f6ff
commit
066aa2589d
|
@ -30,7 +30,12 @@ class Product:
|
|||
class ProductBom:
|
||||
__name__ = 'product.product-production.bom'
|
||||
|
||||
process = fields.Many2One('production.process', 'Process')
|
||||
process = fields.Many2One('production.process', 'Process',
|
||||
select=True, domain=[
|
||||
('output_products', '=', If(Bool(Eval('product')),
|
||||
Eval('product', 0),
|
||||
Get(Eval('_parent_product', {}), 'id', 0))),
|
||||
], depends=['product'])
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
|
|
|
@ -18,9 +18,12 @@ class Process(ModelSQL, ModelView):
|
|||
bom = fields.Many2One('production.bom', 'BOM', required=True)
|
||||
route = fields.Many2One('production.route', 'Route', required=True)
|
||||
inputs = fields.Function(fields.One2Many('production.bom.input', None,
|
||||
'Inputs'), 'get_inputs')
|
||||
'Inputs'), 'get_bom_field')
|
||||
outputs = fields.Function(fields.One2Many('production.bom.output', None,
|
||||
'Outputs'), 'get_outputs')
|
||||
'Outputs'), 'get_bom_field')
|
||||
output_products = fields.Function(fields.Many2Many('production.bom.output',
|
||||
'bom', 'product', 'Outputs'), 'get_bom_field',
|
||||
searcher='search_bom_field')
|
||||
operations = fields.Function(fields.One2Many('production.route.operation',
|
||||
None, 'Operations'), 'get_operations')
|
||||
uom = fields.Many2One('product.uom', 'UOM', required=True)
|
||||
|
@ -30,16 +33,10 @@ class Process(ModelSQL, ModelView):
|
|||
def default_active():
|
||||
return True
|
||||
|
||||
def get_inputs(self, name):
|
||||
def get_bom_field(self, name):
|
||||
res = []
|
||||
if self.bom:
|
||||
res += [x.id for x in self.bom.inputs]
|
||||
return res
|
||||
|
||||
def get_outputs(self, name):
|
||||
res = []
|
||||
if self.bom:
|
||||
res += [x.id for x in self.bom.outputs]
|
||||
res += [x.id for x in getattr(self.bom, name)]
|
||||
return res
|
||||
|
||||
def get_operations(self, name):
|
||||
|
@ -48,6 +45,10 @@ class Process(ModelSQL, ModelView):
|
|||
res += [x.id for x in self.route.operations]
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def search_bom_field(cls, name, clause):
|
||||
return [tuple(('bom.' + name,)) + tuple(clause[1:])]
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
pool = Pool()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
copyright notices and license terms. -->
|
||||
<form string="Product - Process" col="4">
|
||||
<label name="process"/>
|
||||
<field name="process"/>
|
||||
<field name="process" widget="selection"/>
|
||||
<label name="sequence"/>
|
||||
<field name="sequence"/>
|
||||
</form>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
<newline/>
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="bom"/>
|
||||
<field name="bom"/>
|
||||
<label name="route"/>
|
||||
<field name="route"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Description" id="description">
|
||||
<field name="description" colspan="4"/>
|
||||
|
|
Loading…
Reference in New Issue