diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index abf0f823e5c..59081718f5d 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -952,6 +952,7 @@ + diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 795ac5453fb..19f8a48b6fe 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', 'Manufacturing Order'), } def check_produce_product(self, cr, uid, procurement, context=None): @@ -95,16 +96,22 @@ 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 = _("Manufacturing Order 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 5d81bcbb9ba..c6a1c0c3e02 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -362,11 +362,10 @@ class procurement_order(osv.osv): """ Changes procurement state to Running and writes message. @return: True """ - message = _('From stock: products assigned.') + message = _('Products reserved from stock.') 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): @@ -390,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.") @@ -407,7 +404,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 +465,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 +498,6 @@ class procurement_order(osv.osv): def confirm_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Procurement confirmed."), context=context) - def running_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement set to running."), context=context) - - def ready_send_note(self, cr, uid, ids, context=None): - self.message_post(cr, uid, ids, body=_("Procurement set to ready."), context=context) - def cancel_send_note(self, cr, uid, ids, context=None): self.message_post(cr, uid, ids, body=_("Procurement cancelled."), context=context) diff --git a/addons/project_mrp/project_procurement.py b/addons/project_mrp/project_procurement.py index ae5e1ccbf15..6948f54ec09 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" @@ -83,10 +84,15 @@ 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.running_send_note(cr, uid, ids, context=None) + self.write(cr, uid, [procurement.id], {'task_id': task_id, 'state': 'running', 'message':_('Task 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 = _("Task created") + self.message_post(cr, uid, [procurement.id], 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 c0516d09de3..cb4235f9edf 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1084,9 +1084,14 @@ 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.purchase_order_create_note(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 = _("Draft Purchase Order created") + self.message_post(cr, uid, [procurement.id], body=body, context=context) + procurement_order() class mail_mail(osv.osv): diff --git a/addons/stock_location/procurement_pull.py b/addons/stock_location/procurement_pull.py index 840e6c854c7..419118cda96 100644 --- a/addons/stock_location/procurement_pull.py +++ b/addons/stock_location/procurement_pull.py @@ -115,9 +115,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.') + 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