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 "
|
"La ruta \"%(bom)s\" no es pot eliminar perquè ha estat creada pel process "
|
||||||
"\"%(process)s\"."
|
"\"%(process)s\"."
|
||||||
|
|
||||||
|
msgctxt "field:product.product-production.bom,process:"
|
||||||
|
msgid "Process"
|
||||||
|
msgstr "Procés"
|
||||||
|
|
||||||
msgctxt "field:production,process:"
|
msgctxt "field:production,process:"
|
||||||
msgid "Process"
|
msgid "Process"
|
||||||
msgstr "Procés"
|
msgstr "Procés"
|
||||||
|
@ -62,6 +66,10 @@ msgctxt "field:production.process,operations:"
|
||||||
msgid "Operations"
|
msgid "Operations"
|
||||||
msgstr "Operacions"
|
msgstr "Operacions"
|
||||||
|
|
||||||
|
msgctxt "field:production.process,output_products:"
|
||||||
|
msgid "Outputs"
|
||||||
|
msgstr "Sortides"
|
||||||
|
|
||||||
msgctxt "field:production.process,outputs:"
|
msgctxt "field:production.process,outputs:"
|
||||||
msgid "Outputs"
|
msgid "Outputs"
|
||||||
msgstr "Sortides"
|
msgstr "Sortides"
|
||||||
|
|
|
@ -18,6 +18,10 @@ msgstr ""
|
||||||
"La ruta \"%(route)s\" no se puede eliminar porqué ha sido creada por el "
|
"La ruta \"%(route)s\" no se puede eliminar porqué ha sido creada por el "
|
||||||
"proceso \"%(process)s\"."
|
"proceso \"%(process)s\"."
|
||||||
|
|
||||||
|
msgctxt "field:product.product-production.bom,process:"
|
||||||
|
msgid "Process"
|
||||||
|
msgstr "Proceso"
|
||||||
|
|
||||||
msgctxt "field:production,process:"
|
msgctxt "field:production,process:"
|
||||||
msgid "Process"
|
msgid "Process"
|
||||||
msgstr "Proceso"
|
msgstr "Proceso"
|
||||||
|
@ -62,6 +66,10 @@ msgctxt "field:production.process,operations:"
|
||||||
msgid "Operations"
|
msgid "Operations"
|
||||||
msgstr "Operaciones"
|
msgstr "Operaciones"
|
||||||
|
|
||||||
|
msgctxt "field:production.process,output_products:"
|
||||||
|
msgid "Outputs"
|
||||||
|
msgstr "Salidas"
|
||||||
|
|
||||||
msgctxt "field:production.process,outputs:"
|
msgctxt "field:production.process,outputs:"
|
||||||
msgid "Outputs"
|
msgid "Outputs"
|
||||||
msgstr "Salidas"
|
msgstr "Salidas"
|
||||||
|
|
24
product.py
24
product.py
|
@ -16,7 +16,29 @@ class ProductBom:
|
||||||
('output_products', '=', If(Bool(Eval('product')),
|
('output_products', '=', If(Bool(Eval('product')),
|
||||||
Eval('product', 0),
|
Eval('product', 0),
|
||||||
Get(Eval('_parent_product', {}), 'id', 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
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
|
|
|
@ -204,17 +204,18 @@ Create a process definition::
|
||||||
>>> len(process.route.operations) == 2
|
>>> len(process.route.operations) == 2
|
||||||
True
|
True
|
||||||
>>> bom = process.bom
|
>>> bom = process.bom
|
||||||
>>> len(bom.inputs) == 2
|
>>> route = process.route
|
||||||
True
|
|
||||||
>>> len(bom.outputs) == 1
|
|
||||||
True
|
|
||||||
>>> ProductBom = Model.get('product.product-production.bom')
|
>>> 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()
|
>>> product.save()
|
||||||
>>> len(product.boms) == 1
|
>>> len(product.boms) == 1
|
||||||
True
|
True
|
||||||
>>> product.boms[0].bom == bom
|
|
||||||
True
|
|
||||||
|
|
||||||
Create an Inventory::
|
Create an Inventory::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue