1
from osv import osv, fields
2
from tools import config
4
class invoice_line(osv.osv):
5
_inherit = 'account.invoice.line'
7
'tax_stamp': fields.boolean('Tax stamp', help='Specify whether this line should be used for comuting the taxable amount'),
11
class account_invoice(osv.osv):
12
_inherit = 'account.invoice'
14
def _amount_all(self, cr, uid, ids, name, args, context=None):
15
# import pdb; pdb.set_trace()
17
for invoice in self.browse(cr,uid,ids, context=context):
19
'amount_untaxed': 0.0,
23
for line in invoice.invoice_line:
25
res[invoice.id]['amount_tax'] += line.price_subtotal
27
res[invoice.id]['amount_untaxed'] += line.price_subtotal
28
for line in invoice.tax_line:
29
res[invoice.id]['amount_tax'] += line.amount
30
res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']
33
def _get_invoice_tax(self, cr, uid, ids, context=None):
34
return super(account_invoice, self)._get_invoice_tax(self, cr, uid, ids, context)
36
def _get_invoice_line(self, cr, uid, ids, context=None):
37
return super(account_invoice, self)._get_invoice_line(self, cr, uid, ids, context)
40
'amount_untaxed': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])),string='Untaxed',
42
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
43
'account.invoice.tax': (_get_invoice_tax, None, 20),
44
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20),
47
'amount_tax': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])), string='Tax',
49
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
50
'account.invoice.tax': (_get_invoice_tax, None, 20),
51
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20),
54
'amount_total': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])), string='Total',
56
'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
57
'account.invoice.tax': (_get_invoice_tax, None, 20),
58
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20),