From 3ac345c3853f345c06483d8bb9cbd2e0954cdd6f Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Wed, 19 Dec 2007 03:27:08 +0000 Subject: [PATCH] Fix the way of passing a rule to Delivery.updateAppliedRule, and correct a warning message. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18401 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/Order.py | 18 ++++++++++++------ product/ERP5/Document/PackingList.py | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/product/ERP5/Document/Order.py b/product/ERP5/Document/Order.py index b53ebb6237..06e59f4dbd 100644 --- a/product/ERP5/Document/Order.py +++ b/product/ERP5/Document/Order.py @@ -35,6 +35,7 @@ from Products.ERP5Type.Base import Base from Products.ERP5.Document.Delivery import Delivery from zLOG import LOG +from warnings import warn class Order(Delivery): # CMF Type Definition @@ -136,13 +137,18 @@ class Order(Delivery): ########################################################################## # Applied Rule stuff - def updateAppliedRule(self, rule_id="default_order_rule",force=0,**kw): + def updateAppliedRule(self, rule_id=None, rule_reference=None, **kw): + """XXX FIXME: Kept for compatibility. + updateAppliedRule must be called with a rule_reference in a workflow + script. """ - XXX FIXME: Kept for compatibility - updateAppliedRule must be call with the rule_id in workflow script - """ - LOG('Order.updateAppliedRule ',0,'This method this method should not be used anymore.') - Delivery.updateAppliedRule(self, rule_id, force=force,**kw) + if rule_id is None and rule_reference is None: + warn('Relying on a default order rule is deprecated; ' \ + 'rule_reference must be specified explicitly.', + DeprecationWarning) + rule_reference = 'default_order_rule' + Delivery.updateAppliedRule(self, rule_id=rule_id, + rule_reference=rule_reference, **kw) def expandAppliedRuleRelatedToOrder(self, activate_kw=None,**kw): """ diff --git a/product/ERP5/Document/PackingList.py b/product/ERP5/Document/PackingList.py index 6f5cebb452..2128e84b64 100644 --- a/product/ERP5/Document/PackingList.py +++ b/product/ERP5/Document/PackingList.py @@ -32,6 +32,7 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5.Document.Delivery import Delivery from zLOG import LOG +from warnings import warn class PackingList(Delivery): """ @@ -122,9 +123,15 @@ class PackingList(Delivery): ########################################################################## # Applied Rule stuff - def updateAppliedRule(self, rule_id="default_delivery_rule", **kw): + def updateAppliedRule(self, rule_id=None, rule_reference=None, **kw): + """XXX FIXME: Kept for compatibility. + updateAppliedRule must be called with a rule_reference in a workflow + script. """ - XXX FIXME: Kept for compatibility - updateAppliedRule must be call with the rule_id in workflow script - """ - Delivery.updateAppliedRule(self, rule_id, **kw) + if rule_id is None and rule_reference is None: + warn('Relying on a default order rule is deprecated; ' \ + 'rule_reference must be specified explicitly.', + DeprecationWarning) + rule_reference = 'default_delivery_rule' + Delivery.updateAppliedRule(self, rule_id=rule_id, + rule_reference=rule_reference, **kw) -- 2.30.9