Reviewers: ,


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

Affected files:
  M forecast.py
  M forecast.xml


Index: forecast.py
===================================================================

--- a/forecast.py
+++ b/forecast.py
@@ -118,27 +118,24 @@
         self.workflow_trigger_create(ids)
         return True

-    def set_state_draft(self, forecast_id):
-        line_obj = Pool().get("stock.forecast.line")
-        forecast = self.browse(forecast_id)
+    def wkf_draft(self, forecast):
+        line_obj = Pool().get('stock.forecast.line')
         if forecast.state == "done":
             line_obj.cancel_moves(forecast.lines)
-        self.write(forecast_id, {
+        self.write(forecast.id, {
             'state': 'draft',
             })

-    def set_state_cancel(self, forecast_id):
-        self.write(forecast_id, {
+    def wkf_cancel(self, forecast):
+        self.write(forecast.id, {
             'state': 'cancel',
             })

-    def set_state_done(self, forecast_id):
+    def wkf_done(self, forecast):
         line_obj = Pool().get('stock.forecast.line')
-        forecast = self.browse(forecast_id)
-
         for line in forecast.lines:
             line_obj.create_moves(line)
-        self.write(forecast_id, {
+        self.write(forecast.id, {
             'state': 'done',
             })

@@ -257,7 +254,7 @@
         unit_price = False
         if line.forecast.destination.type == 'customer':
             unit_price = line.product.list_price
-            unit_price = uom_obj.compute_price(line.product.default_uom,
+            unit_price = uom_obj.compute_price(line.product.default_uom,
                     unit_price, line.uom)

         moves = []
@@ -280,7 +277,7 @@

     def cancel_moves(self, lines):
         move_obj = Pool().get('stock.move')
-        move_obj.write([m.id for l in lines for m in l.moves],
+        move_obj.write([m.id for l in lines for m in l.moves],
                 {'state': 'cancel'})
         move_obj.delete([m.id for l in lines for m in l.moves])

@@ -413,7 +410,7 @@
                 stock_destination=[forecast.destination.id],
                 stock_date_start=data['form']['from_date'],
                 stock_date_end=data['form']['to_date']):
-            return product_obj.products_by_location([forecast.location.id],
+            return product_obj.products_by_location([forecast.location.id],
                     with_childs=True, skip_zero=False)

     def _set_default_products(self, data):

Index: forecast.xml
===================================================================

--- a/forecast.xml
+++ b/forecast.xml
@@ -173,23 +173,20 @@
         <record model="workflow.activity" id="forecast_act_draft">
             <field name="workflow" ref="wkf_forecast"/>
             <field name="flow_start">True</field>
-            <field name="kind">function</field>
-            <field name="action">set_state_draft()</field>
+            <field name="method">wkf_draft</field>
             <field name="name">Draft</field>
         </record>
         <record model="workflow.activity" id="forecast_act_cancel">
             <field name="workflow" ref="wkf_forecast"/>
             <field name="flow_stop">True</field>
             <field name="name">Cancel</field>
-            <field name="kind">function</field>
-            <field name="action">set_state_cancel()</field>
+            <field name="method">wkf_cancel</field>
         </record>
         <record model="workflow.activity" id="forecast_act_done">
             <field name="workflow" ref="wkf_forecast"/>
             <field name="flow_stop">True</field>
             <field name="name">Done</field>
-            <field name="kind">function</field>
-            <field name="action">set_state_done()</field>
+            <field name="method">wkf_done</field>
         </record>
         <record model="workflow.transition"
                 id="forecast_trans_draft_cancel">



--
[email protected] mailing list

Reply via email to