diff --git a/addons/mrp/__manifest__.py b/addons/mrp/__manifest__.py index 9766a88bf58338999ca79121b8c0055352859d92..d0ce94ee814728f3a4967a4ce891bde8568f280f 100644 --- a/addons/mrp/__manifest__.py +++ b/addons/mrp/__manifest__.py @@ -15,7 +15,6 @@ 'security/mrp_security.xml', 'security/ir.model.access.csv', 'data/mrp_data.xml', - 'data/mrp_data.yml', 'wizard/mrp_product_produce_views.xml', 'wizard/change_production_qty_views.xml', 'wizard/mrp_workcenter_block_view.xml', @@ -44,7 +43,7 @@ ], 'demo': [ 'data/mrp_demo.xml', - 'data/mrp_lot_demo.yml'], + ], 'qweb': ['static/src/xml/mrp.xml'], 'test': [], 'application': True, diff --git a/addons/mrp/data/mrp_data.xml b/addons/mrp/data/mrp_data.xml index 85fffdb3bd9d2e1b3fc36863acdc405a7d97d0fb..771c3c3ca4631f636060bb2db099313e35cdc736 100644 --- a/addons/mrp/data/mrp_data.xml +++ b/addons/mrp/data/mrp_data.xml @@ -82,5 +82,22 @@ <field name="manual" eval="False"/> <field name="sequence">0</field> </record> + + <function model="ir.model.data" name="create"> + <value model="stock.warehouse" eval="{ + 'name': 'picking_type_manufacturing', + 'module':'mrp', + 'model': 'stock.picking.type', + 'res_id': obj().env.ref('stock.warehouse0').manu_type_id.id, + }"/> + </function> + + <!-- avoid the xml id and the associated resource being dropped by the orm by manually making a hit on it --> + <function model="ir.model.data" name="_update_dummy"> + <value>stock.picking.type</value> + <value>mrp</value> + <value>picking_type_manufacturing</value> + </function> </data> + </odoo> diff --git a/addons/mrp/data/mrp_data.yml b/addons/mrp/data/mrp_data.yml deleted file mode 100644 index cc69bbe175b7ca0c47a912e33b1359242154ff2f..0000000000000000000000000000000000000000 --- a/addons/mrp/data/mrp_data.yml +++ /dev/null @@ -1,13 +0,0 @@ -- - !python {model: ir.model.data, id: False}: | - warehouse = self.env['stock.warehouse'].browse(ref('stock.warehouse0')) - #create xml ids for demo data that are widely used in tests or in other codes, for more convenience - xml_references = [ - {'name':'picking_type_manufacturing','module':'mrp', 'model':'stock.picking.type','res_id': warehouse.manu_type_id.id}, - ] - for xml_record in xml_references: - xml_ids = self.search([('module', '=', xml_record['module']), ('model', '=', xml_record['model']), ('name', '=', xml_record['name'])]).ids - if not xml_ids: - self.create(xml_record) - #avoid the xml id and the associated resource being dropped by the orm by manually making a hit on it - self._update_dummy(xml_record['model'], xml_record['module'], xml_record['name']) \ No newline at end of file diff --git a/addons/mrp/data/mrp_demo.xml b/addons/mrp/data/mrp_demo.xml index b15716264b4a61beff24fe828f6c3305c25f7ce1..fcfd0748d4d6057fce9dc219c5dce69bb60e6678 100644 --- a/addons/mrp/data/mrp_demo.xml +++ b/addons/mrp/data/mrp_demo.xml @@ -588,7 +588,31 @@ <field name="date_start" eval="(datetime.now() - timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')"/> </record> - + <function model="mrp.production" name="action_assign"> + <value eval="[ref('mrp.mrp_production_laptop_cust')]"/> + </function> + + <function model="mrp.product.produce" name="create"> + <value model="mrp.product.produce" eval="dict( + obj().with_context(active_id=ref('mrp.mrp_production_laptop_cust')).default_get(list(obj().fields_get())), + **{ + 'product_qty': obj().env.ref('mrp.mrp_production_laptop_cust').product_qty, + 'lot_id': ref('mrp.lot_product_27_0'), + } + )"/> + </function> + + <function model="mrp.product.produce" name="do_produce"> + <value model="mrp.product.produce" search="[('production_id', '=', obj().env.ref('mrp.mrp_production_laptop_cust').id)]"/> + </function> + + <function model="mrp.production" name="post_inventory"> + <value eval="[ref('mrp.mrp_production_laptop_cust')]"/> + </function> + + <function model="mrp.production" name="button_mark_done"> + <value eval="[ref('mrp.mrp_production_laptop_cust')]"/> + </function> </data> </odoo> diff --git a/addons/mrp/data/mrp_lot_demo.yml b/addons/mrp/data/mrp_lot_demo.yml deleted file mode 100644 index bb0c54e238ed9ae6a656f821bbb409b8c68b6b0c..0000000000000000000000000000000000000000 --- a/addons/mrp/data/mrp_lot_demo.yml +++ /dev/null @@ -1,12 +0,0 @@ -- - !python {model: mrp.production, id: mrp_production_laptop_cust}: | - if self.state != 'done': - self.action_assign() - wiz_obj = self.env['mrp.product.produce'] - ctx = dict(self.env.context, active_id=self.id) - produce_wiz = wiz_obj.with_context(ctx).create({'product_qty': self.product_qty, 'lot_id': ref('lot_product_27_0')}) - produce_wiz.produce_line_ids.write({'qty_done': produce_wiz.product_qty}) - #Produce Product,Post Inventory and Set MO Done. - produce_wiz.do_produce() - self.post_inventory() - self.button_mark_done()