1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
6
# Author: Andy Lu <andy.lu@elico-corp.com>
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Affero General Public License as
10
# published by the Free Software Foundation, either version 3 of the
11
# License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU Affero General Public License for more details.
18
# You should have received a copy of the GNU Affero General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from osv import osv, fields
24
from tools.translate import _
25
import openerp.addons.decimal_precision as dp
28
class account_invoice_type(osv.osv):
29
_name = "account.invoice.type"
30
_description = "Account Invoice Type"
33
'name': fields.char('Name',size=128, required=True, translate=True),
36
account_invoice_type()
38
class account_invoice(osv.osv):
39
_inherit = "account.invoice"
41
def _get_reference_type(self, cr, uid, context=None):
42
return [('none', _('Free Reference'))] #,
45
'account_invoice_type': fields.many2one('account.invoice.type', 'Invoice Type'),
46
'supplier_invoice_number': fields.char('Supplier Inv Ref', size=64, help="The reference of this invoice as provided by the supplier."),
47
'fapiao_date': fields.date('V.A.T Date', ),
48
'partner_ref': fields.related('partner_id','ref',type='char', size=64, string='Partner Ref'),
49
'reference_type': fields.selection(_get_reference_type, 'Payment Reference',
50
required=True, readonly=True, states={'draft':[('readonly',False)]}),
54
class account_invoice_line(osv.osv):
55
_inherit = "account.invoice.line"
57
def _amount_line_with_tax(self, cr, uid, ids, prop, arg, context=None):
59
tax_obj = self.pool.get('account.tax')
60
cur_obj = self.pool.get('res.currency')
61
for line in self.browse(cr, uid, ids, context=context):
62
price = line.price_unit * (1-(line.discount or 0.0)/100.0)
63
taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, partner=line.invoice_id.partner_id, force_excluded=True)
64
res[line.id] = taxes['total']
66
cur = line.invoice_id.currency_id
67
res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
71
'amount_subtotal': fields.function(_amount_line_with_tax, string='Amount (Inc. Tax)', type='float', digits_compute=dp.get_precision('Account')),
72
'partner_ref': fields.related(
74
type='char', size=64,relation='res.partner',
75
string='Partner Ref',select=1),
76
'type': fields.related(
78
type='char', size=64,relation='account.invoice',
80
'number': fields.related(
81
'invoice_id', 'number',
82
type='char', size=64,relation='account.invoice',
83
string='Number',select=1),
84
'supplier_invoice_number': fields.related(
85
'invoice_id', 'supplier_invoice_number',
86
type='char', size=64,relation='account.invoice',
87
string='Supplier Inv Ref',select=1),
88
'date_invoice': fields.related(
89
'invoice_id', 'date_invoice',
90
type='date', relation='account.invoice',
91
string='Date Invoice',select=1),
92
'fapiao_date': fields.related(
93
'invoice_id', 'fapiao_date',
94
type='date', relation='account.invoice',
95
string='V.A.T Date',select=1),
96
'state': fields.related(
97
'invoice_id', 'state',
98
type='char', size=16,relation='account.invoice',
100
'reference': fields.related(
101
'invoice_id', 'reference',
102
type='char', size=16,relation='account.invoice',
105
account_invoice_line()
106
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: