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:
|
class ProductBom:
|
||||||
__name__ = 'product.product-production.bom'
|
__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
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
|
|
|
@ -18,9 +18,12 @@ class Process(ModelSQL, ModelView):
|
||||||
bom = fields.Many2One('production.bom', 'BOM', required=True)
|
bom = fields.Many2One('production.bom', 'BOM', required=True)
|
||||||
route = fields.Many2One('production.route', 'Route', required=True)
|
route = fields.Many2One('production.route', 'Route', required=True)
|
||||||
inputs = fields.Function(fields.One2Many('production.bom.input', None,
|
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 = 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',
|
operations = fields.Function(fields.One2Many('production.route.operation',
|
||||||
None, 'Operations'), 'get_operations')
|
None, 'Operations'), 'get_operations')
|
||||||
uom = fields.Many2One('product.uom', 'UOM', required=True)
|
uom = fields.Many2One('product.uom', 'UOM', required=True)
|
||||||
|
@ -30,16 +33,10 @@ class Process(ModelSQL, ModelView):
|
||||||
def default_active():
|
def default_active():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_inputs(self, name):
|
def get_bom_field(self, name):
|
||||||
res = []
|
res = []
|
||||||
if self.bom:
|
if self.bom:
|
||||||
res += [x.id for x in self.bom.inputs]
|
res += [x.id for x in getattr(self.bom, name)]
|
||||||
return res
|
|
||||||
|
|
||||||
def get_outputs(self, name):
|
|
||||||
res = []
|
|
||||||
if self.bom:
|
|
||||||
res += [x.id for x in self.bom.outputs]
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_operations(self, name):
|
def get_operations(self, name):
|
||||||
|
@ -48,6 +45,10 @@ class Process(ModelSQL, ModelView):
|
||||||
res += [x.id for x in self.route.operations]
|
res += [x.id for x in self.route.operations]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def search_bom_field(cls, name, clause):
|
||||||
|
return [tuple(('bom.' + name,)) + tuple(clause[1:])]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
copyright notices and license terms. -->
|
copyright notices and license terms. -->
|
||||||
<form string="Product - Process" col="4">
|
<form string="Product - Process" col="4">
|
||||||
<label name="process"/>
|
<label name="process"/>
|
||||||
<field name="process"/>
|
<field name="process" widget="selection"/>
|
||||||
<label name="sequence"/>
|
<label name="sequence"/>
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
<newline/>
|
<newline/>
|
||||||
<label name="name"/>
|
<label name="name"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<label name="bom"/>
|
|
||||||
<field name="bom"/>
|
|
||||||
<label name="route"/>
|
|
||||||
<field name="route"/>
|
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
<page string="Description" id="description">
|
<page string="Description" id="description">
|
||||||
<field name="description" colspan="4"/>
|
<field name="description" colspan="4"/>
|
||||||
|
|
Loading…
Reference in New Issue