From f1e82fabde91e5856e1d0a6d3a075e69ca864e1e Mon Sep 17 00:00:00 2001 From: vra Date: Wed, 6 Oct 2010 13:30:25 +0530 Subject: [PATCH] [ADD] account_voucher: added act window for invoice payment through account voucher. bzr revid: vra@tinyerp.com-20101006080025-4pt3bv23ev2hkfp6 --- addons/account_voucher/account_voucher.py | 11 ++++++++++- addons/account_voucher/account_voucher_view.xml | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 2ea6e4b39ab..0d0dfafcb8c 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -112,6 +112,15 @@ class account_voucher(osv.osv): return [(r['id'], (str("%.2f" % r['amount']) or '')) for r in self.read(cr, uid, ids, ['amount'], context, load='_classic_write')] def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): + if not view_id and context.get('invoice_type',False): + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + if context.get('invoice_type') in ('out_invoice','out_refund'): + result = mod_obj._get_id(cr, uid, 'account_voucher', 'view_vendor_receipt_form') + else: + result = mod_obj._get_id(cr, uid, 'account_voucher', 'view_vendor_payment_form') + result = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id'] + view_id = result res = super(account_voucher,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) doc = etree.XML(res['arch']) nodes = doc.xpath("//field[@name='partner_id']") @@ -349,7 +358,6 @@ class account_voucher(osv.osv): if context is None: context = {} - currency_pool = self.pool.get('res.currency') move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') @@ -384,6 +392,7 @@ class account_voucher(osv.osv): account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id default['value']['account_id'] = account_id + if journal.type not in ('cash', 'bank'): return default diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index d066c91ad0e..343211c264b 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -161,7 +161,6 @@ +