From 364dc33df33b00a3c783a43588fc8074aa39a284 Mon Sep 17 00:00:00 2001 From: ced <> Date: Mon, 7 Jan 2008 15:14:57 +0000 Subject: [PATCH] Now UOS (Secondary unit!) works in mrp - actually fill the new fields - add all missing fields from commit 8085 (development without testing?) bzr revid: ced-73cbdbd6a6211534d452b79a17f28c5a79794f62 --- addons/mrp/mrp.py | 26 ++++++++++++++++++-------- addons/mrp/mrp_view.xml | 20 ++++++++++++++++---- addons/sale/sale.py | 3 +++ 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 3b5304848ae..c982937fb12 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -236,6 +236,8 @@ class mrp_bom(osv.osv): 'product_id': bom.product_id.id, 'product_qty': bom.product_qty * factor, 'product_uom': bom.product_uom.id, + 'product_uos_qty': bom.product_uos and bom.product_uos_qty * factor or False, + 'product_uos': bom.product_uos and bom.product_uos.id or False, }) if bom.routing_id: for wc_use in bom.routing_id.workcenter_lines: @@ -308,7 +310,9 @@ class mrp_production(osv.osv): 'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type','<>','service')]), 'product_qty': fields.float('Product Qty', required=True), - 'product_uom': fields.many2one('product.uom', 'Product UOM'), + 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), + 'product_uos_qty': fields.float('Product Qty'), + 'product_uos': fields.many2one('product.uom', 'Product UOM'), 'location_src_id': fields.many2one('stock.location', 'Production Location', required=True), 'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True), @@ -494,23 +498,21 @@ class mrp_production(osv.osv): res = False return res + def _get_auto_picking(self, cr, uid, production): + return True + def action_confirm(self, cr, uid, ids): picking_id=False for production in self.browse(cr, uid, ids): if not production.product_lines: self.action_compute(cr, uid, [production.id]) production = self.browse(cr, uid, [production.id])[0] - autopick = True - try: - autopick = production.product_id.auto_picking - except: - pass picking_id = self.pool.get('stock.picking').create(cr, uid, { 'origin': (production.origin or '').split(':')[0] +':'+production.name, 'type': 'internal', 'move_type': 'one', 'state': 'auto', - 'auto_picking': autopick, + 'auto_picking': self._get_auto_picking(cr, uid, production), }) toconfirm = True @@ -571,9 +573,11 @@ class mrp_production(osv.osv): 'product_id': line.product_id.id, 'product_qty': line.product_qty, 'product_uom': line.product_uom.id, + 'product_uos_qty': line.product_uos and line.product_qty or False, + 'product_uos': line.product_uos and line.product_uos.id or False, 'location_id': production.location_src_id.id, 'procure_method': line.product_id.procure_method, - 'move_id': move_id, + 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) @@ -627,6 +631,8 @@ class mrp_production_product_line(osv.osv): 'product_id': fields.many2one('product.product', 'Product', required=True), 'product_qty': fields.float('Product Qty', required=True), 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), + 'product_uos_qty': fields.float('Product UOS Qty'), + 'product_uos': fields.many2one('product.uom', 'Product UOS'), 'production_id': fields.many2one('mrp.production', 'Production Order', select=True), } mrp_production_product_line() @@ -650,6 +656,8 @@ class mrp_procurement(osv.osv): 'product_id': fields.many2one('product.product', 'Product', required=True), 'product_qty': fields.float('Quantity', required=True), 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), + 'product_uos_qty': fields.float('Quantity'), + 'product_uos': fields.many2one('product.uom', 'Product UOM'), 'move_id': fields.many2one('stock.move', 'Reservation', ondelete='set null'), 'close_move': fields.boolean('Close Move at end', required=True), 'location_id': fields.many2one('stock.location', 'Location', required=True), @@ -846,6 +854,8 @@ class mrp_procurement(osv.osv): 'product_id': procurement.product_id.id, 'product_qty': procurement.product_qty, 'product_uom': procurement.product_uom.id, + 'product_uos_qty': procurement.product_uos and procurement.product_uos_qty or False, + 'product_uos': procurement.product_uos and procurement.product_uos.id or False, 'location_src_id': procurement.location_id.id, 'location_dest_id': procurement.location_id.id, 'date_planned': newdate, diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 08ea1b3ed85..2a2c8e0e31b 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -385,6 +385,8 @@ + + @@ -493,8 +495,10 @@ - + + + @@ -506,8 +510,10 @@ - + + + @@ -523,8 +529,10 @@
- + + + @@ -535,8 +543,10 @@ - + + + @@ -578,6 +588,8 @@ + + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 097e4873fda..1c0e5965969 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -467,6 +467,9 @@ class sale_order(osv.osv): 'product_id': line.product_id.id, 'product_qty': line.product_uom_qty, 'product_uom': line.product_uom.id, + 'product_uos_qty': line.product_uos_qty, + 'product_uos': (line.product_uos and line.product_uos.id)\ + or line.product_uom.id, 'location_id': order.shop_id.warehouse_id.lot_stock_id.id, 'procure_method': line.type, 'move_id': move_id,