Tryton - Issues

 

Message43846

Author rvong
Recipients Artem, ced, pokoli, roffez
Date 2018-09-12.22:18:28
Content
I got the same error as describe by roffez. The bug may be related how invoice payment is handled when paying with a foreign currency. I am using trytond from pypi version 4.8.3 and trytond_account_invoice version 4.8.1. I have put some logging code around the "if (abs(amount) > abs(invoice.amount_to_pay)" statement in line 2695 in the "transition_pay" function in class PayInvoice, and I have found that "amount" and "invoice.amount_to_pay" are in different currencies, which will then continues evaluating with the second condition of the if statement and "type" attribute is missing from the object account.invoice.pay.ask.

I don't know why "amount" and "invoice.amount_to_pay" are compared this way, but an easy way to replicate this error without modifying the code with logging statements is to play with the currencies setup:
CASE 1: 
1- Setup a company to work with a currency that has lower value than the currency used in the invoice.  For example, my company is using CRC (Costa Rican Currency) which has the rate of "1" (default currency) and the invoice is in USD with rate of 0.001724 (meaning every 0.001724 USD is equal to 1 CRC).
2- Setup the rates for the date to create the invoice
3- Create an invoice for 100 USD and post it.
4- Click on Pay button to pay the invoice
5- Leave the default amount which is 100 USD and select journal "CASH"
6- Click OK and the error popups.

CASE 2:
1- Setup the currency the other way around: Set the company to work with USD currency and the invoice in CRC. 
2- Setup the rates for the invoice date: "1" for USD and "580" for CRC. 
3- Create an invoice for 1000 CRC and post it
4- Click on Pay button 
5- Leave the default amount which is 1000 CRC
6- Click Ok and no errors.
History
Date User Action Args
2018-09-12 22:18:28rvongsetmessageid: <1536783508.65.0.246825674492.issue7192@tryton.org>
2018-09-12 22:18:28rvongsetrecipients: + ced, pokoli, roffez, Artem
2018-09-12 22:18:28rvonglinkissue7192 messages
2018-09-12 22:18:28rvongcreate

Showing 10 items. Show all history (warning: this could be VERY long)