Workflow on invoice

->add a button and a transition from paid to open + a pop-up of confirmation if the button is pressed(inv must be unreconciled)

bzr revid: mra@tinyerp.com-20080826062732-sfg4u4jshoi3d2n0
This commit is contained in:
Mustufa Rangwala 2008-08-26 11:57:32 +05:30
parent 4b4acd020d
commit a2c1dd98d5
5 changed files with 93 additions and 5 deletions

View File

@ -164,6 +164,7 @@
<button name="invoice_open" states="draft,proforma" string="Validate"/>
<button name="invoice_cancel" states="draft,proforma,sale,open" string="Cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid'/>
</group>
</group>
</page>
@ -232,6 +233,7 @@
<button name="invoice_open" states="draft,proforma" string="Create"/>
<button name="invoice_cancel" states="draft,proforma,sale,open" string="Cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name='%(wizard_paid_open)d' type='action' string='Re-Open' states='paid'/>
</group>
</group>
</page>

View File

@ -6,7 +6,7 @@
<field name="osv">account.invoice</field>
<field name="on_create">True</field>
</record>
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="flow_start">True</field>
@ -31,10 +31,16 @@ action_number()
write({'state':'open'})</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_open_test">
<field name="wkf_id" ref="wkf"/>
<field name="name">open</field>
<field name="action">write({'state':'open'})</field>
<field name="kind">function</field>
</record>
<record id="act_paid" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">paid</field>
<field name="flow_stop">True</field>
<!--<field name="flow_stop">True</field>-->
<field name="action">write({'state':'paid'})</field>
<field name="kind">function</field>
</record>
@ -46,14 +52,14 @@ write({'state':'open'})</field>
write({'state':'cancel'})</field>
<field name="kind">function</field>
</record>
<!--
<record model="workflow.transition" id="t1">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_confirm"/>
</record>
-->
<record id="t3" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_proforma"/>
@ -98,5 +104,15 @@ write({'state':'cancel'})</field>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record id="t13" model="workflow.transition">
<field name="act_from" ref="act_paid"/>
<field name="act_to" ref="act_open_test"/>
<field name="signal">open_test</field>
</record>
<record id="t14" model="workflow.transition">
<field name="act_from" ref="act_open_test"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
</data>
</terp>

View File

@ -77,5 +77,7 @@
<wizard string="Use Models" model="account.model" name="account_use_models" menu="False" id="wizard_account_use_model"/>
<menuitem action="wizard_account_use_model" type="wizard" parent="account.menu_finance_periodical_processing" id="menu_account_use_model"/>
<!-- account.invoice -->
<wizard string="Open State" model="account.invoice" name="account.wizard_paid_open" menu="False" id="wizard_paid_open"/>
</data>
</terp>

View File

@ -61,7 +61,11 @@ import wizard_account_chart
import wizard_move_line_select
import wizard_validate_account_move
import wizard_use_model# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
import wizard_use_model
import wizard_state_open
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,64 @@
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# #
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import pooler
import netsvc
form = '''<?xml version="1.0"?>
<form string="Open Invoice">
<label string="Are you sure you want to open this invoice ?"/>
<newline/>
<label string="(Invoice should be unreconciled if you want to open it)"/>
</form>'''
fields = {
}
def _change_inv_state(self, cr, uid, data, context):
pool_obj = pooler.get_pool(cr.dbname)
data_inv = pool_obj.get('account.invoice').browse(cr, uid, data['ids'][0])
if data_inv.reconciled:
raise wizard.except_wizard('Warning', 'Invoice is already reconciled')
wf_service = netsvc.LocalService("workflow")
res = wf_service.trg_validate(uid, 'account.invoice', data['ids'][0], 'open_test', cr)
return {}
class wiz_state_open(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('yes','Yes'),('end','No')]}
},
'yes': {
'actions': [_change_inv_state],
'result': {'type':'state', 'state':'end'}
}
}
wiz_state_open('account.wizard_paid_open')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: