From 67905b2dda67745599a6743227bc6eceaf5bf1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Dec 2012 18:11:46 +0100 Subject: [PATCH] [REF] Mrp_operation: added track on production_id of mpr.production.workcenter.line, removed extra chatter messages. bzr revid: tde@openerp.com-20121218171146-zudtlz4f263zbzbd --- addons/mrp/mrp.py | 3 +- addons/mrp_operations/mrp_operations.py | 67 +++---------------------- 2 files changed, 8 insertions(+), 62 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index aa8495034be..17a11c3e27e 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1051,7 +1051,8 @@ class mrp_production_workcenter_line(osv.osv): 'cycle': fields.float('Number of Cycles', digits=(16,2)), 'hour': fields.float('Number of Hours', digits=(16,2)), 'sequence': fields.integer('Sequence', required=True, help="Gives the sequence order when displaying a list of work orders."), - 'production_id': fields.many2one('mrp.production', 'Manufacturing Order', select=True, ondelete='cascade', required=True), + 'production_id': fields.many2one('mrp.production', 'Manufacturing Order', + track_visibility=1, select=True, ondelete='cascade', required=True), } _defaults = { 'sequence': lambda *a: 1, diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index bb91fb4b617..1ce60946f6c 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -160,17 +160,14 @@ class mrp_production_workcenter_line(osv.osv): """ Sets state to draft. @return: True """ - self.write(cr, uid, ids, {'state':'draft'}) - self.action_draft_send_note(cr, uid, ids, context=context) - return True + return self.write(cr, uid, ids, {'state': 'draft'}, context=context) def action_start_working(self, cr, uid, ids, context=None): """ Sets state to start working and writes starting date. @return: True """ self.modify_production_order_state(cr, uid, ids, 'start') - self.write(cr, uid, ids, {'state':'startworking', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')}) - self.action_start_send_note(cr, uid, ids, context=context) + self.write(cr, uid, ids, {'state':'startworking', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context) return True def action_done(self, cr, uid, ids, context=None): @@ -186,8 +183,7 @@ class mrp_production_workcenter_line(osv.osv): delay += (date_finished-date_start).days * 24 delay += (date_finished-date_start).seconds / float(60*60) - self.write(cr, uid, ids, {'state':'done', 'date_finished': date_now,'delay':delay}) - self.action_done_send_note(cr, uid, ids, context=context) + self.write(cr, uid, ids, {'state':'done', 'date_finished': date_now,'delay':delay}, context=context) self.modify_production_order_state(cr,uid,ids,'done') return True @@ -195,71 +191,20 @@ class mrp_production_workcenter_line(osv.osv): """ Sets state to cancel. @return: True """ - self.write(cr, uid, ids, {'state':'cancel'}) - self.action_cancel_send_note(cr, uid, ids, context=context) - return True + return self.write(cr, uid, ids, {'state':'cancel'}, context=context) def action_pause(self, cr, uid, ids, context=None): """ Sets state to pause. @return: True """ - self.write(cr, uid, ids, {'state':'pause'}) - self.action_pending_send_note(cr, uid, ids, context=context) - return True + return self.write(cr, uid, ids, {'state':'pause'}, context=context) def action_resume(self, cr, uid, ids, context=None): """ Sets state to startworking. @return: True """ - self.write(cr, uid, ids, {'state':'startworking'}) - self.action_start_send_note(cr, uid, ids, context=context) - return True + return self.write(cr, uid, ids, {'state':'startworking'}, context=context) - # ------------------------------------------------------- - # OpenChatter methods and notifications - # ------------------------------------------------------- - - def action_draft_send_note(self, cr, uid, ids, context=None): - prod_obj = self.pool.get('mrp.production') - for workorder in self.browse(cr, uid, ids): - for prod in prod_obj.browse(cr, uid, [workorder.production_id]): - message = _("Work order has been created for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) - return True - - def action_start_send_note(self, cr, uid, ids, context=None): - prod_obj = self.pool.get('mrp.production') - for workorder in self.browse(cr, uid, ids): - for prod in prod_obj.browse(cr, uid, [workorder.production_id]): - message = _("Work order has been started for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) - return True - - def action_done_send_note(self, cr, uid, ids, context=None): - prod_obj = self.pool.get('mrp.production') - for workorder in self.browse(cr, uid, ids): - for prod in prod_obj.browse(cr, uid, [workorder.production_id]): - message = _("Work order has been done for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) - return True - - def action_pending_send_note(self, cr, uid, ids, context=None): - prod_obj = self.pool.get('mrp.production') - for workorder in self.browse(cr, uid, ids): - for prod in prod_obj.browse(cr, uid, [workorder.production_id]): - message = _("Work order is pending for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) - return True - - def action_cancel_send_note(self, cr, uid, ids, context=None): - prod_obj = self.pool.get('mrp.production') - for workorder in self.browse(cr, uid, ids): - for prod in prod_obj.browse(cr, uid, [workorder.production_id]): - message = _("Work order has been cancelled for production order %s.") % (prod.id.name) - self.message_post(cr, uid, [workorder.id], body=message, context=context) - return True - -mrp_production_workcenter_line() class mrp_production(osv.osv): _inherit = 'mrp.production'