Hi,
We are working on the sale order workflow too. We have to define a new state 
between 'draft' and 'manual'/'progress' that would be called 'wait_confirm'.
Here is the plan :
- the state 'draft' will be used for... draft sale orders ;) written by the 
Commercial service,
- then the customer accept (or not) the quotation => the salesman modify it (or 
not), and then pass it to the state 'wait_confirmation'
- at this moment, the Accounting service can validate or not the quotation to 
make it a sale order, and modify the order_line if necessary.
=> This is the important point here : the sale order lines are still in 'draft' 
state while the sale order has been passed in 'wait_confirmation' state because 
we want our Accounting service to be able to modify the sale order if necessary.

So :
We redefined the 'state' field in 'sale_order' object to add the 'wait_confirm' 
state.

'state': fields.selection([('draft', 'Quotation'), 
('wait_confirm', 'Waiting Confirmation'), ('waiting_date', 'Waiting 
Schedule'), ('manual', 'Manual In Progress'), ('progress', 'In 
Progress'), ('shipping_except', 'Shipping Exception'), 
('invoice_except', 'Invoice Exception'), ('done', 'Done'), 
('cancel', 'Cancelled')], 'Order State', readonly=True, 
select=True),



We defined a function 'action_waiting_confirmation' that changes the state of 
the sale order (and not the sale order lines).

def action_waiting_confirmation(self,cr,uid,ids,*args):
    if not len(ids):
        return False
    self.write(cr,uid,ids,{'state': 
'wait_confirm'})
    return True



We made some changes in the sale order workflow :
- workflow.activity

<record id="act_wait_confirm" model="workflow.activity">
&nbsp; &nbsp;<field name="wkf_id" ref="sale.wkf_sale"/>
&nbsp; &nbsp;<field name="name">wait_confirm</field>
&nbsp; &nbsp;<field name="kind">function</field>
&nbsp; &nbsp;<field name="action">action_waiting_confirmation&#40;&#41;</field>
</record>




- workflow.transition

<!-- delete the 'draft' => 'manual'/'progress' transition -->
<delete id="sale.trans_draft_router" model="workflow.transition"/>

<!-- 'draft' => 'wait_confirm' -->
<record id="trans_draft_wait_confirm" model="workflow.transition">
&nbsp; &nbsp;<field name="act_from" ref="sale.act_draft"/>
&nbsp; &nbsp;<field name="act_to" ref="act_wait_confirm"/>
&nbsp; &nbsp;<field name="signal">waiting_confirmation</field>
&nbsp; &nbsp;<field name="role_id" ref="sale.res_roles_salesman0"/>
</record>

<!-- 'wait_confirm' => 'manual'/'progress' -->
<record id="trans_wait_confirm_router" model="workflow.transition">
&nbsp; &nbsp;<field name="act_from" ref="act_wait_confirm"/>
&nbsp; &nbsp;<field name="act_to" ref="sale.act_router"/>
&nbsp; &nbsp;<field name="signal">order_confirm</field>
&nbsp; &nbsp;<field name="role_id" ref="sale.res_roles_salesman0"/>
</record>

<!-- 'wait_confirm' => 'cancel' -->
<record id="trans_wait_confirm_cancel" model="workflow.transition">
&nbsp; &nbsp;<field name="act_from" ref="act_wait_confirm"/>
&nbsp; &nbsp;<field name="act_to" ref="sale.act_cancel"/>
&nbsp; &nbsp;<field name="signal">cancel</field>
</record>



- process.node

<!-- node for 'wait_confirm' state -->
<record id="process_node_waitingconfirmation0" model="process.node">
&nbsp; &nbsp;<field name="menu_id" ref="sale.menu_sale_order"/>
&nbsp; &nbsp;<field name="model_id" ref="sale.model_sale_order"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" 
name="kind"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Waiting 
Confirmation&quot;&quot;&quot;" name="name"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;The accounting service validates 
the sale order.&quot;&quot;&quot;" name="note"/>
&nbsp; &nbsp;<field name="process_id" ref="sale.process_process_salesprocess0"/>
&nbsp; &nbsp;<field 
eval="&quot;&quot;&quot;object.state=='wait_confirm'&quot;&quot;&quot;" 
name="model_states"/>
&nbsp; &nbsp;<field eval="0" name="flow_start"/>
</record>

<!-- node for 'cancel' state -->
<record id="process_node_cancel0" model="process.node">
&nbsp; &nbsp;<field name="menu_id" ref="sale.menu_sale_order"/>
&nbsp; &nbsp;<field name="model_id" ref="sale.model_sale_order"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" 
name="kind"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Quotation&quot;&quot;&quot;" 
name="name"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Quotation &#40;A sale order in 
draft state&#41;&quot;&quot;&quot;" name="note"/>
&nbsp; &nbsp;<field name="process_id" ref="sale.process_process_salesprocess0"/>
&nbsp; &nbsp;<field 
eval="&quot;&quot;&quot;object.state=='cancel'&quot;&quot;&quot;" 
name="model_states"/>
&nbsp; &nbsp;<field eval="0" name="flow_start"/>
</record>



- process.transition

<!-- node 'process_node_quotation0' &#40;draft&#41; => node 
'process_node_waitingconfirmation0' &#40;wait_confirm&#41; by using 
'trans_draft_wait_confirm' transition -->
<record id="process_transition_quotation0_waitingconfirmation0" 
model="process.transition">
&nbsp; &nbsp;<field eval="&#91;&#40;6,0,&#91;&#93;&#41;&#93;" 
name="transition_ids"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Waiting 
Confirmation&quot;&quot;&quot;" name="name"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Whenever confirm button is clicked, 
the draft state is moved to manual. that is, quotation is moved to&nbsp; sale 
order.&quot;&quot;&quot;" name="note"/>
&nbsp; &nbsp;<field model="process.node" name="target_node_id" 
ref="process_node_waitingconfirmation0"/>
&nbsp; &nbsp;<field model="process.node" name="source_node_id" 
ref="sale.process_node_quotation0"/>
&nbsp; &nbsp;<field 
eval="&#91;&#40;6,0,&#91;ref&#40;'trans_draft_wait_confirm'&#41;&#93;&#41;&#93;"
 name="transition_ids"/>
</record>

<!-- node 'process_node_waitingconfirmation0' &#40;wait_confirm&#41; => node 
'process_node_saleorder0' &#40;manual/progress&#41; by using 
'trans_wait_confirm_router' transition -->
<record id="process_transition_waitingconfirmation0_confirmquotation0" 
model="process.transition">
&nbsp; &nbsp;<field eval="&#91;&#40;6,0,&#91;&#93;&#41;&#93;" 
name="transition_ids"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Confirm 
Quotation&quot;&quot;&quot;" name="name"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Whenever confirm button is clicked, 
the draft state is moved to manual. that is, quotation is moved to&nbsp; sale 
order.&quot;&quot;&quot;" name="note"/>
&nbsp; &nbsp;<field model="process.node" name="target_node_id" 
ref="sale.process_node_saleorder0"/>
&nbsp; &nbsp;<field model="process.node" name="source_node_id" 
ref="process_node_waitingconfirmation0"/>
&nbsp; &nbsp;<field 
eval="&#91;&#40;6,0,&#91;ref&#40;'trans_wait_confirm_router'&#41;&#93;&#41;&#93;"
 name="transition_ids"/>
</record>

<!-- node 'process_node_waitingconfirmation0' &#40;wait_confirm&#41; => node 
'process_node_cancel0' &#40;cancel&#41; by using 'trans_wait_confirm_cancel' 
transition -->
<record id="process_transition_waitingconfirmation0_cancel0" 
model="process.transition">
&nbsp; &nbsp;<field eval="&#91;&#40;6,0,&#91;&#93;&#41;&#93;" 
name="transition_ids"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Confirm 
Quotation&quot;&quot;&quot;" name="name"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Whenever confirm button is clicked, 
the draft state is moved to manual. that is, quotation is moved to&nbsp; sale 
order.&quot;&quot;&quot;" name="note"/>
&nbsp; &nbsp;<field model="process.node" name="target_node_id" 
ref="process_node_cancel0"/>
&nbsp; &nbsp;<field model="process.node" name="source_node_id" 
ref="process_node_waitingconfirmation0"/>
&nbsp; &nbsp;<field 
eval="&#91;&#40;6,0,&#91;ref&#40;'trans_wait_confirm_cancel'&#41;&#93;&#41;&#93;"
 name="transition_ids"/>
</record>



- process.transition.action

<record id="process_transition_action_confirm1" 
model="process.transition.action">
&nbsp; &nbsp;<field 
eval="&quot;&quot;&quot;action_waiting_confirmation&quot;&quot;&quot;" 
name="action"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;object&quot;&quot;&quot;" 
name="state"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Waiting 
Confirmation&quot;&quot;&quot;" name="name"/>
&nbsp; &nbsp;<field name="transition_id" 
ref="process_transition_quotation0_waitingconfirmation0"/>
</record>

<record id="process_transition_action_waitconfirm0" 
model="process.transition.action">
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;action_wait&quot;&quot;&quot;" 
name="action"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;object&quot;&quot;&quot;" 
name="state"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Confirmation&quot;&quot;&quot;" 
name="name"/>
&nbsp; &nbsp;<field name="transition_id" 
ref="process_transition_waitingconfirmation0_confirmquotation0"/>
</record>

<record id="process_transition_action_cancel3" 
model="process.transition.action">
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;action_cancel&quot;&quot;&quot;" 
name="action"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;object&quot;&quot;&quot;" 
name="state"/>
&nbsp; &nbsp;<field eval="&quot;&quot;&quot;Cancel&quot;&quot;&quot;" 
name="name"/>
&nbsp; &nbsp;<field name="transition_id" 
ref="process_transition_waitingconfirmation0_cancel0"/>
</record>



And finally the view part for the buttons in the sale order view

<group col="13" colspan="4">
&nbsp; &nbsp;<field name="state" select="2"/>
&nbsp; &nbsp;<button name="waiting_confirmation" states="draft" string="Wait 
Confirmation" icon="gtk-execute"/>
&nbsp; &nbsp;<button name="order_confirm" states="wait_confirm" string="Confirm 
Order" icon="gtk-execute"/>
&nbsp; &nbsp;<button name="invoice_recreate" states="invoice_except" 
string="Recreate Invoice" icon="gtk-execute"/>
&nbsp; &nbsp;<button name="invoice_corrected" states="invoice_except" 
string="Invoice Corrected" icon="gtk-go-forward"/>
&nbsp; &nbsp;<button name="ship_recreate" states="shipping_except" 
string="Recreate Procurement" icon="gtk-execute"/>
&nbsp; &nbsp;<button name="ship_corrected" states="shipping_except" 
string="Procurement Corrected" icon="gtk-go-forward"/>
&nbsp; &nbsp;<button name="manual_invoice" states="manual" string="Create 
Invoice" icon="gtk-execute"/>
&nbsp; &nbsp;<button name="ship_cancel" states="shipping_except" string="Cancel 
Order" icon="gtk-cancel"/>
&nbsp; &nbsp;<button name="action_cancel_draft" states="cancel" string="Set to 
Draft" type="object" icon="gtk-convert"/>
&nbsp; &nbsp;<button name="action_cancel" states="manual,progress" 
string="Cancel Order" type="object" icon="gtk-cancel"/>
&nbsp; &nbsp;<button name="cancel" states="draft,wait_confirm" string="Cancel 
Order" icon="gtk-cancel"/>
&nbsp; &nbsp;<button name="invoice_cancel" states="invoice_except" 
string="Cancel Order" icon="gtk-cancel"/>
</group>



At this point, everything "seems OK" from the workflow side. We can pass from 
'draft' to 'wait_confirm' or 'cancel', 'wait_confirm' to 'manual'/'progress' or 
'cancel', and 'cancel' to 'draft'.
But! we can't create any sale order line anymore from the sale order view in 
'draft' or 'wait_confirm'. We have to create a sale order, then a sale order 
line (from the sale order line view) and link it to the sale order.
The 'order_line' field of 'sale.order' object has readonly=False in 'draft' and 
'wait_confirm' states.

Any help will be useful :) Thx for reading




-------------------- m2f --------------------

--
http://www.openobject.com/forum/viewtopic.php?p=57214#57214

-------------------- m2f --------------------


_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users

Reply via email to