From 5fabd6fe48ef3d76892d8c09b197cebf4d520045 Mon Sep 17 00:00:00 2001 From: "Jalpesh Patel (OpenERP)" Date: Wed, 27 Jun 2012 10:32:16 +0530 Subject: [PATCH] [IMP] improve sales-receipt bzr revid: pja@tinyerp.com-20120627050216-lf9nko3d1q3vqdj9 --- addons/account_voucher/account_voucher.py | 16 +++++++++++++--- .../voucher_sales_purchase_view.xml | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 1e882b7c585..1eba8c5be9a 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -52,7 +52,16 @@ class account_voucher(osv.osv): paid = True res[voucher.id] = paid return res - + def untaxed_amount(self, cr, uid, ids, name, args, context=None): + res = {} + amount = 0.0 + for voucher in self.browse(cr, uid, ids, context=context): + for line in voucher.line_cr_ids: + amount += line.amount + res[voucher.id] = amount + return res + + def _get_type(self, cr, uid, context=None): if context is None: context = {} @@ -312,6 +321,7 @@ class account_voucher(osv.osv): help='The specific rate that will be used, in this voucher, between the selected currency (in \'Payment Rate Currency\' field) and the voucher currency.'), 'paid_amount_in_company_currency': fields.function(_paid_amount_in_company_currency, string='Paid Amount in Company Currency', type='float', readonly=True), 'is_multi_currency': fields.boolean('Multi Currency Voucher', help='Fields with internal purpose only that depicts if the voucher is a multi currency one or not'), + 'amount_untaxed': fields.function(untaxed_amount, digits_compute=dp.get_precision('Account'), string='Untaxed'), } _defaults = { 'period_id': _get_period, @@ -381,6 +391,7 @@ class account_voucher(osv.osv): return True def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context=None): + context = context or {} tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') @@ -398,7 +409,6 @@ class account_voucher(osv.osv): line_amount = 0.0 line_amount = line.get('amount',0.0) voucher_total += line_amount - total = voucher_total total_tax = 0.0 if tax_id: @@ -415,7 +425,7 @@ class account_voucher(osv.osv): res.update({ 'amount':total or voucher_total, - 'tax_amount':total_tax + 'tax_amount':total_tax }) return { 'value':res diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 1365a24051f..0cb24c6d7e5 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -131,11 +131,12 @@ + - +