Bug invoice rate ICT
This commit is contained in:
@@ -565,6 +565,16 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin):
|
|||||||
if rate:
|
if rate:
|
||||||
return round(1/rate,6) or 1
|
return round(1/rate,6) or 1
|
||||||
|
|
||||||
|
def _compute_company_currency_amount(self, amount, date=None):
|
||||||
|
Currency = Pool().get('currency.currency')
|
||||||
|
if self.currency == self.company.currency:
|
||||||
|
return amount
|
||||||
|
if self.rate:
|
||||||
|
return self.company.currency.round(amount / self.rate)
|
||||||
|
with Transaction().set_context(date=date or self.currency_date):
|
||||||
|
return Currency.compute(
|
||||||
|
self.currency, amount, self.company.currency)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_type():
|
def default_type():
|
||||||
return Transaction().context.get('type', 'out')
|
return Transaction().context.get('type', 'out')
|
||||||
@@ -1900,6 +1910,8 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin):
|
|||||||
|
|
||||||
moves = []
|
moves = []
|
||||||
for invoice in invoices:
|
for invoice in invoices:
|
||||||
|
if invoice.currency != invoice.company.currency and not invoice.rate:
|
||||||
|
invoice.rate = invoice.get_selected_rate()
|
||||||
move = invoice.get_move()
|
move = invoice.get_move()
|
||||||
if move != invoice.move:
|
if move != invoice.move:
|
||||||
invoice.move = move
|
invoice.move = move
|
||||||
@@ -3199,7 +3211,6 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
|
|||||||
|
|
||||||
def _compute_taxes(self):
|
def _compute_taxes(self):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Currency = pool.get('currency.currency')
|
|
||||||
TaxLine = pool.get('account.tax.line')
|
TaxLine = pool.get('account.tax.line')
|
||||||
|
|
||||||
tax_lines = []
|
tax_lines = []
|
||||||
@@ -3208,11 +3219,7 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
|
|||||||
taxes = self._get_taxes().values()
|
taxes = self._get_taxes().values()
|
||||||
for tax in taxes:
|
for tax in taxes:
|
||||||
amount = tax['base']
|
amount = tax['base']
|
||||||
with Transaction().set_context(
|
amount = self.invoice._compute_company_currency_amount(amount)
|
||||||
date=self.invoice.currency_date):
|
|
||||||
amount = Currency.compute(
|
|
||||||
self.invoice.currency, amount,
|
|
||||||
self.invoice.company.currency)
|
|
||||||
tax_line = TaxLine()
|
tax_line = TaxLine()
|
||||||
tax_line.amount = amount
|
tax_line.amount = amount
|
||||||
tax_line.type = 'base'
|
tax_line.type = 'base'
|
||||||
@@ -3537,9 +3544,7 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView):
|
|||||||
'''
|
'''
|
||||||
Return a list of move lines instances for invoice tax
|
Return a list of move lines instances for invoice tax
|
||||||
'''
|
'''
|
||||||
Currency = Pool().get('currency.currency')
|
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Currency = pool.get('currency.currency')
|
|
||||||
MoveLine = pool.get('account.move.line')
|
MoveLine = pool.get('account.move.line')
|
||||||
TaxLine = pool.get('account.tax.line')
|
TaxLine = pool.get('account.tax.line')
|
||||||
line = MoveLine()
|
line = MoveLine()
|
||||||
@@ -3547,11 +3552,8 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView):
|
|||||||
return []
|
return []
|
||||||
line.description = self.description
|
line.description = self.description
|
||||||
if self.invoice.currency != self.invoice.company.currency:
|
if self.invoice.currency != self.invoice.company.currency:
|
||||||
with Transaction().set_context(date=self.invoice.currency_date):
|
amount = self.invoice._compute_company_currency_amount(self.amount)
|
||||||
amount = Currency.compute(self.invoice.currency, self.amount,
|
base = self.invoice._compute_company_currency_amount(self.base)
|
||||||
self.invoice.company.currency)
|
|
||||||
base = Currency.compute(self.invoice.currency, self.base,
|
|
||||||
self.invoice.company.currency)
|
|
||||||
line.amount_second_currency = self.amount
|
line.amount_second_currency = self.amount
|
||||||
line.second_currency = self.invoice.currency
|
line.second_currency = self.invoice.currency
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user