[IMP] account, account_voucher : Improved workflow state name, button name and also the position,Open payment in new window (and close voucher when paid), added 'sent' state and its related changes.

bzr revid: mdi@tinyerp.com-20120229064705-x1j7ll1yst2ez5mf
This commit is contained in:
Divyesh Makwana (Open ERP) 2012-02-29 12:17:05 +05:30
parent 6aaca44580
commit 8082c6e4a3
8 changed files with 67 additions and 12 deletions

View File

@ -202,7 +202,8 @@ class account_invoice(osv.osv):
('draft','Draft'),
('proforma','Pro-forma'),
('proforma2','Pro-forma'),
('open','Open'),
('open','Validated'),
('sent','Sent'),
('paid','Paid'),
('cancel','Cancelled')
],'State', select=True, readonly=True,
@ -370,6 +371,27 @@ class account_invoice(osv.osv):
_('There is no Accounting Journal of type Sale/Purchase defined!'))
else:
raise orm.except_orm(_('Unknown Error'), str(e))
def invoice_sent(self, cr, uid, ids, *args):
email_template_obj = self.pool.get('email.template')
mod_obj = self.pool.get('ir.model.data')
template_id = email_template_obj.search(cr, uid, [('name', '=', 'Automated Invoice Notification Mail')])[0]
template = email_template_obj.browse(cr, uid, template_id)
model_data_id = mod_obj._get_id(cr, uid, 'mail', 'email_compose_message_wizard_form')
res_id = mod_obj.browse(cr, uid, model_data_id).res_id
self.write(cr, uid, ids, {'state' : 'sent'})
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(res_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context':{'active_model':'account.invoice', 'mail.compose.template_id': template.id},
}
def confirm_paid(self, cr, uid, ids, context=None):
if context is None:

View File

@ -299,16 +299,17 @@
<field name="amount_tax"/>
<field name="reconciled"/>
<field name="amount_total"/>
<field name="state" widget="statusbar" statusbar_visible="draft,open,paid" statusbar_colors='{"proforma":"blue","proforma2":"blue"}'/>
<field name="state" widget="statusbar" statusbar_visible="draft,open,sent,paid" statusbar_colors='{"proforma":"blue","proforma2":"blue"}'/>
<field name="residual"/>
<group col="8" colspan="4" groups="base.group_user">
<button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel" icon="gtk-cancel" groups="base.group_no_one"/>
<button name="invoice_sent" string="Send By Email" icon="terp-mail-message-new" states="open"/>
<button name="%(account_invoices)d" string="Print Invoice" type="action" icon="gtk-print" states="open,proforma,sale,proforma2"/>
<button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-go-forward"/>
<button name="invoice_proforma2" states="draft" string="PRO-FORMA" icon="terp-gtk-media-pause" groups="account.group_account_user"/>
<button name="%(action_account_invoice_refund)d" type='action' string='Refund Invoice' states='open,sent,paid' icon="gtk-execute"/>
<button name="invoice_cancel" states="draft,proforma2,sale,open,sent" string="Cancel" icon="gtk-cancel" groups="base.group_no_one"/>
<button name="action_cancel_draft" states="cancel" string="Reset to Draft" type="object" icon="terp-stock_effects-object-colorize"/>
<button name='%(action_account_state_open)d' type='action' string='Re-Open' groups="account.group_account_invoice" attrs="{'invisible':['|', ('state','&lt;&gt;','paid'), ('reconciled', '=', True)]}" icon="gtk-convert" help="This button only appears when the state of the invoice is 'paid' (showing that it has been fully reconciled) and auto-computed boolean 'reconciled' is False (depicting that it's not the case anymore). In other words, the invoice has been dereconciled and it does not fit anymore the 'paid' state. You should press this button to re-open it and let it continue its normal process after having resolved the eventual exceptions it may have created."/>
<button name="%(action_account_invoice_refund)d" type='action' string='Refund' states='open,paid' icon="gtk-execute"/>
<button name="invoice_proforma2" states="draft" string="PRO-FORMA" icon="terp-gtk-media-pause" groups="account.group_account_user"/>
<button name="invoice_open" states="draft,proforma2" string="Validate" icon="gtk-go-forward"/>
<button name="%(account_invoices)d" string="Print Invoice" type="action" icon="gtk-print" states="open,paid,proforma,sale,proforma2"/>
</group>
</group>
</page>

