← Back to team overview

openerp-india team mailing list archive

Re: [Bug 980967] Re: [6.1] [account_voucher] exchange rate calculation is not working if company currency isn't rate 1

 

Amit,

I do think it is a bug. It isn't natural to use the weak currency as base.
And if you where in a multi-company situation, working in different
countries, you wouldn't be able to set the company's currency to base.

I think the precision on the rate is long enough, putting more decimals on
it would just slower calculations and increase the table size over time.

Please see my merge proposals attached to this bug. With 2 small changes I
got everything working. Now the voucher does the right calculations no
matter your currency configuration. I think this is a more permanent
solution.

If you find an error on my code let me know to fix it.

Thanks,
--
PS: escribí este email desde mi teléfono, por favor disculpe la brevedad y
cualquier error de escritura.

Carlos Vásquez
CTO · Director de Ingeniería
CLEARCORP S.A.

carlos.vasquez@xxxxxxxxxxxxxxx
CR: +(506) 4000-CORP (4000-2677)
US: +1 (786) 472-4267
Cel: +(506) 8351-4484
skype: crvasquez
twitter: cvclearcorp

300 m. Este de la Escuela
Calle de Platanares
11402 San Jerónimo, Moravia
San José, Costa Rica

http://www.clearcorp.co.cr

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/980967

Title:
  [6.1] [account_voucher] exchange rate calculation is not working if
  company currency isn't rate 1

Status in OpenERP Addons (modules):
  New

Bug description:
  In the account_voucher module, the currency rate is not well
  calculated. The method that write the account move line is not
  correct. It starts at line 227 in account_voucher.py:

      def _paid_amount_in_company_currency(self, cr, uid, ids, name, args, context=None):
          if not ids: return {}
          res = {}
          rate = 1.0
          for voucher in self.browse(cr, uid, ids, context=context):
              if voucher.currency_id:
                  if voucher.company_id.currency_id.id == voucher.payment_rate_currency_id.id:
                      rate =  1 / voucher.payment_rate
                  else:
                      ctx = context.copy()
                      ctx.update({'date': voucher.date})
                      voucher_rate = self.browse(cr, uid, voucher.id, context=ctx).currency_id.rate
                      company_currency_rate = voucher.company_id.currency_id.rate
                      rate = voucher_rate * company_currency_rate
              res[voucher.id] =  voucher.amount / rate
          return res

  This should be (diff output):

           for voucher in self.browse(cr, uid, ids, context=context):
               if voucher.currency_id:
                   if voucher.company_id.currency_id.id == voucher.payment_rate_currency_id.id:
  -                    rate =  1 / voucher.payment_rate
  +                    rate =  voucher.payment_rate
                   else:
                       ctx = context.copy()
                       ctx.update({'date': voucher.date})
                       voucher_rate = self.browse(cr, uid, voucher.id, context=ctx).currency_id.rate
                       company_currency_rate = voucher.company_id.currency_id.rate
  -                    rate = voucher_rate * company_currency_rate
  -            res[voucher.id] =  voucher.amount / rate
  +                    rate = company_currency_rate / voucher_rate
  +            res[voucher.id] =  voucher.amount * rate
           return res

  
  I am posting a merge proposal with this change in a couple of minutes.

  There is also a wrong currency_amount value calculation even if you
  apply the previous patch. This wrong calculation apply to only some
  lines of the move. I will get back on this bug about this later.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/980967/+subscriptions


References