Use function name in workflow instead of python code
This commit is contained in:
1 parent
cd7ab541b7
commit
fddddfb430
2 files changed
+10
-16
No files matched your search
+7
-10
@@ -118,27 +118,24 @@ class Forecast(ModelWorkflow, ModelSQL, ModelView):
|
||||
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',
|
||||
})
|
||||
|
||||
|
||||
+3
-6
@@ -173,23 +173,20 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<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">
|
||||
|
||||
Reference in new issue
Block a user