From b7b6a7076944a65a8df9209ee40917d16d467c72 Mon Sep 17 00:00:00 2001 From: "uco (Open ERP)" Date: Wed, 1 Sep 2010 12:15:19 +0530 Subject: [PATCH 01/14] [FIX] mrp: Fixed Bug 380529: Top Level BOM with Set/Phantom type incorrect behaviour. bzr revid: uco@tinyerp.com-20100901064519-scqma00dfp5cof7o --- addons/mrp/mrp_workflow.xml | 3 +++ addons/mrp/procurement.py | 11 +++++++++++ addons/sale/sale.py | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/addons/mrp/mrp_workflow.xml b/addons/mrp/mrp_workflow.xml index 0a55ccdd610..3a8ec11b353 100644 --- a/addons/mrp/mrp_workflow.xml +++ b/addons/mrp/mrp_workflow.xml @@ -142,6 +142,9 @@ subflow.done + + not test_cancel() and not get_phantom_bom_id() + diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 6425f6e84ac..29eb2d3bddf 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -48,6 +48,17 @@ class procurement_order(osv.osv): return False return True + def get_phantom_bom_id(self, cr, uid, ids, context=None): + for procurement in self.browse(cr, uid, ids, context=context): + if procurement.move_id and procurement.move_id.product_id.supply_method=='produce' \ + and procurement.move_id.product_id.procure_method=='make_to_order': + phantom_bom_id = self.pool.get('mrp.bom').search(cr, uid, [ + ('product_id', '=', procurement.move_id.product_id.id), + ('bom_id', '=', False), + ('type', '=', 'phantom')]) + return phantom_bom_id + return False + def action_produce_assign_product(self, cr, uid, ids, context={}): """ This is action which call from workflow to assign production order to procurements @return: True diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 3fa024074dc..bf6b6cfcce5 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -694,15 +694,15 @@ class sale_order(osv.osv): self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id}) val = {} - if picking_id: - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) - for proc_id in proc_ids: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) + if picking_id: + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) + if order.state == 'shipping_except': val['state'] = 'progress' From d91be1e90825b0bcbbb78756c347ceecdb5cca4a Mon Sep 17 00:00:00 2001 From: "uco (Open ERP)" Date: Wed, 1 Sep 2010 14:43:08 +0530 Subject: [PATCH 02/14] [FIX] sale: Question:119827 : Corrected Workflow. bzr revid: uco@tinyerp.com-20100901091308-zx5m4q5388cczcvs --- addons/mrp/stock.py | 17 ----------------- addons/procurement/procurement.py | 30 ++++++++++++++++++++++++++++++ addons/sale/sale.py | 1 - 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 3e158b4d0cf..248e39989d8 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -33,14 +33,8 @@ class StockMove(osv.osv): _columns = { 'production_id': fields.many2one('mrp.production', 'Production', select=True), - 'procurements': fields.one2many('procurement.order', 'move_id', 'Procurements'), } - def copy(self, cr, uid, id, default=None, context=None): - default = default or {} - default['procurements'] = [] - return super(StockMove, self).copy(cr, uid, id, default, context) - def _action_explode(self, cr, uid, move, context={}): """ Explodes pickings. @param move: Stock moves @@ -152,17 +146,6 @@ StockMove() class StockPicking(osv.osv): _inherit = 'stock.picking' - def test_finnished(self, cursor, user, ids): - wf_service = netsvc.LocalService("workflow") - res = super(StockPicking, self).test_finnished(cursor, user, ids) - for picking in self.browse(cursor, user, ids): - for move in picking.move_lines: - if move.state == 'done' and move.procurements: - for procurement in move.procurements: - wf_service.trg_validate(user, 'procurement.order', - procurement.id, 'button_check', cursor) - return res - # # Explode picking by replacing phantom BoMs # diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 298d9b05449..e5375d6b9c1 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -60,6 +60,21 @@ class mrp_property(osv.osv): 'composition': lambda *a: 'min', } mrp_property() + +class StockMove(osv.osv): + _inherit = 'stock.move' + + _columns= { + 'procurements': fields.one2many('procurement.order', 'move_id', 'Procurements'), + } + + def copy(self, cr, uid, id, default=None, context=None): + default = default or {} + default['procurements'] = [] + return super(StockMove, self).copy(cr, uid, id, default, context) + +StockMove() + class procurement_order(osv.osv): """ Procurement Orders @@ -471,6 +486,21 @@ class procurement_order(osv.osv): procurement_order() +class StockPicking(osv.osv): + _inherit = 'stock.picking' + + def test_finnished(self, cursor, user, ids): + wf_service = netsvc.LocalService("workflow") + res = super(StockPicking, self).test_finnished(cursor, user, ids) + for picking in self.browse(cursor, user, ids): + for move in picking.move_lines: + if move.state == 'done' and move.procurements: + for procurement in move.procurements: + wf_service.trg_validate(user, 'procurement.order', + procurement.id, 'button_check', cursor) + return res + +StockPicking() class stock_warehouse_orderpoint(osv.osv): """ diff --git a/addons/sale/sale.py b/addons/sale/sale.py index bf6b6cfcce5..65abe223cad 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -697,7 +697,6 @@ class sale_order(osv.osv): for proc_id in proc_ids: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) if picking_id: wf_service = netsvc.LocalService("workflow") From f5419932bafe2a9671e6a5a8fb752c9d433d47df Mon Sep 17 00:00:00 2001 From: "uco (Open ERP)" Date: Wed, 1 Sep 2010 14:57:56 +0530 Subject: [PATCH 03/14] [REM] mrp: Removed access rule for osv_memory object. bzr revid: uco@tinyerp.com-20100901092756-p2et4cz0mpprfe1p --- addons/mrp/security/ir.model.access.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/mrp/security/ir.model.access.csv b/addons/mrp/security/ir.model.access.csv index 41cbb5554c8..79c5de9a505 100644 --- a/addons/mrp/security/ir.model.access.csv +++ b/addons/mrp/security/ir.model.access.csv @@ -87,7 +87,6 @@ "access_mrp_production_system","mrp.production system","model_mrp_production","base.group_system",1,0,0,0 "access_stock_production_lot_user","stock.production.lot","stock.model_stock_production_lot","mrp.group_mrp_user",1,1,1,1 "access_stock_warehouse_orderpoint_manager","stock.warehouse.orderpoint","procurement.model_stock_warehouse_orderpoint","mrp.group_mrp_manager",1,0,0,0 -"access_procurement_order_compute_all_user","procurement.order.compute.all.user","procurement.model_procurement_order_compute_all","mrp.group_mrp_user",1,0,0,0 "access_stock_picking_mrp_manager","stock.picking mrp_manager","stock.model_stock_picking","mrp.group_mrp_manager",1,1,1,1 "access_report_mrp_inout_user","report.mrp.inout user","model_report_mrp_inout","mrp.group_mrp_user",1,0,0,0 "access_report_workcenter_load_user","report.workcenter.load.user","model_report_workcenter_load","mrp.group_mrp_user",1,0,0,0 From 3db8f8fd6d203d2f48488eabc547a6500b8fb776 Mon Sep 17 00:00:00 2001 From: "uco (Open ERP)" Date: Fri, 3 Sep 2010 15:17:11 +0530 Subject: [PATCH 04/14] [IMP] mrp: Improved yaml. bzr revid: uco@tinyerp.com-20100903094711-rvmbd333mavm8muq --- addons/mrp/__openerp__.py | 3 +- addons/mrp/test/mrp_packs.yml | 11 ++++++- addons/mrp/test/mrp_phantom_bom.yml | 37 +++++++++++++++++++++--- addons/mrp/test/mrp_procurement.yml | 4 +-- addons/mrp/test/mrp_production_order.yml | 4 ++- 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/addons/mrp/__openerp__.py b/addons/mrp/__openerp__.py index cdc5dd6b5ac..f8630065598 100644 --- a/addons/mrp/__openerp__.py +++ b/addons/mrp/__openerp__.py @@ -88,10 +88,11 @@ 'board_manufacturing_demo.xml' ], 'test': [ + 'test/mrp_procurement.yml', 'test/mrp_packs.yml', 'test/mrp_phantom_bom.yml', 'test/mrp_production_order.yml', - 'test/mrp_procurement.yml' + ], 'installable': True, 'active': False, diff --git a/addons/mrp/test/mrp_packs.yml b/addons/mrp/test/mrp_packs.yml index 6b3fbd08fba..76e3eb58f2c 100644 --- a/addons/mrp/test/mrp_packs.yml +++ b/addons/mrp/test/mrp_packs.yml @@ -8,6 +8,10 @@ categ_id: product.cat1 name: Beers procure_method: make_to_stock + seller_ids: + - delay: 1 + name: base.res_partner_agrolait + min_qty: 2.0 supply_method: buy type: product uom_id: product.product_uom_unit @@ -19,6 +23,10 @@ categ_id: product.cat1 name: Beers Pack procure_method: make_to_stock + seller_ids: + - delay: 1 + name: base.res_partner_asus + min_qty: 2.0 supply_method: buy type: product uom_id: product.product_uom_unit @@ -87,8 +95,9 @@ converted to a picking of 24 beers and a pack of beer, so that my stock of beers remains exact. - - !assert {model: stock.picking, id: picking_out, string:pack_of_beer_splitted}: + !assert {model: stock.picking, id: picking_out, string: pack_of_beer_splitted}: - len(move_lines) == 2 - move_lines[0].product_id.id <> move_lines[1].product_id.id - move_lines[0].product_id.id in (ref('product_product_beers0'), ref('product_product_beerspack0')) - move_lines[1].product_id.id in (ref('product_product_beers0'), ref('product_product_beerspack0')) + diff --git a/addons/mrp/test/mrp_phantom_bom.yml b/addons/mrp/test/mrp_phantom_bom.yml index 1cb7aa9b631..05b5984dbee 100644 --- a/addons/mrp/test/mrp_phantom_bom.yml +++ b/addons/mrp/test/mrp_phantom_bom.yml @@ -67,7 +67,11 @@ !record {model: product.product, id: product_product_water0}: categ_id: product.cat1 name: Water - procure_method: make_to_stock + procure_method: make_to_order + seller_ids: + - delay: 1 + name: base.res_partner_agrolait + min_qty: 2.0 supply_method: buy type: consu uom_id: product_uom_litre0 @@ -196,7 +200,7 @@ - !python {model: procurement.order}: | from tools.translate import _ - proc_ids = self.search(cr, uid, [('state','!=','confirmed')]) + proc_ids = self.search(cr, uid, [('state','=','confirmed')]) assert proc_ids, _('No Procurements!') - The scheduler runs. @@ -256,7 +260,7 @@ - !python {model: stock.partial.picking}: | pick_obj = self.pool.get('stock.picking') - picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')]) + picking_ids = pick_obj.search(cr, uid, [('type','=','in'),('state','=','assigned')]) partial = self.browse(cr, uid, 1, context) partial_datas = { 'delivery_date': partial.date @@ -274,4 +278,29 @@ 'product_currency': m.product_currency }) pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context) - +- + Again the scheduler runs. +- + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order + search: "[('state','!=','confirmed')]" +- + I check my internal picking of "Orange Juice" is done. +- + !python {model: stock.picking}: | + from tools.translate import _ + pick_ids = self.search(cr, uid, [('type','=','internal'),('state','=','done')]) + assert pick_ids, _('Internal Picking is not done yet!') +- + I check my manufacturing order for "Orange Juice" is ready or not. +- + !python {model: mrp.production}: | + from tools.translate import _ + pick_ids = self.search(cr, uid, [('state','=','ready'),('id','=',ref('mrp_production_mo0'))]) + assert pick_ids, _('Manufacturing order is not ready!') +- + I start the production order. +- + !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo0} + + \ No newline at end of file diff --git a/addons/mrp/test/mrp_procurement.yml b/addons/mrp/test/mrp_procurement.yml index 5ce256ab7d9..f85b8cbcee3 100644 --- a/addons/mrp/test/mrp_procurement.yml +++ b/addons/mrp/test/mrp_procurement.yml @@ -162,7 +162,7 @@ - !function {model: procurement.order, name: run_scheduler}: - model: procurement.order - search: "[]" + search: "[('state','=','confirmed')]" - I check that there is one purchase order for Cloth. - @@ -286,7 +286,7 @@ - !function {model: procurement.order, name: run_scheduler}: - model: procurement.order - search: "[]" + search: "[('state','!=','confirmed')]" - Check state of manufacturing order for Shirt. - diff --git a/addons/mrp/test/mrp_production_order.yml b/addons/mrp/test/mrp_production_order.yml index 0ceebfab107..476d79f7fab 100644 --- a/addons/mrp/test/mrp_production_order.yml +++ b/addons/mrp/test/mrp_production_order.yml @@ -86,7 +86,7 @@ - !python {model: procurement.order}: | from tools.translate import _ - proc_ids = self.search(cr, uid, [('state','!=','confirmed')]) + proc_ids = self.search(cr, uid, [('state','=','confirmed')]) assert proc_ids, _('No Procurements!') - The scheduler runs. @@ -110,6 +110,8 @@ assert order_ids, _('No manufacturing order!') - I start producing that product first. So I marked it as started. +- + !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo0} - I create record for producing products with quantity 5.00. - From 30a7baee0ae3913b098664c6788f18e88655ebab Mon Sep 17 00:00:00 2001 From: "uco (Open ERP)" Date: Fri, 3 Sep 2010 15:18:32 +0530 Subject: [PATCH 05/14] [IMP] mrp: Load demo data without running Schedulers manually. bzr revid: uco@tinyerp.com-20100903094832-19vlmiyibjpzi7xj --- addons/mrp/mrp_demo.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index fa54dc0096f..f454a8d14a8 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -713,6 +713,9 @@ 12.0 + + + From a3fe51e16438f274571478626fde433053fa4735 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Fri, 3 Sep 2010 12:14:55 +0100 Subject: [PATCH 06/14] Make 'Maximum Communication History' actually be a maximum. bzr revid: daniel.watkins@credativ.co.uk-20100903111455-52oi01hlfj0wewzg --- addons/crm/crm_action_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_action_rule.py b/addons/crm/crm_action_rule.py index 1ca37a426a2..6805131155a 100644 --- a/addons/crm/crm_action_rule.py +++ b/addons/crm/crm_action_rule.py @@ -96,7 +96,7 @@ this if you want the rule to send an email to the partner."), res_count = True if action.trg_max_history: res_count = False - if len(obj.message_ids) >= action.trg_max_history: + if len(obj.message_ids) <= action.trg_max_history: res_count = True ok = ok and res_count return ok From 0cd651e4211880b493b558d8f26c0b335b55bfbf Mon Sep 17 00:00:00 2001 From: "uco (Open ERP)" Date: Fri, 3 Sep 2010 16:54:47 +0530 Subject: [PATCH 07/14] [IMP] mrp: Production Lot field should not be readonly. Improved alignment. bzr revid: uco@tinyerp.com-20100903112447-ns238b37z3om6ryk --- addons/mrp/mrp.py | 4 ++-- addons/mrp/mrp_view.xml | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index fd9f8335987..fad20da2589 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -459,9 +459,9 @@ class mrp_production(osv.osv): help="This is the internal picking list that brings the finished product to the production plan"), 'move_prod_id': fields.many2one('stock.move', 'Move product', readonly=True), 'move_lines': many2many_domain('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Products to Consume', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}), - 'move_lines2': many2many_domain('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products', domain=[('state','in', ('done', 'cancel'))], readonly=True), + 'move_lines2': many2many_domain('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Consumed Products', domain=[('state','in', ('done', 'cancel'))]), 'move_created_ids': one2many_domain('stock.move', 'production_id', 'Moves Created', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}), - 'move_created_ids2': one2many_domain('stock.move', 'production_id', 'Moves Created', domain=[('state','in', ('done', 'cancel'))], readonly=True), + 'move_created_ids2': one2many_domain('stock.move', 'production_id', 'Moves Created', domain=[('state','in', ('done', 'cancel'))]), 'product_lines': fields.one2many('mrp.production.product.line', 'production_id', 'Scheduled goods'), 'workcenter_lines': fields.one2many('mrp.production.workcenter.line', 'production_id', 'Work Centers Utilisation'), 'state': fields.selection([('draft','Draft'),('picking_except', 'Picking Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Cancelled'),('done','Done')],'State', readonly=True, diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 058cc99a7b6..ec58b6627fb 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -611,11 +611,11 @@ - - - - - + + + + +