Reviewers: ,


Please review this at http://codereview.tryton.org/80003/

Affected files:
  M opportunity.py
  M opportunity.xml


Index: opportunity.py
===================================================================

--- a/opportunity.py
+++ b/opportunity.py
@@ -270,6 +270,22 @@
             })
         return sale_id

+    def wkf_lead(self, opportunity):
+        self.write(opportunity.id, {'state': 'lead'})
+
+    def wkf_opportunity(self, opportunity):
+        self.write(opportunity.id, {'state': 'opportunity'})
+
+    def wkf_converted(self, opportunity):
+        self.set_end_date(opportunity.id, 'converted')
+        self.create_sale(opportunity.id)
+
+    def wkf_cancelled(self, opportunity):
+        self.set_end_date(opportunity.id, 'cancelled')
+
+    def wkf_lost(self, opportunity):
+        self.set_end_date(opportunity.id, 'lost')
+
 SaleOpportunity()



Index: opportunity.xml
===================================================================

--- a/opportunity.xml
+++ b/opportunity.xml
@@ -251,36 +251,30 @@
         <record model="workflow.activity" id="opportunity_activity_lead">
             <field name="name">Lead</field>
             <field name="workflow" ref="opportunity_workflow"/>
-            <field name="kind">function</field>
-            <field name="action">write({'state': 'lead'})</field>
+            <field name="method">wkf_lead</field>
             <field name="flow_start" eval="True"/>
         </record>
<record model="workflow.activity" id="opportunity_activity_opportunity">
             <field name="name">Opportunity</field>
             <field name="workflow" ref="opportunity_workflow"/>
-            <field name="kind">function</field>
-            <field name="action">write({'state': 'opportunity'})</field>
+            <field name="method">wkf_opportunity</field>
         </record>
<record model="workflow.activity" id="opportunity_activity_converted">
             <field name="name">Converted</field>
             <field name="workflow" ref="opportunity_workflow"/>
-            <field name="kind">function</field>
-            <field name="action">set_end_date('converted')
-create_sale()</field>
+            <field name="method">wkf_converted</field>
             <field name="flow_stop" eval="True"/>
         </record>
<record model="workflow.activity" id="opportunity_activity_cancelled">
             <field name="name">Cancelled</field>
             <field name="workflow" ref="opportunity_workflow"/>
-            <field name="kind">function</field>
-            <field name="action">set_end_date('cancelled')</field>
+            <field name="method">wkf_cancelled</field>
             <field name="flow_stop" eval="True"/>
         </record>
         <record model="workflow.activity" id="opportunity_activity_lost">
             <field name="name">Lost</field>
             <field name="workflow" ref="opportunity_workflow"/>
-            <field name="kind">function</field>
-            <field name="action">set_end_date('lost')</field>
+            <field name="method">wkf_lost</field>
             <field name="flow_stop" eval="True"/>
         </record>




--
[email protected] mailing list

Reply via email to