[IMP] improve sales-receipt

bzr revid: pja@tinyerp.com-20120627050216-lf9nko3d1q3vqdj9
This commit is contained in:
Jalpesh Patel (OpenERP) 2012-06-27 10:32:16 +05:30
parent f1957e8563
commit 5fabd6fe48
2 changed files with 16 additions and 4 deletions

View File

@ -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

View File

@ -131,11 +131,12 @@
</group>
<group>
<group class="oe_subtotal_footer" string="Total">
<field name="amount_untaxed"/>
<field name="tax_id"
on_change="onchange_price(line_cr_ids, tax_id, partner_id)"
widget="selection"
domain="[('type_tax_use','in',('sale','all')), ('parent_id', '=', False)]"/>
<field name="tax_amount" nolabel="1"/>
<field name="tax_amount"/>
<field name="amount" class="oe_subtotal_footer_separator" />
<button type="object"
icon="terp-stock_format-scientific" name="compute_tax" string="Compute Tax"
@ -279,6 +280,7 @@
attrs="{'invisible': [('state','!=','draft')]}"/>
</div>
-->
<field name="tax_id"
on_change="onchange_price(line_dr_ids, tax_id, partner_id)"
widget="selection"