From 0f534670ea04d1f785b0155010a0d229e434e7fc Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Wed, 3 Oct 2012 13:27:30 +0530 Subject: [PATCH] [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):