Make bom and route readonly if process defined and copy values from process
This commit is contained in:
parent
3ce2f299d0
commit
11042be27a
|
@ -18,6 +18,10 @@ msgstr ""
|
|||
"La ruta \"%(bom)s\" no es pot eliminar perquè ha estat creada pel process "
|
||||
"\"%(process)s\"."
|
||||
|
||||
msgctxt "field:product.product-production.bom,process:"
|
||||
msgid "Process"
|
||||
msgstr "Procés"
|
||||
|
||||
msgctxt "field:production,process:"
|
||||
msgid "Process"
|
||||
msgstr "Procés"
|
||||
|
@ -62,6 +66,10 @@ msgctxt "field:production.process,operations:"
|
|||
msgid "Operations"
|
||||
msgstr "Operacions"
|
||||
|
||||
msgctxt "field:production.process,output_products:"
|
||||
msgid "Outputs"
|
||||
msgstr "Sortides"
|
||||
|
||||
msgctxt "field:production.process,outputs:"
|
||||
msgid "Outputs"
|
||||
msgstr "Sortides"
|
||||
|
|
|
@ -18,6 +18,10 @@ msgstr ""
|
|||
"La ruta \"%(route)s\" no se puede eliminar porqué ha sido creada por el "
|
||||
"proceso \"%(process)s\"."
|
||||
|
||||
msgctxt "field:product.product-production.bom,process:"
|
||||
msgid "Process"
|
||||
msgstr "Proceso"
|
||||
|
||||
msgctxt "field:production,process:"
|
||||
msgid "Process"
|
||||
msgstr "Proceso"
|
||||
|
@ -62,6 +66,10 @@ msgctxt "field:production.process,operations:"
|
|||
msgid "Operations"
|
||||
msgstr "Operaciones"
|
||||
|
||||
msgctxt "field:production.process,output_products:"
|
||||
msgid "Outputs"
|
||||
msgstr "Salidas"
|
||||
|
||||
msgctxt "field:production.process,outputs:"
|
||||
msgid "Outputs"
|
||||
msgstr "Salidas"
|
||||
|
|
24
product.py
24
product.py
|
@ -16,7 +16,29 @@ class ProductBom:
|
|||
('output_products', '=', If(Bool(Eval('product')),
|
||||
Eval('product', 0),
|
||||
Get(Eval('_parent_product', {}), 'id', 0))),
|
||||
], depends=['product'])
|
||||
],
|
||||
depends=['product'], on_change=['process', 'bom', 'route'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ProductBom, cls).__setup__()
|
||||
if not 'process' in cls.bom.depends:
|
||||
cls.bom.states.update({
|
||||
'readonly': Bool(Eval('process', 0)),
|
||||
})
|
||||
cls.bom.depends.append('process')
|
||||
if not 'process' in cls.route.depends:
|
||||
cls.route.states.update({
|
||||
'readonly': Bool(Eval('process', 0)),
|
||||
})
|
||||
cls.route.depends.append('process')
|
||||
|
||||
def on_change_process(self):
|
||||
res = {}
|
||||
if self.process:
|
||||
res['bom'] = self.process.bom.id
|
||||
res['route'] = self.process.route.id
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
|
|
|
@ -204,17 +204,18 @@ Create a process definition::
|
|||
>>> len(process.route.operations) == 2
|
||||
True
|
||||
>>> bom = process.bom
|
||||
>>> len(bom.inputs) == 2
|
||||
True
|
||||
>>> len(bom.outputs) == 1
|
||||
True
|
||||
>>> route = process.route
|
||||
>>> ProductBom = Model.get('product.product-production.bom')
|
||||
>>> product.processes.append(ProductBom(process=process))
|
||||
>>> product_bom = ProductBom()
|
||||
>>> product.boms.append(product_bom)
|
||||
>>> product_bom.process = process
|
||||
>>> product_bom.bom == bom
|
||||
True
|
||||
>>> product_bom.route == route
|
||||
True
|
||||
>>> product.save()
|
||||
>>> len(product.boms) == 1
|
||||
True
|
||||
>>> product.boms[0].bom == bom
|
||||
True
|
||||
|
||||
Create an Inventory::
|
||||
|
||||
|
|
Loading…
Reference in New Issue