From 602c38bcc28f4496f95706468234277552c8fda4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Sun, 28 Feb 2010 00:18:01 -0300 Subject: [PATCH 001/164] [REF] backward compatible refactoring introducing an extension point in inventory line to move line creation. Useful for instance for double unit management of inventory extension module. Removed TOPO comment regarding need for tracking in inventory as it seems to work like a charm bzr revid: rvalyi@gmail.com-20100228031801-171hrv4yq9anu9n9 --- addons/stock/stock.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 240bc9762ce..b6b98316805 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1585,10 +1585,12 @@ class stock_inventory(osv.osv): 'state': lambda *a: 'draft', 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c) } + + + def _inventory_line_hook(self, cr, uid, inventory_line, move_vals): + '''Creates a stock move from an inventory line''' + return self.pool.get('stock.move').create(cr, uid, move_vals) - # - # Update to support tracking - # def action_done(self, cr, uid, ids, context=None): for inv in self.browse(cr, uid, ids): move_ids = [] @@ -1628,7 +1630,7 @@ class stock_inventory(osv.osv): 'prodlot_id': lot_id, 'product_qty': line.product_qty }) - move_ids.append(self.pool.get('stock.move').create(cr, uid, value)) + move_ids.append(self._inventory_line_hook(cr, uid, line, value)) if len(move_ids): self.pool.get('stock.move').action_done(cr, uid, move_ids, context=context) From 353f7026a15571490010a804828bf6b129753e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Sun, 28 Feb 2010 00:52:50 -0300 Subject: [PATCH 002/164] [REF] [MRP] action_produce_assign_product method refactoring: several mrp.production where made and not linked to their procurement only last id was returned. -> Not possible to override cleany for instance to pass custom options from a procurement to a production order. Implemented it with the {} trick. This is debatable whether {} links or hook before creation is better. At least now you can override it... bzr revid: rvalyi@gmail.com-20100228035250-xnp9q1tx5j0sjnlr --- addons/mrp/mrp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index bea0e5f2b94..a7f4b6b739f 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1115,7 +1115,7 @@ class mrp_procurement(osv.osv): return True def action_produce_assign_product(self, cr, uid, ids, context={}): - produce_id = False + res = {} company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id for procurement in self.browse(cr, uid, ids): res_id = procurement.move_id.id @@ -1136,6 +1136,7 @@ class mrp_procurement(osv.osv): 'move_prod_id': res_id, 'company_id': procurement.company_id.id, }) + res[procurement.id] = produce_id self.write(cr, uid, [procurement.id], {'state':'running'}) bom_result = self.pool.get('mrp.production').action_compute(cr, uid, [produce_id], properties=[x.id for x in procurement.property_ids]) @@ -1143,7 +1144,7 @@ class mrp_procurement(osv.osv): wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr) self.pool.get('stock.move').write(cr, uid, [res_id], {'location_id':procurement.location_id.id}) - return produce_id + return res def action_po_assign(self, cr, uid, ids, context={}): purchase_id = False From dc1722f35d10f84c13bfce7e116302dc689dfe35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Sun, 28 Feb 2010 01:16:10 -0300 Subject: [PATCH 003/164] [REF] [MRP] action_po_assign method refactoring: several purchase.order where made and not linked to their procurement only last id was returned. -> Not possible to override cleany for instance to pass custom options from a procurement to a production order. Implemented it with the {} trick. This is debatable whether {} links or hook before creation is better. At least now you can override it... bzr revid: rvalyi@gmail.com-20100228041610-knbvwzptzgzjyq42 --- addons/mrp/mrp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index a7f4b6b739f..29300198523 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1147,7 +1147,7 @@ class mrp_procurement(osv.osv): return res def action_po_assign(self, cr, uid, ids, context={}): - purchase_id = False + res = {} company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id for procurement in self.browse(cr, uid, ids): res_id = procurement.move_id.id @@ -1199,8 +1199,9 @@ class mrp_procurement(osv.osv): 'company_id': procurement.company_id.id, 'fiscal_position': partner.property_account_position and partner.property_account_position.id or False }) + res[procurement.id] = purchase_id self.write(cr, uid, [procurement.id], {'state':'running', 'purchase_id':purchase_id}) - return purchase_id + return res def action_cancel(self, cr, uid, ids): todo = [] From 91d45aa7a112ae072ad0e9cbbe282af76235e589 Mon Sep 17 00:00:00 2001 From: mso Date: Tue, 9 Mar 2010 12:01:33 +0530 Subject: [PATCH 004/164] [IMP] stock,mrp:Changes in the way scrap products are handled.Considered as consumed product & Same products entries are created indicating that products are required for manufacturing. bzr revid: mso@mso-20100309063133-giiqvwqewlg61nm2 --- addons/mrp/mrp_view.xml | 2 +- addons/stock/stock.py | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 29e37f9532b..6041bc5163c 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -506,7 +506,7 @@ - + diff --git a/addons/stock/stock.py b/addons/stock/stock.py index a403c141be4..f1b7e34d1d5 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1309,7 +1309,40 @@ class stock_move(osv.osv): wf_service.trg_trigger(uid, 'stock.move', id, cr) #self.action_cancel(cr,uid, ids2, context) return True - + + def action_scrap(self, cr, uid, ids,context=None): + ''' + add the damaged product into consumed product by updating its state to cancel and + add same product since we need that product to manufacture the parent product. + + :param cr: the database cursor + :param uid: the user id + :param ids: ids of product object to be scraped + :param context: context arguments + :return: + ''' +# to find the parent id(manufacturing order) of the active record(product to consume), +# obtain active record id 1st and then get the production_id from mrp_production_move_ids + active_id=ids[0] + cr.execute("select production_id from mrp_production_move_ids where move_id=%s" % (active_id)) +# it gives parent id in [list(tuple)] format so extract it [(21,)] + parent_id = int(cr.fetchall()[0][0]) +# get the parent object + parent_obj = self.pool.get('mrp.production').browse(cr, uid, parent_id) +# create copy for multiple id processing for product to consume which r scraped + for id in ids: + #create copy of the product records which are scraped due to damage since they are + #still required to manufacture the product. + new_rec_id = self.copy(cr, uid, id, {'state': 'waiting'}, context) + + #assign all new products which will replace damaged product to the current manufacturing order + cr.execute('insert into mrp_production_move_ids (production_id,move_id) values (%s,%s)', (parent_id, new_rec_id)) + +# all damaged product needs to be in consumed product window having cancel state. + vals={'state': 'cancel', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')} + self.pool.get('stock.move').write(cr, uid, ids,vals ) + + return True def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] @@ -1563,7 +1596,9 @@ class stock_move(osv.osv): self.write(cr, uid, [move.id], update_val) if consume: - self.action_done(cr, uid, res) + self.action_done(cr, uid, res) + else: + self.action_scrap(cr, uid, res,context) return res def scrap_moves(self, cr, uid, ids, quantity, location_dest_id, context=None): From 2c4229fd1cf080c7520a566525f4a8394e66b691 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Tue, 9 Mar 2010 12:09:45 +0530 Subject: [PATCH 005/164] [IMP] mrp: Converted 'Requisition Request' wizard into osv_memory wizard. bzr revid: uco@tinyerp.co.in-20100309063945-9o712w12gio5mcvs --- addons/mrp/__terp__.py | 1 + addons/mrp/mrp_wizard.xml | 12 +-- addons/mrp/wizard/__init__.py | 2 +- addons/mrp/wizard/make_procurement.py | 102 ------------------ addons/mrp/wizard/make_procurement_product.py | 95 ++++++++++++++++ addons/mrp/wizard/make_procurement_view.xml | 51 +++++++++ 6 files changed, 154 insertions(+), 109 deletions(-) delete mode 100644 addons/mrp/wizard/make_procurement.py create mode 100644 addons/mrp/wizard/make_procurement_product.py create mode 100644 addons/mrp/wizard/make_procurement_view.xml diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py index a147266ce1d..9f5bc664be7 100644 --- a/addons/mrp/__terp__.py +++ b/addons/mrp/__terp__.py @@ -62,6 +62,7 @@ 'mrp_data.xml', 'mrp_wizard_view.xml', 'mrp_view.xml', + 'wizard/make_procurement_view.xml', 'mrp_wizard.xml', 'mrp_report.xml', 'company_view.xml', diff --git a/addons/mrp/mrp_wizard.xml b/addons/mrp/mrp_wizard.xml index 74001494c77..e1823092989 100644 --- a/addons/mrp/mrp_wizard.xml +++ b/addons/mrp/mrp_wizard.xml @@ -24,12 +24,12 @@ - + + + + + + diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py index 240f25daa9d..a859d55b44e 100644 --- a/addons/mrp/wizard/__init__.py +++ b/addons/mrp/wizard/__init__.py @@ -26,7 +26,7 @@ import wizard_price import wizard_workcenter_load import wizard_track_prod import wizard_change_production_qty -import make_procurement +import make_procurement_product # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/wizard/make_procurement.py b/addons/mrp/wizard/make_procurement.py deleted file mode 100644 index 0cf12107181..00000000000 --- a/addons/mrp/wizard/make_procurement.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import wizard -import pooler -import netsvc - -import time - -def _get_default(obj, cr, uid, data, context=None): - pool = pooler.get_pool(cr.dbname) - product = pool.get('product.product').browse(cr, uid, data['id'], context) - return {'product_id': product.id, 'uom_id':product.uom_id.id, 'qty':1.0} - -def make_procurement(obj, cr, uid, data, context=None): - '''Create procurement''' - pool = pooler.get_pool(cr.dbname) - wh = pool.get('stock.warehouse').browse(cr, uid, data['form']['warehouse_id'], context) - user = pool.get('res.users').browse(cr, uid, uid, context) - procure_id = pool.get('mrp.procurement').create(cr, uid, { - 'name':'INT:'+str(user.login), - 'date_planned':data['form']['date_planned'], - 'product_id':data['form']['product_id'], - 'product_qty':data['form']['qty'], - 'product_uom':data['form']['uom_id'], - 'location_id':wh.lot_stock_id.id, - 'procure_method':'make_to_order', - }, context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr) - return {} - - -class MakeProcurement(wizard.interface): - '''Wizard that create a procurement from a product form''' - - done_form = """ -
-