~credativ/openobject-addons/elico-7.0-fixes

« back to all changes in this revision

Viewing changes to account_invoice_line/account.py

  • Committer:
  • Date: 2013-08-23 03:28:08 UTC
  • mfrom: (3.1.4 elico-7.0)
  • Revision ID: elicoidal@hotmail.com-20130823032808-ikvuppdmwbasz6zy
[ADD] account_invoice_line, mrp_move_direct, purchase_price_list_item, purchase_po_price, purchase_control_supplier

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
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>
 
7
#
 
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.
 
12
#
 
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.
 
17
#
 
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/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
from osv import osv, fields
 
24
from tools.translate import _
 
25
import openerp.addons.decimal_precision as dp
 
26
import time
 
27
 
 
28
class account_invoice_type(osv.osv):
 
29
    _name = "account.invoice.type"
 
30
    _description = "Account Invoice Type"
 
31
 
 
32
    _columns = {
 
33
        'name': fields.char('Name',size=128, required=True, translate=True),
 
34
    }
 
35
 
 
36
account_invoice_type()
 
37
 
 
38
class account_invoice(osv.osv):
 
39
    _inherit = "account.invoice"
 
40
 
 
41
    def _get_reference_type(self, cr, uid, context=None):
 
42
        return [('none', _('Free Reference'))] #,
 
43
    
 
44
    _columns = {
 
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)]}),
 
51
    }
 
52
account_invoice()
 
53
 
 
54
class account_invoice_line(osv.osv):
 
55
    _inherit = "account.invoice.line"
 
56
 
 
57
    def _amount_line_with_tax(self, cr, uid, ids, prop, arg, context=None):
 
58
        res = {}
 
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']
 
65
            if line.invoice_id:
 
66
                cur = line.invoice_id.currency_id
 
67
                res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
 
68
        return res
 
69
    
 
70
    _columns = {
 
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(
 
73
                    'partner_id', 'ref',
 
74
                    type='char', size=64,relation='res.partner',
 
75
                    string='Partner Ref',select=1),
 
76
        'type': fields.related(
 
77
                    'invoice_id', 'type',
 
78
                    type='char', size=64,relation='account.invoice',
 
79
                    string='Type'),
 
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',
 
99
                    string='State'),
 
100
        'reference': fields.related(
 
101
                    'invoice_id', 'reference',
 
102
                    type='char', size=16,relation='account.invoice',
 
103
                    string='Reference'),
 
104
    }
 
105
account_invoice_line()
 
106
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: