Divyesh Makwana(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-customer_invoice_wkf-mdi into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-customer_invoice_wkf-mdi/+merge/95552
Hello Sir,
I have improved the following things:
1. Improved workflow state name, button name and also the position in which
they are appear.
2. Open payment in new window (and close voucher when paid).
3. Added 'sent' state to send an invoice by e-mail and its related changes to
workflow.
Thanks and Regards,
Divyesh Makwana(MDI)
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-customer_invoice_wkf-mdi/+merge/95552
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-customer_invoice_wkf-mdi.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2012-02-28 14:08:16 +0000
+++ account/account_invoice.py 2012-03-02 13:07:25 +0000
@@ -202,7 +202,8 @@
('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,56 @@
_('There is no Accounting Journal of type Sale/Purchase defined!'))
else:
raise orm.except_orm(_('Unknown Error'), str(e))
+
+ def _hook_message_sent(self, cr, uid, invoice_id, context=None):
+ wf_service = netsvc.LocalService("workflow")
+ wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_sent', cr)
+ return True
+
+ def invoice_print(self, cr, uid, ids, context=None):
+ wf_service = netsvc.LocalService('workflow')
+ for id in ids:
+ wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_sent', cr)
+ datas = {
+ 'ids': ids,
+ 'model': 'account.invoice',
+ 'form': self.read(cr, uid, ids, context=context)[0]
+ }
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'account.invoice',
+ 'datas': datas,
+ 'nodestroy' : True
+ }
+
+ def action_invoice_sent(self, cr, uid, ids, context=None):
+ email_template_obj = self.pool.get('email.template')
+ mod_obj = self.pool.get('ir.model.data')
+
+ template_id = email_template_obj.search(cr, uid, [('model_id', '=', 'account.invoice')], context=context)[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, context=context).res_id
+
+ #EDI EXport data
+ id = ids[0]
+ invoice = self.browse(cr, uid, id, context)
+# if not invoice.partner_id.opt_out:
+# invoice.edi_export_and_email(template_ext_id='account.email_template_edi_invoice', context=context)
+ ctx = context.copy()
+ ctx.update({'active_model': 'account.invoice', 'active_id': invoice.id, 'mail.compose.template_id': template.id})
+
+ return {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'mail.compose.message',
+ 'views': [(res_id, 'form')],
+ 'view_id': res_id,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'context': ctx,
+ 'nodestroy': True,
+ }
def confirm_paid(self, cr, uid, ids, context=None):
if context is None:
=== modified file 'account/account_invoice_view.xml'
--- account/account_invoice_view.xml 2012-02-28 14:08:16 +0000
+++ account/account_invoice_view.xml 2012-03-02 13:07:25 +0000
@@ -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="action_invoice_sent" type="object" string="Send By Email" icon="terp-mail-message-new" states="open"/>
+ <button name="invoice_print" string="Print Invoice" type="object" icon="gtk-print" states="open"/>
+ <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='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','<>','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>
=== modified file 'account/account_invoice_workflow.xml'
--- account/account_invoice_workflow.xml 2011-01-14 00:11:01 +0000
+++ account/account_invoice_workflow.xml 2012-03-02 13:07:25 +0000
@@ -30,6 +30,14 @@
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">write({'state':'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 @@
<field name="act_to" ref="act_open"/>
<field name="signal">invoice_open</field>
</record>
+ <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_open"/>
+ <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 @@
<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"/>
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py 2012-02-24 10:23:05 +0000
+++ account_voucher/account_voucher.py 2012-03-02 13:07:25 +0000
@@ -772,7 +772,7 @@
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")
=== modified file 'account_voucher/account_voucher_pay_invoice.xml'
--- account_voucher/account_voucher_pay_invoice.xml 2011-10-16 01:28:00 +0000
+++ account_voucher/account_voucher_pay_invoice.xml 2012-03-02 13:07:25 +0000
@@ -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>
=== modified file 'account_voucher/invoice.py'
--- account_voucher/invoice.py 2011-10-27 21:11:24 +0000
+++ account_voucher/invoice.py 2012-03-02 13:07:25 +0000
@@ -36,7 +36,7 @@
'res_model': 'account.voucher',
'type': 'ir.actions.act_window',
'nodestroy': True,
- 'target': 'current',
+ 'target': 'new',
'domain': '[]',
'context': {
'default_partner_id': inv.partner_id.id,
=== modified file 'account_voucher/voucher_payment_receipt_view.xml'
--- account_voucher/voucher_payment_receipt_view.xml 2012-02-28 14:08:16 +0000
+++ account_voucher/voucher_payment_receipt_view.xml 2012-03-02 13:07:25 +0000
@@ -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>
=== modified file 'email_template/email_template.py'
--- email_template/email_template.py 2012-02-13 14:35:31 +0000
+++ email_template/email_template.py 2012-03-02 13:07:25 +0000
@@ -56,6 +56,8 @@
: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)
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp