From 6bd409246d79edc471b3a69bde9428339367bec6 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 13 Feb 2013 15:00:52 +0100 Subject: [PATCH 1/2] [IMP] remove model methods _workflow_trigger and _workflow_signal, and replace calls to new workflow methods bzr revid: rco@openerp.com-20130213140052-9q6s9m3x6ye0qy35 --- addons/point_of_sale/point_of_sale.py | 2 +- addons/procurement/procurement.py | 9 +++-- addons/stock/stock.py | 52 ++++++++++++++++++--------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 4f1b97cf28b..ea7460dae21 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -364,7 +364,7 @@ class pos_session(osv.osv): ids = [ids] this_record = self.browse(cr, uid, ids[0], context=context) - this_record._workflow_signal('open') + this_record.signal_workflow('open') context.update(active_id=this_record.id) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index dba68e79bf4..5dc8daf8303 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -373,14 +373,13 @@ class procurement_order(osv.osv): self.message_post(cr, uid, [procurement.id], body=message, context=context) return ok - def _workflow_trigger(self, cr, uid, ids, trigger, context=None): - """ Don't trigger workflow for the element specified in trigger - """ - wkf_op_key = 'workflow.%s.%s' % (trigger, self._name) + def trigger_workflow(self, cr, uid, ids, context=None): + """ Don't trigger workflow for the element specified in trigger """ + wkf_op_key = 'workflow.trg_write.%s' % self._name if context and not context.get(wkf_op_key, True): # make sure we don't have a trigger loop while processing triggers return - return super(procurement_order,self)._workflow_trigger(cr, uid, ids, trigger, context=context) + return super(procurement_order, self).trigger_workflow(cr, uid, ids, context=context) def action_produce_assign_service(self, cr, uid, ids, context=None): """ Changes procurement state to Running. diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 2d351d9302e..b8a7c675b6a 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2947,15 +2947,25 @@ class stock_picking_in(osv.osv): #override in order to redirect the check of acces rules on the stock.picking object return self.pool.get('stock.picking').check_access_rule(cr, uid, ids, operation, context=context) - def _workflow_trigger(self, cr, uid, ids, trigger, context=None): - #override in order to trigger the workflow of stock.picking at the end of create, write and unlink operation - #instead of it's own workflow (which is not existing) - return self.pool.get('stock.picking')._workflow_trigger(cr, uid, ids, trigger, context=context) + def create_workflow(self, cr, uid, ids, context=None): + # overridden in order to trigger the workflow of stock.picking at the end of create, + # write and unlink operation instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').create_workflow(cr, uid, ids, context=context) - def _workflow_signal(self, cr, uid, ids, signal, context=None): - #override in order to fire the workflow signal on given stock.picking workflow instance - #instead of it's own workflow (which is not existing) - return self.pool.get('stock.picking')._workflow_signal(cr, uid, ids, signal, context=context) + def delete_workflow(self, cr, uid, ids, context=None): + # overridden in order to trigger the workflow of stock.picking at the end of create, + # write and unlink operation instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').delete_workflow(cr, uid, ids, context=context) + + def trigger_workflow(self, cr, uid, ids, context=None): + # overridden in order to trigger the workflow of stock.picking at the end of create, + # write and unlink operation instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').trigger_workflow(cr, uid, ids, context=context) + + def signal_workflow(self, cr, uid, ids, signal, context=None): + # overridden in order to fire the workflow signal on given stock.picking workflow instance + # instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').signal_workflow(cr, uid, ids, signal, context=context) _columns = { 'backorder_id': fields.many2one('stock.picking.in', 'Back Order of', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="If this shipment was split, then this field links to the shipment which contains the already processed part.", select=True), @@ -2992,15 +3002,25 @@ class stock_picking_out(osv.osv): #override in order to redirect the check of acces rules on the stock.picking object return self.pool.get('stock.picking').check_access_rule(cr, uid, ids, operation, context=context) - def _workflow_trigger(self, cr, uid, ids, trigger, context=None): - #override in order to trigger the workflow of stock.picking at the end of create, write and unlink operation - #instead of it's own workflow (which is not existing) - return self.pool.get('stock.picking')._workflow_trigger(cr, uid, ids, trigger, context=context) + def create_workflow(self, cr, uid, ids, context=None): + # overridden in order to trigger the workflow of stock.picking at the end of create, + # write and unlink operation instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').create_workflow(cr, uid, ids, context=context) - def _workflow_signal(self, cr, uid, ids, signal, context=None): - #override in order to fire the workflow signal on given stock.picking workflow instance - #instead of it's own workflow (which is not existing) - return self.pool.get('stock.picking')._workflow_signal(cr, uid, ids, signal, context=context) + def delete_workflow(self, cr, uid, ids, context=None): + # overridden in order to trigger the workflow of stock.picking at the end of create, + # write and unlink operation instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').delete_workflow(cr, uid, ids, context=context) + + def trigger_workflow(self, cr, uid, ids, context=None): + # overridden in order to trigger the workflow of stock.picking at the end of create, + # write and unlink operation instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').trigger_workflow(cr, uid, ids, context=context) + + def signal_workflow(self, cr, uid, ids, signal, context=None): + # overridden in order to fire the workflow signal on given stock.picking workflow instance + # instead of its own workflow (which is not existing) + return self.pool.get('stock.picking').signal_workflow(cr, uid, ids, signal, context=context) _columns = { 'backorder_id': fields.many2one('stock.picking.out', 'Back Order of', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="If this shipment was split, then this field links to the shipment which contains the already processed part.", select=True), From f66e33f36d9eb725380fe05802f3c4a9ab37435a Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 13 Feb 2013 16:01:36 +0100 Subject: [PATCH 2/2] [IMP] rename model method 'trigger_workflow' into 'step_workflow' (less confusing) bzr revid: rco@openerp.com-20130213150136-rg0llzdr4tzizise --- addons/procurement/procurement.py | 4 ++-- addons/stock/stock.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 5dc8daf8303..edf01290398 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -373,13 +373,13 @@ class procurement_order(osv.osv): self.message_post(cr, uid, [procurement.id], body=message, context=context) return ok - def trigger_workflow(self, cr, uid, ids, context=None): + def step_workflow(self, cr, uid, ids, context=None): """ Don't trigger workflow for the element specified in trigger """ wkf_op_key = 'workflow.trg_write.%s' % self._name if context and not context.get(wkf_op_key, True): # make sure we don't have a trigger loop while processing triggers return - return super(procurement_order, self).trigger_workflow(cr, uid, ids, context=context) + return super(procurement_order, self).step_workflow(cr, uid, ids, context=context) def action_produce_assign_service(self, cr, uid, ids, context=None): """ Changes procurement state to Running. diff --git a/addons/stock/stock.py b/addons/stock/stock.py index b8a7c675b6a..8e4611dc5d0 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2957,10 +2957,10 @@ class stock_picking_in(osv.osv): # write and unlink operation instead of its own workflow (which is not existing) return self.pool.get('stock.picking').delete_workflow(cr, uid, ids, context=context) - def trigger_workflow(self, cr, uid, ids, context=None): + def step_workflow(self, cr, uid, ids, context=None): # overridden in order to trigger the workflow of stock.picking at the end of create, # write and unlink operation instead of its own workflow (which is not existing) - return self.pool.get('stock.picking').trigger_workflow(cr, uid, ids, context=context) + return self.pool.get('stock.picking').step_workflow(cr, uid, ids, context=context) def signal_workflow(self, cr, uid, ids, signal, context=None): # overridden in order to fire the workflow signal on given stock.picking workflow instance @@ -3012,10 +3012,10 @@ class stock_picking_out(osv.osv): # write and unlink operation instead of its own workflow (which is not existing) return self.pool.get('stock.picking').delete_workflow(cr, uid, ids, context=context) - def trigger_workflow(self, cr, uid, ids, context=None): + def step_workflow(self, cr, uid, ids, context=None): # overridden in order to trigger the workflow of stock.picking at the end of create, # write and unlink operation instead of its own workflow (which is not existing) - return self.pool.get('stock.picking').trigger_workflow(cr, uid, ids, context=context) + return self.pool.get('stock.picking').step_workflow(cr, uid, ids, context=context) def signal_workflow(self, cr, uid, ids, signal, context=None): # overridden in order to fire the workflow signal on given stock.picking workflow instance