View File

@ -30,6 +30,14 @@ action_number()
write({'state':'open'})</field>
<field name="kind">function</field>
</record>
<record id="act_sent" model="workflow.activity">
<field name="wkf_id" ref="wkf"/>
<field name="name">sent</field>
<field name="action">invoice_sent()</field>
<field name="kind">function</field>
</record>
<record model="workflow.activity" id="act_open_test">
<field name="wkf_id" ref="wkf"/>
<field name="name">re-open</field>
@ -58,13 +66,30 @@ write({'state':'cancel'})</field>
<field name="act_to" ref="act_open"/>
<field name="signal">invoice_open</field>
</record>
<record id="t8" model="workflow.transition">
<record id="t_open_sent" model="workflow.transition">
<field name="act_from" ref="act_open"/>
<field name="act_to" ref="act_sent"/>
<field name="signal">invoice_sent</field>
</record>
<record id="t_open_paid" model="workflow.transition">
<field name="act_from" ref="act_open"/>
<field name="act_to" ref="act_paid"/>
<field name="trigger_model">account.move.line</field>
<field name="trigger_expr_id">move_line_id_payment_get()</field>
<field name="condition">test_paid()</field>
</record>
<record id="t8" model="workflow.transition">
<field name="act_from" ref="act_sent"/>
<field name="act_to" ref="act_paid"/>
<field name="trigger_model">account.move.line</field>
<field name="trigger_expr_id">move_line_id_payment_get()</field>
<field name="condition">test_paid()</field>
</record>
<record id="t_sent_cancel" model="workflow.transition">
<field name="act_from" ref="act_sent"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record id="t9" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_cancel"/>
@ -86,6 +111,11 @@ write({'state':'cancel'})</field>
<field name="signal">invoice_cancel</field>
</record>
<record id="open_test_to_sent" model="workflow.transition">
<field name="act_from" ref="act_open_test"/>
<field name="act_to" ref="act_sent"/>
<field name="signal">invoice_sent</field>
</record>
<record id="open_test_to_paid" model="workflow.transition">
<field name="act_from" ref="act_open_test"/>
<field name="act_to" ref="act_paid"/>

View File

@ -772,7 +772,7 @@ class account_voucher(osv.osv):
def proforma_voucher(self, cr, uid, ids, context=None):
self.action_move_line_create(cr, uid, ids, context=context)
return True
return {'type': 'ir.actions.act_window_close'}
def action_cancel_draft(self, cr, uid, ids, context=None):
wf_service = netsvc.LocalService("workflow")

View File

@ -8,7 +8,7 @@
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<button name="invoice_open" position="after">
<button name="invoice_pay_customer" type="object" string="Payment" states="open" icon="gtk-go-forward"/>
<button name="invoice_pay_customer" type="object" string="Register Payment" states="open,sent" icon="gtk-go-forward"/>
</button>
</field>
</record>

View File

@ -36,7 +36,7 @@ class invoice(osv.osv):
'res_model': 'account.voucher',
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
'target': 'new',
'domain': '[]',
'context': {
'default_partner_id': inv.partner_id.id,

View File

@ -403,10 +403,10 @@
</notebook>
<group col="10" colspan="4">
<field name="state" widget="statusbar" statusbar_visible="draft,posted" statusbar_colors='{"proforma":"blue"}'/>
<button name="proforma_voucher" string="Validate" states="draft" icon="gtk-go-forward" invisible="context.get('line_type', False)"/>
<button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel" invisible="context.get('line_type', False)"/>
<button name="cancel_voucher" string="Unreconcile" type="object" states="posted" invisible="context.get('line_type', False)" icon="terp-stock_effects-object-colorize" confirm="Are you sure to unreconcile and cancel this record ?"/>
<button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize" invisible="context.get('line_type', False)"/>
<button name="proforma_voucher" string="Validate" states="draft" icon="gtk-go-forward" invisible="context.get('line_type', False)"/>
</group>
</form>
</field>

View File

@ -56,6 +56,8 @@ class email_template(osv.osv):
:param str model: model name of the document record this mail is related to.
:param int res_id: id of the document record this mail is related to.
"""
if context is None:
context = {}
if not template: return u""
try:
template = tools.ustr(template)