~koi-accounting-modules-maintainer/koi-accounting-modules/7.0-fixed-asset

« back to all changes in this revision

Viewing changes to ar_account/object_other/account_invoice.py

  • Committer: Andhitia Rama
  • Date: 2015-08-07 13:01:25 UTC
  • Revision ID: andhitia.r@gmail.com-20150807130125-47717n0jry5vtaf3
Integrasi dgn tax

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
##############################################################################
22
22
 
23
23
 
24
 
from osv import  osv
 
24
from osv import  osv,fields
25
25
from openerp.tools.translate import _
26
26
 
27
27
class account_invoice(osv.osv):
31
31
    def _default_journal_id(self, cr, uid, context={}):
32
32
        return False
33
33
 
 
34
    _columns =  {
 
35
                'faktur_pajak_id' : fields.many2one(string='# Faktur Pajak',
 
36
                    obj='pajak.faktur_pajak',
 
37
                    ),
 
38
                }
 
39
 
34
40
    _defaults = {
35
41
                'journal_id' : _default_journal_id,
36
42
                }
40
46
            if not self._create_sequence(cr, uid, invoice):
41
47
                return False
42
48
 
 
49
            if not self._check_tax(cr, uid, invoice.id):
 
50
                return False
 
51
 
43
52
            if not self._create_account_move(cr, uid, invoice, context):
44
53
                return False
45
54
 
46
 
            if not self._check_tax(cr, uid, invoice.id):
47
 
                return False
48
55
 
49
56
            self.write(cr, uid, [invoice.id], {'state' : 'open'})
50
57
 
116
123
                return False
117
124
 
118
125
        # create account.move.line for each tax
119
 
        if invoice.tax_line:
 
126
        if invoice.tax_line and not invoice.faktur_pajak_id:
120
127
            for tax in invoice.tax_line:
121
128
                tax_move_line_id = obj_tax._create_account_move_line(cr, uid, tax, move_id)
122
129
 
129
136
                return False
130
137
 
131
138
 
132
 
 
133
139
        invoice = self.browse(cr, uid, [invoice.id])[0]
134
140
        self.write(cr, uid, [invoice.id], {'move_id' : move_id, 'move_name' : invoice.name})
135
141
 
193
199
        if invoice_currency.id != company_currency.id:
194
200
            result['currency_id'] = invoice_currency.id
195
201
 
196
 
        exchange_rate = obj_currency.compute(cr, uid, invoice_currency.id, company_currency.id, 1.0, context={'date' : invoice.date_invoice})
197
 
        amount_total = invoice.amount_total * exchange_rate
 
202
        exchange_rate = obj_currency.compute(cr, uid, invoice_currency.id, 
 
203
                company_currency.id, 1.0, context={'date' : invoice.date_invoice})
 
204
 
 
205
        if invoice.faktur_pajak_id:
 
206
            amount = invoice.amount_untaxed
 
207
        else:
 
208
            amount = invoice.amount_total
 
209
 
 
210
        amount_total = amount * exchange_rate
198
211
 
199
212
 
200
213
        if invoice.type == 'out_invoice' or invoice.type == 'in_refund':
201
214
            result['debit'] = amount_total
202
 
            result['amount_currency'] = result['currency_id'] and invoice.amount_total or 0.0
 
215
            result['amount_currency'] = result['currency_id'] and amount or 0.0
203
216
        else:
204
217
            result['credit'] = amount_total
205
 
            result['amount_currency'] = result['currency_id'] and -1.0 * invoice.amount_total or 0.0
 
218
            result['amount_currency'] = result['currency_id'] and -1.0 * amount or 0.0
206
219
 
207
220
        return result
208
221