From 0f534670ea04d1f785b0155010a0d229e434e7fc Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Wed, 3 Oct 2012 13:27:30 +0530 Subject: [PATCH 1/6] [IMP] open chatter messages on the procurement. bzr revid: tta@openerp.com-20121003075730-hkwuqmpkriswphgh --- addons/mrp/procurement.py | 12 ++++++++++-- addons/procurement/procurement.py | 9 --------- addons/project_mrp/project_procurement.py | 11 +++++++++-- addons/purchase/purchase.py | 8 +++++++- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 7f417dc18b1..40da3ab4425 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -31,6 +31,7 @@ class procurement_order(osv.osv): _columns = { 'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True), 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'), + 'production_id': fields.many2one('mrp.production', 'Manufucture Order'), } def check_produce_product(self, cr, uid, procurement, context=[]): @@ -95,16 +96,23 @@ class procurement_order(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'}) - self.running_send_note(cr, uid, ids, context=context) + self.write(cr, uid, [procurement.id], {'state': 'running', 'production_id': produce_id}) + bom_result = production_obj.action_compute(cr, uid, [produce_id], properties=[x.id for x in procurement.property_ids]) wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr) if res_id: move_obj.write(cr, uid, [res_id], {'location_id': procurement.location_id.id}) + self.production_order_create_note(cr, uid, ids, context=context) return res + + def production_order_create_note(self, cr, uid, ids, context=None): + for procurement in self.browse(cr, uid, ids, context=context): + body = "%s %s %s" % (_("Manufacturing Order"), procurement.production_id.name, _("Created")) + self.message_post(cr, uid, ids, body=body, context=context) procurement_order() diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index c9b09761ed0..d47c3fe350f 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -366,7 +366,6 @@ class procurement_order(osv.osv): self.write(cr, uid, ids, {'state': 'running', 'message': message}, context=context) self.message_post(cr, uid, ids, body=message, context=context) - self.running_send_note(cr, uid, ids, context=context) return True def _check_make_to_stock_service(self, cr, uid, procurement, context=None): @@ -407,7 +406,6 @@ class procurement_order(osv.osv): """ for procurement in self.browse(cr, uid, ids, context=context): self.write(cr, uid, [procurement.id], {'state': 'running'}) - self.running_send_note(cr, uid, ids, context=None) return True def action_produce_assign_product(self, cr, uid, ids, context=None): @@ -469,7 +467,6 @@ class procurement_order(osv.osv): @return: True """ res = self.write(cr, uid, ids, {'state': 'ready'}) - self.ready_send_note(cr, uid, ids, context=None) return res def action_done(self, cr, uid, ids): @@ -503,12 +500,6 @@ class procurement_order(osv.osv): def confirm_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Procurement has been confirmed."), context=context) - def running_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to running."), context=context) - - def ready_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement has been set to ready."), context=context) - def cancel_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Procurement has been cancelled."), context=context) diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index 1c347c8ae02..f70d43426b9 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -20,6 +20,7 @@ ############################################################################## from osv import fields, osv +from tools.translate import _ class procurement_order(osv.osv): _name = "procurement.order" @@ -82,11 +83,17 @@ class procurement_order(osv.osv): 'description': procurement.note, 'project_id': project and project.id or False, 'company_id': procurement.company_id.id, - },context=context) + },context=context) self.write(cr, uid, [procurement.id], {'task_id': task_id, 'state': 'running', 'message':'from project: task created.'}, context=context) - self.running_send_note(cr, uid, ids, context=None) + self.document_send_note(cr, uid, [procurement.id], body='%s %s:%s %s' % (_("Task"), procurement.origin or '', procurement.product_id.name, _("created")), context=context) + self.project_task_create_note(cr, uid, ids, context=context) return task_id + def project_task_create_note(self, cr, uid, ids, context=None): + for procurement in self.browse(cr, uid, ids, context=context): + body = "%s %s %s" % (_("Task"), procurement.task_id.name, _("Created")) + self.message_post(cr, uid, ids, body=body, context=context) + procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 8502fd7ee3f..ed99b9f2a58 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1082,9 +1082,15 @@ class procurement_order(osv.osv): } res[procurement.id] = self.create_procurement_purchase_order(cr, uid, procurement, po_vals, line_vals, context=new_context) self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': res[procurement.id]}) - self.running_send_note(cr, uid, [procurement.id], context=context) + self.document_send_note(cr, uid, [procurement.id], body='%s %s %s' % (_("Draft Purchase Order"), name or '', _("created")), context=context) + self.purchase_order_create_note(self, cr, uid, ids, context=context) return res + def purchase_order_create_note(self, cr, uid, ids, context=None): + for procurement in self.browse(cr, uid, ids, context=context): + body = "%s %s %s" % (_("Draft Purchase Order"), procurement.purchase_id.name, _("Created")) + self.message_post(cr, uid, ids, body=body, context=context) + procurement_order() class mail_mail(osv.osv): From 9c2ca851e23d5f93b59668e633618a6c3cd9f678 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Wed, 3 Oct 2012 15:13:41 +0530 Subject: [PATCH 2/6] [IMP] procurement: Products reserverd from stock & added Manufucture Order in procurement. bzr revid: tta@openerp.com-20121003094341-suosaw2sum3grn7k --- addons/mrp/mrp_view.xml | 1 + addons/procurement/procurement.py | 2 +- addons/project_mrp/project_procurement.py | 3 +-- addons/purchase/purchase.py | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index a198d736bbc..7294ad043b0 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -954,6 +954,7 @@ + diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index d47c3fe350f..ab644dd08db 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -362,7 +362,7 @@ class procurement_order(osv.osv): """ Changes procurement state to Running and writes message. @return: True """ - message = _('From stock: products assigned.') + message = _('Products reserverd from stock.') self.write(cr, uid, ids, {'state': 'running', 'message': message}, context=context) self.message_post(cr, uid, ids, body=message, context=context) diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index f70d43426b9..5f9a94f1894 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -84,8 +84,7 @@ class procurement_order(osv.osv): 'project_id': project and project.id or False, 'company_id': procurement.company_id.id, },context=context) - self.write(cr, uid, [procurement.id], {'task_id': task_id, 'state': 'running', 'message':'from project: task created.'}, context=context) - self.document_send_note(cr, uid, [procurement.id], body='%s %s:%s %s' % (_("Task"), procurement.origin or '', procurement.product_id.name, _("created")), context=context) + self.write(cr, uid, [procurement.id], {'task_id': task_id, 'state': 'running', 'message':'from project: task created.'}, context=context) self.project_task_create_note(cr, uid, ids, context=context) return task_id diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index ed99b9f2a58..4dda418c2ad 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1082,8 +1082,7 @@ class procurement_order(osv.osv): } res[procurement.id] = self.create_procurement_purchase_order(cr, uid, procurement, po_vals, line_vals, context=new_context) self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': res[procurement.id]}) - self.document_send_note(cr, uid, [procurement.id], body='%s %s %s' % (_("Draft Purchase Order"), name or '', _("created")), context=context) - self.purchase_order_create_note(self, cr, uid, ids, context=context) + self.purchase_order_create_note(cr, uid, ids, context=context) return res def purchase_order_create_note(self, cr, uid, ids, context=None): From dd44dab68c94cf88b2d9e16e614741680483d508 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 3 Oct 2012 17:08:10 +0530 Subject: [PATCH 3/6] [FIX] small issues bzr revid: hmo@tinyerp.com-20121003113810-mnlg6rf50xi2ljnt --- addons/mrp/procurement.py | 8 +++++--- addons/procurement/procurement.py | 2 +- addons/project_mrp/project_procurement.py | 6 ++++-- addons/purchase/purchase.py | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index f718856fbf8..82390a2f2c1 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -31,7 +31,7 @@ class procurement_order(osv.osv): _columns = { 'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True), 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'), - 'production_id': fields.many2one('mrp.production', 'Manufucture Order'), + 'production_id': fields.many2one('mrp.production', 'Manufacturing Order'), } def check_produce_product(self, cr, uid, procurement, context=None): @@ -80,8 +80,10 @@ class procurement_order(osv.osv): procurement_obj = self.pool.get('procurement.order') for procurement in procurement_obj.browse(cr, uid, ids, context=context): res_id = procurement.move_id.id + #TOFIX: split into new function to compute manufacturing lead time newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0) newdate = newdate - relativedelta(days=company.manufacturing_lead) + #TOFIX: implement hook method for creating production order produce_id = production_obj.create(cr, uid, { 'origin': procurement.origin, 'product_id': procurement.product_id.id, @@ -111,8 +113,8 @@ class procurement_order(osv.osv): def production_order_create_note(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): - body = "%s %s %s" % (_("Manufacturing Order"), procurement.production_id.name, _("Created")) - self.message_post(cr, uid, ids, body=body, context=context) + body = "%s %s %s" % (_("Manufacturing Order"), procurement.production_id.name, _("Created")) + self.message_post(cr, uid, [procurement.id], body=body, context=context) procurement_order() diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index aa3b2a2a673..5f8cd3c0b56 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -104,7 +104,7 @@ class procurement_order(osv.osv): " a make to order method."), 'note': fields.text('Note'), - 'message': fields.char('Latest error', size=124, help="Exception occurred while computing procurement orders."), + 'message': fields.char('Latest error', size=124, help="Exception occurred while computing procurement orders."), #TOCHECK: is it need after OpenChatter ? 'state': fields.selection([ ('draft','Draft'), ('cancel','Cancelled'), diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index 1daf03dfd9f..63e72493e35 100644 --- a/addons/project_mrp/project_procurement.py +++ b/addons/project_mrp/project_procurement.py @@ -69,8 +69,10 @@ class procurement_order(osv.osv): def action_produce_assign_service(self, cr, uid, ids, context=None): project_task = self.pool.get('project.task') for procurement in self.browse(cr, uid, ids, context=context): + #TOFIX: split into new function to compute task planning hours project = self._get_project(cr, uid, procurement, context=context) planned_hours = self._convert_qty_company_hours(cr, uid, procurement, context=context) + #TOFIX: implement hook method for creating Task task_id = project_task.create(cr, uid, { 'name': '%s:%s' % (procurement.origin or '', procurement.product_id.name), 'date_deadline': procurement.date_planned, @@ -90,8 +92,8 @@ class procurement_order(osv.osv): def project_task_create_note(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): - body = "%s %s %s" % (_("Task"), procurement.task_id.name, _("Created")) - self.message_post(cr, uid, ids, body=body, context=context) + body = "%s %s %s" % (_("Task"), procurement.task_id.name, _("Created")) + self.message_post(cr, uid, [procurement.id], body=body, context=context) procurement_order() diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index a574d8e4467..6bc76f14f34 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1083,8 +1083,8 @@ class procurement_order(osv.osv): def purchase_order_create_note(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): - body = "%s %s %s" % (_("Draft Purchase Order"), procurement.purchase_id.name, _("Created")) - self.message_post(cr, uid, ids, body=body, context=context) + body = "%s %s %s" % (_("Draft Purchase Order"), procurement.purchase_id.name, _("Created")) + self.message_post(cr, uid, [procurement.id], body=body, context=context) procurement_order() From 71bf16d126e2719fe9fd4da12e09d3e75be785b8 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 3 Oct 2012 17:49:04 +0530 Subject: [PATCH 4/6] [FIX] stock_location: fix issue to post message after created pulled procurement bzr revid: hmo@tinyerp.com-20121003121904-x930vx8rs0y80xre --- addons/stock_location/procurement_pull.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/stock_location/procurement_pull.py b/addons/stock_location/procurement_pull.py index 840e6c854c7..87af0c7e08d 100644 --- a/addons/stock_location/procurement_pull.py +++ b/addons/stock_location/procurement_pull.py @@ -57,6 +57,7 @@ class procurement_order(osv.osv): break assert line, 'Line cannot be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name + #TOFIX: implement hook method for creating picking picking_id = picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, @@ -67,6 +68,7 @@ class procurement_order(osv.osv): 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s (#%d)') % (proc.location_id.name, line.name, proc.name, proc.id), 'invoice_state': line.invoice_state, }) + #TOFIX: implement hook method for creating move move_id = move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, @@ -92,6 +94,8 @@ class procurement_order(osv.osv): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) + + #TOFIX: implement hook method for creating new procurement proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, @@ -115,9 +119,9 @@ class procurement_order(osv.osv): if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) - self.write(cr, uid, [proc.id], {'state':'running', 'message':_('Pulled from another location via procurement %d') % proc_id}) - self.running_send_note(cr, uid, [proc.id], context=context) - + msg = _('Pulled from another location via procurement %d') % proc_id + self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) + self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) return False From d69f71a1ae0b195fe4e5837459f058c8fa3c2f88 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 4 Oct 2012 18:00:06 +0530 Subject: [PATCH 5/6] [FIX] procurement: if enough stock and no defined orderpoint, should not raise procurement exception. bzr revid: hmo@tinyerp.com-20121004123006-1txskppuycj1wkiw --- addons/procurement/procurement.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 5f8cd3c0b56..c4e5dd36015 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -104,7 +104,7 @@ class procurement_order(osv.osv): " a make to order method."), 'note': fields.text('Note'), - 'message': fields.char('Latest error', size=124, help="Exception occurred while computing procurement orders."), #TOCHECK: is it need after OpenChatter ? + 'message': fields.char('Latest error', size=124, help="Exception occurred while computing procurement orders.") 'state': fields.selection([ ('draft','Draft'), ('cancel','Cancelled'), @@ -389,8 +389,6 @@ class procurement_order(osv.osv): order_point_id = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id', '=', procurement.product_id.id)], context=context) if not order_point_id and not ok: message = _("Not enough stock and no minimum orderpoint rule defined.") - elif not order_point_id: - message = _("No minimum orderpoint rule defined.") elif not ok: message = _("Not enough stock.") From 805fd62cdc25a217092f06e5ea36a13d9d791eba Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 4 Oct 2012 18:16:25 +0530 Subject: [PATCH 6/6] [FIX] procurement: fix bzr revid: hmo@tinyerp.com-20121004124625-gzi2yt49j6i7uala --- addons/procurement/procurement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index c4e5dd36015..e4ed0d5dfaa 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -104,7 +104,7 @@ class procurement_order(osv.osv): " a make to order method."), 'note': fields.text('Note'), - 'message': fields.char('Latest error', size=124, help="Exception occurred while computing procurement orders.") + 'message': fields.char('Latest error', size=124, help="Exception occurred while computing procurement orders."), 'state': fields.selection([ ('draft','Draft'), ('cancel','Cancelled'),