summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2014-07-07 11:50:30 +0200
committerRaphael Collet <rco@openerp.com>2014-07-07 11:50:30 +0200
commit33eb3dffb2bd3ac9d886a17c3c67ea83e65dcaa1 (patch)
tree9bb298a8c7193fa7ad7ef637655fd824a28d165d
parentcbe2dbb672a6c55d86f2e515f9d1cdfee426ef80 (diff)
[REM] models: remove the magic methods signal_XXX()
-rw-r--r--addons/account/account_invoice.py2
-rw-r--r--addons/mrp/mrp.py4
-rw-r--r--addons/mrp/procurement.py2
-rw-r--r--addons/mrp/stock.py4
-rw-r--r--addons/point_of_sale/point_of_sale.py10
-rw-r--r--addons/purchase/purchase.py16
-rw-r--r--addons/purchase_requisition/purchase_requisition.py8
-rw-r--r--addons/sale/wizard/sale_make_invoice.py2
-rw-r--r--addons/sale_stock/sale_stock.py4
-rw-r--r--addons/sale_stock/test/cancel_order_sale_stock.yml2
-rw-r--r--addons/sale_stock/test/picking_order_policy.yml2
-rw-r--r--addons/stock/wizard/make_procurement_product.py2
-rw-r--r--addons/website_quote/controllers/main.py2
-rw-r--r--openerp/addons/base/ir/ir_actions.py4
-rw-r--r--openerp/models.py13
15 files changed, 32 insertions, 45 deletions
diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py
index ad99ae40058..455feb14afb 100644
--- a/addons/account/account_invoice.py
+++ b/addons/account/account_invoice.py
@@ -98,7 +98,7 @@ class account_invoice(models.Model):
def _compute_reconciled(self):
self.reconciled = self.test_paid()
if not self.reconciled and self.state == 'paid':
- self.signal_open_test()
+ self.signal_workflow('open_test')
@api.model
def _get_reference_type(self):
diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py
index 73d0688a543..453bfe5c458 100644
--- a/addons/mrp/mrp.py
+++ b/addons/mrp/mrp.py
@@ -884,7 +884,7 @@ class mrp_production(osv.osv):
production = self.browse(cr, uid, production_id, context=context)
if not production.move_lines and production.state == 'ready':
# trigger workflow if not products to consume (eg: services)
- self.signal_button_produce(cr, uid, [production_id])
+ self.signal_workflow(cr, uid, [production_id], 'button_produce')
produced_qty = self._get_produced_qty(cr, uid, production, context=context)
@@ -944,7 +944,7 @@ class mrp_production(osv.osv):
stock_mov_obj.action_done(cr, uid, [extra_move_id], context=context)
self.message_post(cr, uid, production_id, body=_("%s produced") % self._description, context=context)
- self.signal_button_produce_done(cr, uid, [production_id])
+ self.signal_workflow(cr, uid, [production_id], 'button_produce_done')
return True
def _costs_generate(self, cr, uid, production):
diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py
index 50650b7b371..06eacc6a1a2 100644
--- a/addons/mrp/procurement.py
+++ b/addons/mrp/procurement.py
@@ -114,7 +114,7 @@ class procurement_order(osv.osv):
procurement.refresh()
self.production_order_create_note(cr, uid, procurement, context=context)
production_obj.action_compute(cr, uid, [produce_id], properties=[x.id for x in procurement.property_ids])
- production_obj.signal_button_confirm(cr, uid, [produce_id])
+ production_obj.signal_workflow(cr, uid, [produce_id], 'button_confirm')
else:
res[procurement.id] = False
self.message_post(cr, uid, [procurement.id], body=_("No BoM exists for this product!"), context=context)
diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py
index e04c434a741..236fec019dd 100644
--- a/addons/mrp/stock.py
+++ b/addons/mrp/stock.py
@@ -159,7 +159,7 @@ class StockMove(osv.osv):
'consumed_for': consumed_for}, context=context)
self.action_done(cr, uid, res, context=context)
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
- production_obj.signal_button_produce(cr, uid, production_ids)
+ production_obj.signal_workflow(cr, uid, production_ids, button_produce)
for new_move in res:
if new_move != move.id:
#This move is not already there in move lines of production order
@@ -181,7 +181,7 @@ class StockMove(osv.osv):
#If we are not scrapping our whole move, tracking and lot references must not be removed
production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])])
for prod_id in production_ids:
- production_obj.signal_button_produce(cr, uid, [prod_id])
+ production_obj.signal_workflow(cr, uid, [prod_id], 'button_produce')
for new_move in new_moves:
production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]})
res.append(new_move)
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index 1eec3cb48d4..5c8103c7626 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -497,7 +497,7 @@ class pos_session(osv.osv):
_('Error!'),
_("You cannot confirm all orders of this session, because they have not the 'paid' status"))
else:
- pos_order_obj.signal_done(cr, uid, [order.id])
+ pos_order_obj.signal_workflow(cr, uid, [order.id], 'done')
return True
@@ -581,14 +581,14 @@ class pos_order(osv.osv):
order_ids.append(order_id)
try:
- self.signal_paid(cr, uid, [order_id])
+ self.signal_workflow(cr, uid, [order_id], 'paid')
except Exception as e:
_logger.error('Could not fully process the POS Order: %s', tools.ustr(e))
if to_invoice:
self.action_invoice(cr, uid, [order_id], context)
order_obj = self.browse(cr, uid, order_id, context)
- self.pool['account.invoice'].signal_invoice_open(cr, uid, [order_obj.invoice_id.id])
+ self.pool['account.invoice'].signal_workflow(cr, uid, [order_obj.invoice_id.id], 'invoice_open')
return order_ids
@@ -933,8 +933,8 @@ class pos_order(osv.osv):
inv_line['invoice_line_tax_id'] = [(6, 0, [x.id for x in line.product_id.taxes_id] )]
inv_line_ref.create(cr, uid, inv_line, context=context)
inv_ref.button_reset_taxes(cr, uid, [inv_id], context=context)
- self.signal_invoice(cr, uid, [order.id])
- inv_ref.signal_validate(cr, uid, [inv_id])
+ self.signal_workflow(cr, uid, [order.id], 'invoice')
+ inv_ref.signal_workflow(cr, uid, [inv_id], 'validate')
if not inv_ids: return {}
diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index e8622de493d..da14954d4a0 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -328,7 +328,7 @@ class purchase_order(osv.osv):
raise osv.except_osv(_('Invalid Action!'), _('In order to delete a purchase order, you must cancel it first.'))
# automatically sending subflow.delete upon deletion
- self.signal_purchase_cancel(cr, uid, unlink_ids)
+ self.signal_workflow(cr, uid, unlink_ids, 'purchase_cancel')
return super(purchase_order, self).unlink(cr, uid, unlink_ids, context=context)
@@ -519,7 +519,7 @@ class purchase_order(osv.osv):
This function prints the request for quotation and mark it as sent, so that we can see more easily the next step of the workflow
'''
assert len(ids) == 1, 'This option should only be used for a single id at a time'
- self.signal_send_rfq(cr, uid, ids)
+ self.signal_workflow(cr, uid, ids, 'send_rfq')
return self.pool['report'].get_action(cr, uid, ids, 'purchase.report_purchasequotation', context=context)
def wkf_confirm_order(self, cr, uid, ids, context=None):
@@ -680,19 +680,19 @@ class purchase_order(osv.osv):
_('Unable to cancel the purchase order %s.') % (purchase.name),
_('First cancel all receptions related to this purchase order.'))
self.pool.get('stock.picking') \
- .signal_button_cancel(cr, uid, map(attrgetter('id'), purchase.picking_ids))
+ .signal_workflow(cr, uid, map(attrgetter('id'), purchase.picking_ids), 'button_cancel')
for inv in purchase.invoice_ids:
if inv and inv.state not in ('cancel', 'draft'):
raise osv.except_osv(
_('Unable to cancel this purchase order.'),
_('You must first cancel all invoices related to this purchase order.'))
self.pool.get('account.invoice') \
- .signal_invoice_cancel(cr, uid, map(attrgetter('id'), purchase.invoice_ids))
+ .signal_workflow(cr, uid, map(attrgetter('id'), purchase.invoice_ids), 'invoice_cancel')
self.pool['purchase.order.line'].write(cr, uid, [l.id for l in purchase.order_line],
{'state': 'cancel'})
self.write(cr, uid, ids, {'state': 'cancel'})
self.set_order_line_status(cr, uid, ids, 'cancel', context=context)
- self.signal_purchase_cancel(cr, uid, ids)
+ self.signal_workflow(cr, uid, ids, 'purchase_cancel')
return True
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, group_id, context=None):
@@ -933,7 +933,7 @@ class purchase_order(osv.osv):
# make triggers pointing to the old orders point to the new order
for old_id in old_ids:
self.redirect_workflow(cr, uid, [(old_id, neworder_id)])
- self.signal_purchase_cancel(cr, uid, [old_id])
+ self.signal_workflow(cr, uid, [old_id], 'purchase_cancel')
return orders_info
@@ -1370,7 +1370,7 @@ class mail_mail(osv.Model):
if mail_sent and mail.model == 'purchase.order':
obj = self.pool.get('purchase.order').browse(cr, uid, mail.res_id, context=context)
if obj.state == 'draft':
- self.pool.get('purchase.order').signal_send_rfq(cr, uid, [mail.res_id])
+ self.pool.get('purchase.order').signal_workflow(cr, uid, [mail.res_id], 'send_rfq')
return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context, mail_sent=mail_sent)
@@ -1423,7 +1423,7 @@ class mail_compose_message(osv.Model):
context = context or {}
if context.get('default_model') == 'purchase.order' and context.get('default_res_id'):
context = dict(context, mail_post_autofollow=True)
- self.pool.get('purchase.order').signal_send_rfq(cr, uid, [context['default_res_id']])
+ self.pool.get('purchase.order').signal_workflow(cr, uid, [context['default_res_id']], 'send_rfq')
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py
index a4908f23687..954547cb5b5 100644
--- a/addons/purchase_requisition/purchase_requisition.py
+++ b/addons/purchase_requisition/purchase_requisition.py
@@ -245,7 +245,7 @@ class purchase_requisition(osv.osv):
for quotation in tender.purchase_ids:
if (self.check_valid_quotation(cr, uid, quotation, context=context)):
#use workflow to set PO state to confirm
- po.signal_purchase_confirm(cr, uid, [quotation.id])
+ po.signal_workflow(cr, uid, [quotation.id], 'purchase_confirm')
#get other confirmed lines per supplier
for po_line in tender.po_line_ids:
@@ -268,13 +268,13 @@ class purchase_requisition(osv.osv):
vals = self._prepare_po_line_from_tender(cr, uid, tender, line, new_po, context=context)
poline.copy(cr, uid, line.id, default=vals, context=context)
#use workflow to set new PO state to confirm
- po.signal_purchase_confirm(cr, uid, [new_po])
+ po.signal_workflow(cr, uid, [new_po], 'purchase_confirm')
#cancel other orders
self.cancel_unconfirmed_quotations(cr, uid, tender, context=context)
#set tender to state done
- self.signal_done(cr, uid, [tender.id])
+ self.signal_workflow(cr, uid, [tender.id], 'done')
return True
def cancel_unconfirmed_quotations(self, cr, uid, tender, context=None):
@@ -282,7 +282,7 @@ class purchase_requisition(osv.osv):
po = self.pool.get('purchase.order')
for quotation in tender.purchase_ids:
if quotation.state in ['draft', 'sent', 'bid']:
- self.pool.get('purchase.order').signal_purchase_cancel(cr, uid, [quotation.id])
+ self.pool.get('purchase.order').signal_workflow(cr, uid, [quotation.id], 'purchase_cancel')
po.message_post(cr, uid, [quotation.id], body=_('Cancelled by the call for bids associated to this request for quotation.'), context=context)
return True
diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py
index 170259824f7..073c2481160 100644
--- a/addons/sale/wizard/sale_make_invoice.py
+++ b/addons/sale/wizard/sale_make_invoice.py
@@ -60,7 +60,7 @@ class sale_make_invoice(osv.osv_memory):
for i in o.invoice_ids:
newinv.append(i.id)
# Dummy call to workflow, will not create another invoice but bind the new invoice to the subflow
- order_obj.signal_manual_invoice(cr, uid, [o.id for o in orders if o.order_policy == 'manual'])
+ order_obj.signal_workflow(cr, uid, [o.id for o in orders if o.order_policy == 'manual'], 'manual_invoice')
result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1')
id = result and result[1] or False
result = act_obj.read(cr, uid, [id], context=context)[0]
diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py
index 61183413a33..20bac48c562 100644
--- a/addons/sale_stock/sale_stock.py
+++ b/addons/sale_stock/sale_stock.py
@@ -159,7 +159,7 @@ class sale_order(osv.osv):
raise osv.except_osv(
_('Cannot cancel sales order!'),
_('You must first cancel all delivery order(s) attached to this sales order.'))
- stock_obj.signal_button_cancel(cr, uid, [p.id for p in sale.picking_ids])
+ stock_obj.signal_workflow(cr, uid, [p.id for p in sale.picking_ids], 'button_cancel')
return super(sale_order, self).action_cancel(cr, uid, ids, context=context)
def action_wait(self, cr, uid, ids, context=None):
@@ -356,7 +356,7 @@ class stock_move(osv.osv):
if move.procurement_id and move.procurement_id.sale_line_id:
sale_ids.append(move.procurement_id.sale_line_id.order_id.id)
if sale_ids:
- self.pool.get('sale.order').signal_ship_except(cr, uid, sale_ids)
+ self.pool.get('sale.order').signal_workflow(cr, uid, sale_ids, 'ship_except')
return super(stock_move, self).action_cancel(cr, uid, ids, context=context)
def _create_invoice_line_from_vals(self, cr, uid, move, invoice_line_vals, context=None):
diff --git a/addons/sale_stock/test/cancel_order_sale_stock.yml b/addons/sale_stock/test/cancel_order_sale_stock.yml
index 302cbf4a933..49835b064c9 100644
--- a/addons/sale_stock/test/cancel_order_sale_stock.yml
+++ b/addons/sale_stock/test/cancel_order_sale_stock.yml
@@ -76,7 +76,7 @@
!python {model: sale.order}: |
invoice_ids = self.browse(cr, uid, ref("sale.sale_order_8")).invoice_ids
first_invoice_id = invoice_ids[0]
- self.pool.get('account.invoice').signal_invoice_cancel(cr, uid, [first_invoice_id.id])
+ self.pool.get('account.invoice').signal_workflow(cr, uid, [first_invoice_id.id], 'invoice_cancel')
-
I check order status in "Invoice Exception" and related invoice is in cancel state.
-
diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml
index 57ba0323b4c..8de8ea45a08 100644
--- a/addons/sale_stock/test/picking_order_policy.yml
+++ b/addons/sale_stock/test/picking_order_policy.yml
@@ -190,7 +190,7 @@
so = self.browse(cr, uid, ref("sale_order_service"))
account_invoice_obj = self.pool.get('account.invoice')
for invoice in so.invoice_ids:
- account_invoice_obj.signal_invoice_open(cr, uid, [invoice.id])
+ account_invoice_obj.signal_workflow(cr, uid, [invoice.id], 'invoice_open')
-
I pay the invoice
-
diff --git a/addons/stock/wizard/make_procurement_product.py b/addons/stock/wizard/make_procurement_product.py
index 73dda6bbb3e..5c6f4b618ee 100644
--- a/addons/stock/wizard/make_procurement_product.py
+++ b/addons/stock/wizard/make_procurement_product.py
@@ -76,7 +76,7 @@ class make_procurement(osv.osv_memory):
'location_id': wh.lot_stock_id.id,
'company_id': wh.company_id.id,
})
- procurement_obj.signal_button_confirm(cr, uid, [procure_id])
+ procurement_obj.signal_workflow(cr, uid, [procure_id], 'button_confirm')
id2 = data_obj._get_id(cr, uid, 'procurement', 'procurement_tree_view')
id3 = data_obj._get_id(cr, uid, 'procurement', 'procurement_form_view')
diff --git a/addons/website_quote/controllers/main.py b/addons/website_quote/controllers/main.py
index 522a613bdff..8fab07fcce2 100644
--- a/addons/website_quote/controllers/main.py
+++ b/addons/website_quote/controllers/main.py
@@ -65,7 +65,7 @@ class sale_quote(http.Controller):
if token != order.access_token:
return request.website.render('website.404')
attachments=sign and [('signature.png', sign.decode('base64'))] or []
- order_obj.signal_order_confirm(request.cr, SUPERUSER_ID, [order_id], context=request.context)
+ order_obj.signal_workflow(request.cr, SUPERUSER_ID, [order_id], 'order_confirm', context=request.context)
message = _('Order signed by %s') % (signer,)
self.__message_post(message, order_id, type='comment', subtype='mt_comment', attachments=attachments)
return True
diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py
index 7ac8783ddd9..c9195d93d12 100644
--- a/openerp/addons/base/ir/ir_actions.py
+++ b/openerp/addons/base/ir/ir_actions.py
@@ -848,9 +848,9 @@ class ir_actions_server(osv.osv):
def run_action_trigger(self, cr, uid, action, eval_context=None, context=None):
""" Trigger a workflow signal, depending on the use_relational_model:
- - `base`: base_model_pool.signal_<TRIGGER_NAME>(cr, uid, context.get('active_id'))
+ - `base`: base_model_pool.signal_workflow(cr, uid, context.get('active_id'), <TRIGGER_NAME>)
- `relational`: find the related model and object, using the relational
- field, then target_model_pool.signal_<TRIGGER_NAME>(cr, uid, target_id)
+ field, then target_model_pool.signal_workflow(cr, uid, target_id, <TRIGGER_NAME>)
"""
obj_pool = self.pool[action.model_id.model]
if action.use_relational_model == 'base':
diff --git a/openerp/models.py b/openerp/models.py
index 86d702ef582..a87ab3e8b23 100644
--- a/openerp/models.py
+++ b/openerp/models.py
@@ -4937,19 +4937,6 @@ class BaseModel(object):
""" stuff to do right after the registry is built """
pass
- def __getattr__(self, name):
- if name.startswith('signal_'):
- # self.signal_XXX() sends signal XXX to the record's workflow
- signal_name = name[7:]
- assert signal_name
- return (lambda *args, **kwargs:
- self.signal_workflow(*args, signal=signal_name, **kwargs))
-
- get = getattr(super(BaseModel, self), '__getattr__', None)
- if get is None:
- raise AttributeError("%r has no attribute %r" % (type(self).__name__, name))
- return get(name)
-
def _patch_method(self, name, method):
""" Monkey-patch a method for all instances of this model. This replaces
the method called `name` by `method` in `self`'s class.