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"> <field name="wkf_id" ref="sale.wkf_sale"/> <field name="name">wait_confirm</field> <field name="kind">function</field> <field name="action">action_waiting_confirmation()</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"> <field name="act_from" ref="sale.act_draft"/> <field name="act_to" ref="act_wait_confirm"/> <field name="signal">waiting_confirmation</field> <field name="role_id" ref="sale.res_roles_salesman0"/> </record> <!-- 'wait_confirm' => 'manual'/'progress' --> <record id="trans_wait_confirm_router" model="workflow.transition"> <field name="act_from" ref="act_wait_confirm"/> <field name="act_to" ref="sale.act_router"/> <field name="signal">order_confirm</field> <field name="role_id" ref="sale.res_roles_salesman0"/> </record> <!-- 'wait_confirm' => 'cancel' --> <record id="trans_wait_confirm_cancel" model="workflow.transition"> <field name="act_from" ref="act_wait_confirm"/> <field name="act_to" ref="sale.act_cancel"/> <field name="signal">cancel</field> </record> - process.node <!-- node for 'wait_confirm' state --> <record id="process_node_waitingconfirmation0" model="process.node"> <field name="menu_id" ref="sale.menu_sale_order"/> <field name="model_id" ref="sale.model_sale_order"/> <field eval=""""state"""" name="kind"/> <field eval=""""Waiting Confirmation"""" name="name"/> <field eval=""""The accounting service validates the sale order."""" name="note"/> <field name="process_id" ref="sale.process_process_salesprocess0"/> <field eval=""""object.state=='wait_confirm'"""" name="model_states"/> <field eval="0" name="flow_start"/> </record> <!-- node for 'cancel' state --> <record id="process_node_cancel0" model="process.node"> <field name="menu_id" ref="sale.menu_sale_order"/> <field name="model_id" ref="sale.model_sale_order"/> <field eval=""""state"""" name="kind"/> <field eval=""""Quotation"""" name="name"/> <field eval=""""Quotation (A sale order in draft state)"""" name="note"/> <field name="process_id" ref="sale.process_process_salesprocess0"/> <field eval=""""object.state=='cancel'"""" name="model_states"/> <field eval="0" name="flow_start"/> </record> - process.transition <!-- node 'process_node_quotation0' (draft) => node 'process_node_waitingconfirmation0' (wait_confirm) by using 'trans_draft_wait_confirm' transition --> <record id="process_transition_quotation0_waitingconfirmation0" model="process.transition"> <field eval="[(6,0,[])]" name="transition_ids"/> <field eval=""""Waiting Confirmation"""" name="name"/> <field eval=""""Whenever confirm button is clicked, the draft state is moved to manual. that is, quotation is moved to sale order."""" name="note"/> <field model="process.node" name="target_node_id" ref="process_node_waitingconfirmation0"/> <field model="process.node" name="source_node_id" ref="sale.process_node_quotation0"/> <field eval="[(6,0,[ref('trans_draft_wait_confirm')])]" name="transition_ids"/> </record> <!-- node 'process_node_waitingconfirmation0' (wait_confirm) => node 'process_node_saleorder0' (manual/progress) by using 'trans_wait_confirm_router' transition --> <record id="process_transition_waitingconfirmation0_confirmquotation0" model="process.transition"> <field eval="[(6,0,[])]" name="transition_ids"/> <field eval=""""Confirm Quotation"""" name="name"/> <field eval=""""Whenever confirm button is clicked, the draft state is moved to manual. that is, quotation is moved to sale order."""" name="note"/> <field model="process.node" name="target_node_id" ref="sale.process_node_saleorder0"/> <field model="process.node" name="source_node_id" ref="process_node_waitingconfirmation0"/> <field eval="[(6,0,[ref('trans_wait_confirm_router')])]" name="transition_ids"/> </record> <!-- node 'process_node_waitingconfirmation0' (wait_confirm) => node 'process_node_cancel0' (cancel) by using 'trans_wait_confirm_cancel' transition --> <record id="process_transition_waitingconfirmation0_cancel0" model="process.transition"> <field eval="[(6,0,[])]" name="transition_ids"/> <field eval=""""Confirm Quotation"""" name="name"/> <field eval=""""Whenever confirm button is clicked, the draft state is moved to manual. that is, quotation is moved to sale order."""" name="note"/> <field model="process.node" name="target_node_id" ref="process_node_cancel0"/> <field model="process.node" name="source_node_id" ref="process_node_waitingconfirmation0"/> <field eval="[(6,0,[ref('trans_wait_confirm_cancel')])]" name="transition_ids"/> </record> - process.transition.action <record id="process_transition_action_confirm1" model="process.transition.action"> <field eval=""""action_waiting_confirmation"""" name="action"/> <field eval=""""object"""" name="state"/> <field eval=""""Waiting Confirmation"""" name="name"/> <field name="transition_id" ref="process_transition_quotation0_waitingconfirmation0"/> </record> <record id="process_transition_action_waitconfirm0" model="process.transition.action"> <field eval=""""action_wait"""" name="action"/> <field eval=""""object"""" name="state"/> <field eval=""""Confirmation"""" name="name"/> <field name="transition_id" ref="process_transition_waitingconfirmation0_confirmquotation0"/> </record> <record id="process_transition_action_cancel3" model="process.transition.action"> <field eval=""""action_cancel"""" name="action"/> <field eval=""""object"""" name="state"/> <field eval=""""Cancel"""" name="name"/> <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"> <field name="state" select="2"/> <button name="waiting_confirmation" states="draft" string="Wait Confirmation" icon="gtk-execute"/> <button name="order_confirm" states="wait_confirm" string="Confirm Order" icon="gtk-execute"/> <button name="invoice_recreate" states="invoice_except" string="Recreate Invoice" icon="gtk-execute"/> <button name="invoice_corrected" states="invoice_except" string="Invoice Corrected" icon="gtk-go-forward"/> <button name="ship_recreate" states="shipping_except" string="Recreate Procurement" icon="gtk-execute"/> <button name="ship_corrected" states="shipping_except" string="Procurement Corrected" icon="gtk-go-forward"/> <button name="manual_invoice" states="manual" string="Create Invoice" icon="gtk-execute"/> <button name="ship_cancel" states="shipping_except" string="Cancel Order" icon="gtk-cancel"/> <button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/> <button name="action_cancel" states="manual,progress" string="Cancel Order" type="object" icon="gtk-cancel"/> <button name="cancel" states="draft,wait_confirm" string="Cancel Order" icon="gtk-cancel"/> <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
