diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml
index 65fb581619e..75c94a6eae6 100644
--- a/addons/account/test/account_fiscalyear_close.yml
+++ b/addons/account/test/account_fiscalyear_close.yml
@@ -75,5 +75,7 @@
-
I check that the past accounts are taken into account in partner credit
-
- !assert {model: res.partner, id: base.res_partner_2, string: Total Receivable does not takes unreconciled moves of previous years}:
- - credit == 1040.0
+ !python {model: res.partner}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('base.res_partner_2')).credit
+ assert float_compare(credit, 1040.0, precision_digits=2) == 0, "Total Receivable does not takes unreconciled moves of previous years"
diff --git a/addons/account/test/account_supplier_invoice.yml b/addons/account/test/account_supplier_invoice.yml
index a59ede03e4e..df4b99bc476 100644
--- a/addons/account/test/account_supplier_invoice.yml
+++ b/addons/account/test/account_supplier_invoice.yml
@@ -62,6 +62,7 @@
I verify that account move is created
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
move_obj = self.pool.get('account.move')
inv = self.browse(cr, uid, ref('account_invoice_supplier0'))
move = inv.move_id
@@ -73,7 +74,7 @@
amt_compute = move_obj._amount_compute(cr, uid, list(ids), 'amount', None, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')}, where ='')
move_amount = amt_compute.values()
- assert(inv.move_id and move.period_id.id == get_period and move_amount[0] == 3100.0), ('Journal Entries has not been created')
+ assert(inv.move_id and move.period_id.id == get_period and float_compare(move_amount[0], 3100.0, precision_digits=2) == 0), ('Journal Entries has not been created')
-
I cancel the account move which is in posted state and verifies that it gives warning message
-
@@ -92,5 +93,6 @@
I verify that 'Period Sum' and 'Year sum' of the tax code are the expected values
-
!python {model: account.tax.code}: |
+ from openerp.tools import float_compare
tax_code = self.browse(cr, uid, ref('tax_case'))
- assert(tax_code.sum_period == 100.0 and tax_code.sum == 100.0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum)
+ assert(float_compare(tax_code.sum_period, 100.0, precision_digits=2) == 0 and float_compare(tax_code.sum, 100.0, precision_digits=2) == 0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum)
diff --git a/addons/account/test/test_edi_invoice.yml b/addons/account/test/test_edi_invoice.yml
index 2225ae5ba9b..a0c3257d1b6 100644
--- a/addons/account/test/test_edi_invoice.yml
+++ b/addons/account/test/test_edi_invoice.yml
@@ -49,6 +49,7 @@
-
!python {model: account.invoice}: |
import time
+ from openerp.tools import float_compare
edi_document = {
"__id": "account:b33adf8a-decd-11f0-a4de-702a04e25700.random_invoice_763jsms",
"__module": "account",
@@ -141,14 +142,14 @@
for inv_line in invoice_new.invoice_line:
if inv_line.name == 'PC Assemble SC234':
assert inv_line.uos_id.name == "Unit" , "uom is not same"
- assert inv_line.price_unit == 10 , "price unit is not same"
- assert inv_line.quantity == 1 , "product qty is not same"
- assert inv_line.price_subtotal == 10, "price sub total is not same"
+ assert float_compare(inv_line.price_unit, 10, precision_digits=2) == 0, "price unit is not same"
+ assert float_compare(inv_line.quantity, 1, precision_digits=2) == 0, "product qty is not same"
+ assert float_compare(inv_line.price_subtotal, 10, precision_digits=2) == 0, "price sub total is not same"
elif inv_line.name == 'PC on Demand':
assert inv_line.uos_id.name == "Unit" , "uom is not same"
- assert inv_line.price_unit == 100 , "price unit is not same"
- assert inv_line.quantity == 5 , "product qty is not same"
- assert inv_line.price_subtotal == 500, "price sub total is not same"
+ assert float_compare(inv_line.price_unit, 100, precision_digits=2) == 0, "price unit is not same"
+ assert float_compare(inv_line.quantity, 5, precision_digits=2) == 0, "product qty is not same"
+ assert float_compare(inv_line.price_subtotal, 500, precision_digits=2) == 0, "price sub total is not same"
else:
raise AssertionError('unknown invoice line: %s' % inv_line)
for inv_tax in invoice_new.tax_line:
@@ -159,6 +160,7 @@
-
!python {model: account.invoice}: |
import time
+ from openerp.tools import float_compare
edi_document = {
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.random_invoice_763jsms",
"__module": "account",
@@ -249,14 +251,14 @@
for inv_line in invoice_new.invoice_line:
if inv_line.name == 'Basic PC':
assert inv_line.uos_id.name == "PCE" , "uom is not same"
- assert inv_line.price_unit == 10 , "price unit is not same"
- assert inv_line.quantity == 1 , "product qty is not same"
- assert inv_line.price_subtotal == 10, "price sub total is not same"
+ assert float_compare(inv_line.price_unit, 10, precision_digits=2) == 0, "price unit is not same"
+ assert float_compare(inv_line.quantity, 1, precision_digits=2) == 0, "product qty is not same"
+ assert float_compare(inv_line.price_subtotal, 10, precision_digits=2) == 0, "price sub total is not same"
elif inv_line.name == 'Medium PC':
assert inv_line.uos_id.name == "PCE" , "uom is not same"
- assert inv_line.price_unit == 100 , "price unit is not same"
- assert inv_line.quantity == 5 , "product qty is not same"
- assert inv_line.price_subtotal == 500, "price sub total is not same"
+ assert float_compare(inv_line.price_unit, 100, precision_digits=2) == 0, "price unit is not same"
+ assert float_compare(inv_line.quantity, 5, precision_digits=2) == 0, "product qty is not same"
+ assert float_compare(inv_line.price_subtotal, 500, precision_digits=2) == 0, "price sub total is not same"
else:
raise AssertionError('unknown invoice line: %s' % inv_line)
for inv_tax in invoice_new.tax_line:
diff --git a/addons/account_analytic_analysis/test/account_analytic_analysis.yml b/addons/account_analytic_analysis/test/account_analytic_analysis.yml
index 4f594b6bed3..ef4eced2b68 100644
--- a/addons/account_analytic_analysis/test/account_analytic_analysis.yml
+++ b/addons/account_analytic_analysis/test/account_analytic_analysis.yml
@@ -38,8 +38,9 @@
I test the generated invoice
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
aid = ref('account_analytic_analysis.contract_main')
ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context)
assert len(ids)>=1, 'No invoice created for the contract'
for invoice in self.browse(cr, uid, ids,context=context):
- assert invoice.amount_untaxed == 150.0, "The invoice total is different than 150!"
+ assert float_compare(invoice.amount_untaxed, 150.0, precision_digits=2) == 0, "The invoice total is different than 150!"
diff --git a/addons/account_anglo_saxon/test/anglo_saxon.yml b/addons/account_anglo_saxon/test/anglo_saxon.yml
index c98de7c47db..c5b4361240e 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon.yml
@@ -132,13 +132,17 @@
-
I check the Stock Interim account (Received) is credited successfully.
-
- !assert {model: account.account, id : account_anglo_stock_input, string : Stock Interim account (Received) is not credited successfully.}:
- - credit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_stock_input')).credit
+ float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not credited successfully."
-
I check the Stock valuation account is debited sucessfully.
-
- !assert {model: account.account, id : account_anglo_stock_valuation, string : Stock valuation account is not debited successfully.}:
- - debit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_stock_valuation')).debit
+ float_compare(debit, 9, precision_digits=2) == 0, "Stock valuation account is not debited successfully."
-
I Validate Invoice of Purchase Order.
-
@@ -148,18 +152,24 @@
-
I check the Stock Interim account (Received) is debited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_stock_input, string : Stock Interim account (Received) is not debited successfully.}:
- - debit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_stock_input')).debit
+ float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not debited successfully."
-
I check the Price difference creditor Account is debited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_price_difference, string : Price difference creditor Account is not debited successfully.}:
- - debit == 1
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_price_difference')).debit
+ float_compare(debit, 1, precision_digits=2) == 0, "Price difference creditor Account is not debited successfully."
-
I check Payable(creditor) Account is Credited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_payable, string : Payable(creditor) Account is not Credited successfully.}:
- - credit == 10
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_payable')).credit
+ float_compare(credit, 10, precision_digits=2) == 0, "Payable(creditor) Account is not Credited successfully."
-
I open the Invoice.
-
@@ -179,13 +189,17 @@
-
I check Payable(Creditors) Account is Debited sucessfully after invoice paid.
-
- !assert {model: account.account, id : account_anglo_payable, string : Payable(Creditors) Account is not Debited successfully.}:
- - debit == 10
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_payable')).debit
+ assert float_compare(debit, 10, precision_digits=2) == 0, "Payable(Creditors) Account is not Debited successfully."
-
I check Bank/Cash account is credited sucessfully after invoice paid.
-
- !assert {model: account.account, id : account_anglo_cash, string: Bank/Cash account is not credited successfully.}:
- - credit == 10
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_cash')).credit
+ float_compare(credit, 10, precision_digits=2) == 0, "Bank/Cash account is not credited successfully."
-
I create an Outgoing Picking order
-
@@ -225,13 +239,17 @@
-
I check Stock Interim account (Delivery) is debited successfully.
-
- !assert {model: account.account, id : account_anglo_stock_output, string : Stock Interim account (Delivery) is not debited successfully.}:
- - debit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_stock_output')).debit
+ float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not debited successfully."
-
I check the Stock valuation account is credited sucessfully.
-
- !assert {model: account.account, id : account_anglo_stock_valuation, string : Stock valuation account is not credited successfully.}:
- - credit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_stock_valuation')).credit
+ float_compare(credit, 9, precision_digits=2) == 0, "Stock valuation account is not credited successfully."
-
As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order.
-
@@ -256,23 +274,31 @@
-
I check Income Account is Credited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_income, string : Income Account is not Credited successfully.}:
- - credit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_income')).credit
+ float_compare(credit, 20, precision_digits=2) == 0, "Income Account is not Credited successfully."
-
I check Cost of goods sold account for debit.
-
- !assert {model: account.account, id : account_anglo_cogs, string : Cost of goods sale is not Debited successfully.}:
- - debit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_cogs')).debit
+ float_compare(debit, 9, precision_digits=2) == 0, "Cost of goods sale is not Debited successfully."
-
I check Stock Interim account (Delivery)
-
- !assert {model: account.account, id : account_anglo_stock_output, string : Stock Interim account (Delivery) is not credited successfully.}:
- - credit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_stock_output')).credit
+ float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not credited successfully."
-
I check Receivable(Debtor) Account for debit.
-
- !assert {model: account.account, id : account_anglo_receivable, string : Receivable(Debtors) Account is not Debited successfully.}:
- - debit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_receivable')).debit
+ float_compare(debit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Debited successfully."
-
I pay the invoice.
-
@@ -289,10 +315,14 @@
-
I check Receivable(Debtor) Account for credit.
-
- !assert {model: account.account, id : account_anglo_receivable, string : Receivable(Debtors) Account is not Credited successfully.}:
- - credit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_receivable')).credit
+ float_compare(credit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Credited successfully."
-
I check Bank/Cash account is debited sucessfully after invoice paid.
-
- !assert {model: account.account, id : account_anglo_cash, string: Bank/Cash account is not successfully credited.}:
- - debit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_cash')).debit
+ float_compare(debit, 20, precision_digits=2) == 0, "Bank/Cash account is not successfully credited."
diff --git a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
index 03442260295..3a89bfe60ba 100644
--- a/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
+++ b/addons/account_anglo_saxon/test/anglo_saxon_avg_fifo.yml
@@ -140,13 +140,17 @@
-
I check the Stock Interim account (Received) is credit successfully.
-
- !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not credited successfully.}:
- - credit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_stock_input_fifo')).credit
+ assert float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not credited successfully."
-
I check the Stock valuation account is debit sucessfully.
-
- !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not debited successfully.}:
- - debit == 9
+ !python {model: account.account, id}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_stock_valuation_fifo')).debit
+ assert float_compare(debit, 9, precision_digits=2) == 0, "Stock valuation account is not debited successfully."
-
I Validate Invoice of Purchase Order after having changed the price to 10.
-
@@ -158,18 +162,24 @@
-
I check the Stock Interim account (Received) is debited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_stock_input_fifo, string : Stock Interim account (Received) is not debited successfully.}:
- - debit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_stock_input_fifo')).debit
+ assert float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not debited successfully."
-
I check the Price difference creditor Account is debited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_price_difference_fifo, string : Price difference creditor Account is not debited successfully.}:
- - debit == 1
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_price_difference_fifo')).debit
+ assert float_compare(debit, 1, precision_digits=2) == 0, "Price difference creditor Account is not debited successfully."
-
I check Payable(creditor) Account is Credited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(creditor) Account is not Credited successfully.}:
- - credit == 10
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_payable_fifo')).credit
+ assert float_compare(credit, 10, precision_digits=2) == 0, "Payable(creditor) Account is not Credited successfully."
-
I pay the invoice.
-
@@ -182,13 +192,17 @@
-
I check Payable(Creditors) Account is Debited sucessfully after invoice paid.
-
- !assert {model: account.account, id : account_anglo_payable_fifo, string : Payable(Creditors) Account is not Debited successfully.}:
- - debit == 10
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_payable_fifo')).debit
+ assert float_compare(debit, 10, precision_digits=2) == 0, "Payable(Creditors) Account is not Debited successfully."
-
I check Bank/Cash account is credited sucessfully after invoice paid.
-
- !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not credited successfully.}:
- - credit == 10
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_cash_fifo')).credit
+ assert float_compare(credit, 10, precision_digits=2) == 0, "Bank/Cash account is not credited successfully."
-
I create an Outgoing Picking order
-
@@ -225,13 +239,17 @@
-
I check Stock Interim account (Delivery) is debited successfully.
-
- !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not debited successfully.}:
- - debit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_stock_output_fifo')).debit
+ assert float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not debited successfully."
-
I check the Stock valuation account is credited sucessfully.
-
- !assert {model: account.account, id : account_anglo_stock_valuation_fifo, string : Stock valuation account is not credited successfully.}:
- - credit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_stock_valuation_fifo')).credit
+ assert float_compare(credit, 9, precision_digits=2) == 0, "Stock valuation account is not credited successfully."
-
As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order.
-
@@ -261,23 +279,31 @@
-
I check Income Account is Credited sucessfully when Invoice validated.
-
- !assert {model: account.account, id : account_anglo_income_fifo, string : Income Account is not Credited successfully.}:
- - credit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_income_fifo')).credit
+ assert float_compare(credit, 20, precision_digits=2) == 0, "Income Account is not Credited successfully."
-
I check Cost of goods sold account for debit.
-
- !assert {model: account.account, id : account_anglo_cogs_fifo, string : Cost of goods sale is not Debited successfully.}:
- - debit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_cogs_fifo')).debit
+ assert float_compare(debit, 9, precision_digits=2) == 0, "Cost of goods sale is not Debited successfully."
-
I check Stock Interim account (Delivery)
-
- !assert {model: account.account, id : account_anglo_stock_output_fifo, string : Stock Interim account (Delivery) is not credited successfully.}:
- - credit == 9
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_stock_output_fifo')).credit
+ assert float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not credited successfully."
-
I check Receivable(Debtor) Account for debit.
-
- !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Debited successfully.}:
- - debit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_receivable_fifo')).debit
+ assert float_compare(debit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Debited successfully."
-
I pay the invoice.
-
@@ -294,10 +320,14 @@
-
I check Receivable(Debtor) Account for credit.
-
- !assert {model: account.account, id : account_anglo_receivable_fifo, string : Receivable(Debtors) Account is not Credited successfully.}:
- - credit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ credit = self.browse(cr, uid, ref('account_anglo_receivable_fifo')).credit
+ assert float_compare(credit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Credited successfully."
-
I check Bank/Cash account is debited sucessfully after invoice paid.
-
- !assert {model: account.account, id : account_anglo_cash_fifo, string: Bank/Cash account is not successfully credited.}:
- - debit == 20
+ !python {model: account.account}: |
+ from openerp.tools import float_compare
+ debit = self.browse(cr, uid, ref('account_anglo_cash_fifo')).debit
+ assert float_compare(debit, 20, precision_digits=2) == 0, "Bank/Cash account is not successfully credited."
diff --git a/addons/account_voucher/test/case1_usd_usd.yml b/addons/account_voucher/test/case1_usd_usd.yml
index 84ae118ab16..4c19c33eb5f 100644
--- a/addons/account_voucher/test/case1_usd_usd.yml
+++ b/addons/account_voucher/test/case1_usd_usd.yml
@@ -94,12 +94,13 @@
I check that first invoice move is correct for debtor account (debit - credit == 150.0)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 150.0, precision_digits=2) == 0), "Invoice move is not correct for debtors account"
-
I create the second invoice on 1st February for 100 USD
-
@@ -127,12 +128,13 @@
I check that second invoice move is correct for debtor account (debit - credit == 80)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is not correct for debtors account"
-
I set the context that will be used for the encoding of all the vouchers of this file
@@ -159,11 +161,12 @@
I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$>
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case1'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 200.00:
+ if float_compare(item.amount_unreconciled, 200.00, precision_digits=2) == 0:
data += [(item.id, 180.0)]
else:
data += [(item.id, 70.0)]
@@ -174,9 +177,10 @@
I check that writeoff amount computed is -10.0
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0"
+ assert (float_compare(voucher_id.writeoff_amount, -10.0, precision_digits=2) == 0), "Writeoff amount is not -10.0"
-
I confirm the voucher
-
@@ -201,39 +205,42 @@
I check that my write-off is correct. 9 debit and 10 amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -180.00:
- assert move_line.credit == 162.00, "Debtor account has wrong entry."
- elif move_line.amount_currency == -70.00:
- assert move_line.credit == 63.00, "Debtor account has wrong entry."
- elif move_line.amount_currency == 10.00:
- assert move_line.debit == 9.00, "Writeoff amount is wrong."
- elif move_line.amount_currency == 240.00:
- assert move_line.debit == 216.00, "Bank entry is wrong."
+ if float_compare(move_line.amount_currency, -180.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 162.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, -70.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 63.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, 10.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 9.00, precision_digits=2) == 0, "Writeoff amount is wrong."
+ elif float_compare(move_line.amount_currency, 240.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 216.00, precision_digits=2) == 0, "Bank entry is wrong."
else:
assert False, "Unrecognized journal entry"
-
I check the residual amount of Invoice1, should be 20 in amount_currency
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 20.0) , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 20.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
-
I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 30.0) , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 30.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
-
On the first April, I create the second voucher of payment with values 45 USD, journal USD,
-
@@ -253,11 +260,12 @@
I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_2_case1'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 20.00:
+ if float_compare(item.amount_unreconciled, 20.00, precision_digits=2) == 0:
data += [(item.id, 20.0)]
else:
data += [(item.id, 30.0)]
@@ -268,9 +276,10 @@
I check that writeoff amount computed is -5.0
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.writeoff_amount == -5.0), "Writeoff amount is not -5.0"
+ assert (float_compare(voucher_id.writeoff_amount, -5.0, precision_digits=2) == 0), "Writeoff amount is not -5.0"
-
I confirm the voucher
-
@@ -299,52 +308,55 @@
I check that my writeoff is correct. 4.75 debit and 5 amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
reconcile_a = reconcile_b = False
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -20.00:
+ if float_compare(move_line.amount_currency, -20.00, precision_digits=2) == 0:
assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled"
reconcile_b = move_line.reconcile_id.id
- elif move_line.amount_currency == -30.00:
+ elif float_compare(move_line.amount_currency, -30.00, precision_digits=2) == 0:
assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled"
reconcile_a = move_line.reconcile_id.id
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -20.00:
- assert move_line.credit == 19.00, "Debtor account has wrong entry."
- elif move_line.amount_currency == -30.00:
- assert move_line.credit == 28.50, "Debtor account has wrong entry."
- elif move_line.amount_currency == 5.00:
- assert move_line.debit == 4.75, "Writeoff amount is wrong."
- elif move_line.debit == 11.5 and move_line.account_id.reconcile:
- assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_a, "Exchange difference entry for the invoice of 100$ is wrong"
- elif move_line.credit == 11.5:
- assert move_line.amount_currency == 0.0
- elif move_line.debit == 31.0 and move_line.account_id.reconcile:
- assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_b, "Exchange difference entry for the invoice of 200$ is wrong"
- elif move_line.credit == 31.0:
- assert move_line.amount_currency == 0.0
- elif move_line.amount_currency == 45.00:
- assert move_line.debit == 42.75, "Bank entry is wrong."
+ if float_compare(move_line.amount_currency, -20.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 19.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, -30.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 28.50, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, 5.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 4.75, precision_digits=2) == 0, "Writeoff amount is wrong."
+ elif float_compare(move_line.debit, 11.5, precision_digits=2) == 0 and move_line.account_id.reconcile:
+ assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_a, "Exchange difference entry for the invoice of 100$ is wrong"
+ elif float_compare(move_line.credit, 11.5, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0
+ elif float_compare(move_line.debit, 31.0, precision_digits=2) == 0 and move_line.account_id.reconcile:
+ assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_b, "Exchange difference entry for the invoice of 200$ is wrong"
+ elif float_compare(move_line.credit, 31.0, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0
+ elif float_compare(move_line.amount_currency, 45.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 42.75, precision_digits=2) == 0, "Bank entry is wrong."
else:
assert False, "Unrecognized journal entry"
-
I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
-
I check the residual amuont of Invoice2, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
diff --git a/addons/account_voucher/test/case1_usd_usd_payment_rate.yml b/addons/account_voucher/test/case1_usd_usd_payment_rate.yml
index c0aa617783c..7f5cf15284d 100644
--- a/addons/account_voucher/test/case1_usd_usd_payment_rate.yml
+++ b/addons/account_voucher/test/case1_usd_usd_payment_rate.yml
@@ -101,12 +101,13 @@
I check that first invoice move is correct for debtor account (debit - credit == 150.0)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_jan_payment_rate"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 150.0, precision_digits=2) == 0), "Invoice move is not correct for debtors account"
-
I create the second invoice on 1st February for 100 USD
-
@@ -134,12 +135,13 @@
I check that second invoice move is correct for debtor account (debit - credit == 80)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_feb_payment_rate"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is not correct for debtors account"
-
I set the context that will be used for the encoding of all the vouchers of this file
@@ -168,11 +170,12 @@
I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$>
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case1_payment_rate'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 200.00:
+ if float_compare(item.amount_unreconciled, 200.00, precision_digits=2) == 0:
data += [(item.id, 180.0)]
else:
data += [(item.id, 70.0)]
@@ -183,9 +186,10 @@
I check that writeoff amount computed is -10.0
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = ref('account_voucher_1_case1_payment_rate')
voucher_id = self.browse(cr, uid, voucher)
- assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0"
+ assert (float_compare(voucher_id.writeoff_amount, -10.0, precision_digits=2) == 0), "Writeoff amount is not -10.0"
-
I confirm the voucher
-
@@ -210,38 +214,41 @@
I check that my write-off is correct. 8 debit and 10 amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = ref('account_voucher_1_case1_payment_rate')
voucher_id = self.browse(cr, uid, voucher)
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -180.00:
- assert move_line.credit == 144.00, "Debtor account has wrong entry."
- elif move_line.amount_currency == -70.00:
- assert move_line.credit == 56.00, "Debtor account has wrong entry."
- elif move_line.amount_currency == 10.00:
- assert move_line.debit == 8.00, "Writeoff amount is wrong: Got a debit of %s (expected 8,00€)" % (move_line.debit)
- elif move_line.amount_currency == 240.00:
- assert move_line.debit == 192.00, "Bank entry is wrong."
+ if float_compare(move_line.amount_currency, -180.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 144.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, -70.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 56.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, 10.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 8.00, precision_digits=2) == 0, "Writeoff amount is wrong: Got a debit of %s (expected 8,00€)" % (move_line.debit)
+ elif float_compare(move_line.amount_currency, 240.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 192.00, precision_digits=2) == 0, "Bank entry is wrong."
else:
assert False, "Unrecognized journal entry"
-
I check the residual amount of Invoice1, should be 20 in amount_currency and 6 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_jan_payment_rate"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual == 6.0) , "Residual amount is not correct for first Invoice"
- assert (move_line.amount_residual_currency == 20.0) , "Residual amount in currency is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual, 6.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 20.0, precision_digits=2) == 0) , "Residual amount in currency is not correct for first Invoice"
-
I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_feb_payment_rate"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual == 24.0) , "Residual amount is not correct for second Invoice"
- assert (move_line.amount_residual_currency == 30.0) , "Residual amount in currency is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual, 24.0, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 30.0, precision_digits=2) == 0) , "Residual amount in currency is not correct for second Invoice"
diff --git a/addons/account_voucher/test/case2_suppl_usd_eur.yml b/addons/account_voucher/test/case2_suppl_usd_eur.yml
index 836bee35d30..79870aea12d 100644
--- a/addons/account_voucher/test/case2_suppl_usd_eur.yml
+++ b/addons/account_voucher/test/case2_suppl_usd_eur.yml
@@ -65,12 +65,13 @@
I check that first invoice move is correct for debtor account(debit - credit == -150)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == -150.00), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, -150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I create the second invoice on 1st February for 100 USD
-
@@ -100,12 +101,13 @@
I check that second invoice move is correct for debtor account (debit - credit == -80)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == -80), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, -80, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I set the context that will be used for the encoding of all the vouchers of this file
-
@@ -131,11 +133,12 @@
I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2_suppl'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 200.00:
+ if float_compare(item.amount_unreconciled, 200.00, precision_digits=2) == 0:
data += [(item.id, 180.0)]
else:
data += [(item.id, 70.0)]
@@ -146,16 +149,18 @@
I check that writeoff amount computed is -15.0
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.writeoff_amount == -15.0), "Writeoff amount is not -15.0"
+ assert (float_compare(voucher_id.writeoff_amount, -15.0, precision_digits=2) == 0), "Writeoff amount is not -15.0"
-
I check that currency rate difference is 34.0
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.currency_rate_difference == 34.0), "Currency rate difference is not 34.0"
+ assert (float_compare(voucher_id.currency_rate_difference, 34.0, precision_digits=2) == 0), "Currency rate difference is not 34.0"
-
I confirm the voucher
-
@@ -182,37 +187,40 @@
I check that my writeoff is correct. -15 in credit with no amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == 180.00:
- assert move_line.debit == 135.00, "Creditor account has wrong entry."
- elif move_line.amount_currency == 70.00:
- assert move_line.debit == 56.00, "Debtor account has wrong entry."
- elif move_line.debit == 34.00:
- assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
- elif move_line.debit == 15.00:
- assert move_line.amount_currency == 0.00, "Writeoff amount is wrong."
+ if float_compare(move_line.amount_currency, 180.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 135.00, precision_digits=2) == 0, "Creditor account has wrong entry."
+ elif float_compare(move_line.amount_currency, 70.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 56.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.debit, 34.00, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Incorrect Currency Difference."
+ elif float_compare(move_line.debit, 15.00, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Writeoff amount is wrong."
-
I check the residual amount of Invoice1, should be 20 in residual currency and 15 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 20.0 and move_line.amount_residual == 15) , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 20.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 15, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
-
I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 30 and move_line.amount_residual == 24) , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 30, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 24, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"
-
I create the second voucher of payment with values 45 USD, journal USD,
-
@@ -233,11 +241,12 @@
I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2_suppl'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 20.00:
+ if float_compare(item.amount_unreconciled, 20.00, precision_digits=2) == 0:
data += [(item.id, 20.0)]
else:
data += [(item.id, 30.0)]
@@ -248,16 +257,18 @@
I check that writeoff amount computed is -5.0
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.writeoff_amount == 5.0), "Writeoff amount is not 5.0"
+ assert (float_compare(voucher_id.writeoff_amount, 5.0, precision_digits=2) == 0), "Writeoff amount is not 5.0"
-
I check that currency rate difference is 8.50
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.currency_rate_difference == 8.50), "Currency rate difference is not 8.50"
+ assert (float_compare(voucher_id.currency_rate_difference, 8.50, precision_digits=2) == 0), "Currency rate difference is not 8.50"
-
I confirm the voucher
-
@@ -281,34 +292,37 @@
I check that my writeoff is correct. 4.75 in credit and 5 in amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == 20.00:
- assert move_line.debit == 15.00, "Debtor account has wrong entry."
- elif move_line.amount_currency == 30.00:
- assert move_line.debit == 24.00, "Debtor account has wrong entry."
- elif move_line.debit == 8.50:
- assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
- elif move_line.amount_currency == -5.00:
- assert move_line.credit == 4.75, "Writeoff amount is wrong."
+ if float_compare(move_line.amount_currency, 20.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 15.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, 30.00, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 24.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.debit, 8.50, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Incorrect Currency Difference."
+ elif float_compare(move_line.amount_currency, -5.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 4.75, precision_digits=2) == 0, "Writeoff amount is wrong."
-
I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
-
I check the residual amount of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
diff --git a/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml b/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml
index 45c86eb7ad0..0eb71d66d4d 100644
--- a/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml
+++ b/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml
@@ -99,12 +99,13 @@
I check that first invoice move is correct for debtor account(debit - credit == 150)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I create the second invoice on 1st February for 100 USD
-
@@ -132,12 +133,13 @@
I check that second invoice move is correct for debtor account (debit - credit == 80)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I set the context that will be used for the encoding of all the vouchers of this file
-
@@ -163,13 +165,14 @@
I fill amounts 130 for the invoice of 200$ and 70 for the invoice of 100$
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
import time
from openerp import netsvc
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2a'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 150.00:
+ if float_compare(item.amount_unreconciled, 150.00, precision_digits=2) == 0:
data += [(item.id, 130.0)]
else:
data += [(item.id, 70.0)]
@@ -197,20 +200,22 @@
I check the residual amount of Invoice1, should be 55.56 in residual currency and 20 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 55.56 and move_line.amount_residual == 20) , "Residual amount is not correct for first Invoice. Got %s USD (%s EUR)" %(move_line.amount_residual_currency, move_line.amount_residual)
+ assert (float_compare(move_line.amount_residual_currency, 55.56, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 20, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice. Got %s USD (%s EUR)" %(move_line.amount_residual_currency, move_line.amount_residual)
-
I check the residual amuont of Invoice2, should be 22.22 in residual currency and 10 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 22.22 and move_line.amount_residual == 10) , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 22.22, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 10, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"
-
I create the second voucher of payment with values 80 USD, journal USD
-
@@ -233,11 +238,12 @@
!python {model: account.voucher}: |
import time
from openerp import netsvc
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2a'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 55.56:
+ if float_compare(item.amount_unreconciled, 55.56, precision_digits=2) == 0:
data += [(item.id, 55.56)]
else:
data += [(item.id, 22.22)]
@@ -248,9 +254,10 @@
I check that writeoff amount computed is 2.22
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (round(voucher_id.writeoff_amount, 2) == 2.22), "Writeoff amount is not 2.22$"
+ assert (float_compare(round(voucher_id.writeoff_amount, 2), 2.22, precision_digits=2) == 0), "Writeoff amount is not 2.22$"
-
I confirm the voucher
-
@@ -275,44 +282,47 @@
I check that my writeoff is correct. 2.11 in credit and 2.22 in amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
reconcile_a = reconcile_b = False
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -22.22:
+ if float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0:
assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled"
reconcile_b = move_line.reconcile_id.id
- elif move_line.amount_currency == -55.56:
+ elif float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0:
assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled"
reconcile_a = move_line.reconcile_id.id
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -55.56:
- assert move_line.credit == 52.78, "Debtor account has wrong entry."
- elif move_line.amount_currency == -22.22:
- assert move_line.credit == 21.11, "Debtor account has wrong entry."
- elif move_line.credit == 11.11 and move_line.account_id.reconcile:
- assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference."
- elif move_line.credit == 32.78 and move_line.account_id.reconcile:
- assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference."
- elif move_line.amount_currency == 2.22:
- assert move_line.credit == 2.11, "Writeoff amount is wrong."
+ if float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 52.78, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 21.11, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.credit, 11.11, precision_digits=2) == 0 and move_line.account_id.reconcile:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference."
+ elif float_compare(move_line.credit, 32.78, precision_digits=2) == 0 and move_line.account_id.reconcile:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference."
+ elif float_compare(move_line.amount_currency, 2.22, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 2.11, precision_digits=2) == 0, "Writeoff amount is wrong."
-
I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
-
I check the residual amuont of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
diff --git a/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml b/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml
index f353cd8c6fc..12d6f07b33a 100644
--- a/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml
+++ b/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml
@@ -99,12 +99,13 @@
I check that first invoice move is correct for debtor account(debit - credit == 150)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I create the second invoice on 1st February for 100 USD
-
@@ -132,12 +133,13 @@
I check that second invoice move is correct for debtor account (debit - credit == 80)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 80, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I set the context that will be used for the encoding of all the vouchers of this file
-
@@ -163,11 +165,12 @@
I fill amounts 130 for the invoice of 200$ and 70 for the invoice of 100$>
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2b'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 150.00:
+ if float_compare(item.amount_unreconciled, 150.00, precision_digits=2) == 0:
data += [(item.id, 130.0)]
else:
data += [(item.id, 70.0)]
@@ -196,33 +199,36 @@
I check that the debtor account has 2 new lines with 144.44 and 77.78 in amount_currency columns and their credit columns are 130 and 70
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.credit == 70.0:
- assert move_line.amount_currency == -77.78, "Wrong debtor entry"
- if move_line.credit == 130.0:
- assert move_line.amount_currency == -144.44, "Wrong debtor entry"
+ if float_compare(move_line.credit, 70.0, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, -77.78, precision_digits=2) == 0, "Wrong debtor entry"
+ if float_compare(move_line.credit, 130.0, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, -144.44, precision_digits=2) == 0, "Wrong debtor entry"
-
I check the residual amount of Invoice1, should be 55.56 in residual currency and 20 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 55.56 and move_line.amount_residual == 20) , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 55.56, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 20, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
-
I check the residual amount of Invoice2, should be 22.22 in residual currency and 10 in amount_residual
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 22.22 and move_line.amount_residual == 10) , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 22.22, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 10, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"
-
I create the second voucher of payment with values 80 USD, journal USD
-
@@ -243,11 +249,12 @@
and I fully reconcil the 2 previous invoices
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2b'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 55.56:
+ if float_compare(item.amount_unreconciled, 55.56, precision_digits=2) == 0:
data += [(item.id, 55.56)]
else:
data += [(item.id, 22.22)]
@@ -258,9 +265,10 @@
I check that writeoff amount computed is 2.22
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (round(voucher_id.writeoff_amount, 2) == 2.22), "Writeoff amount is not 2.22$"
+ assert (float_compare(round(voucher_id.writeoff_amount, 2), 2.22, precision_digits=2) == 0), "Writeoff amount is not 2.22$"
-
I confirm the voucher
-
@@ -284,44 +292,47 @@
I check that my writeoff is correct. 2.11 in credit and 2.22 in amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
reconcile_a = reconcile_b = False
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -22.22:
+ if float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0:
assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled"
reconcile_b = move_line.reconcile_id.id
- elif move_line.amount_currency == -55.56:
+ elif float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0:
assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled"
reconcile_a = move_line.reconcile_id.id
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.amount_currency == -55.56:
- assert move_line.credit == 52.78, "Debtor account has wrong entry."
- elif move_line.amount_currency == -22.22:
- assert move_line.credit == 21.11, "Debtor account has wrong entry."
- elif move_line.credit == 11.11 and move_line.account_id.reconcile:
- assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference."
- elif move_line.credit == 32.78 and move_line.account_id.reconcile:
- assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference."
- elif move_line.amount_currency == 2.22:
- assert move_line.credit == 2.11, "Writeoff amount is wrong."
+ if float_compare(move_line.amount_currency, -55.56, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 52.78, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.amount_currency, -22.22, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 21.11, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.credit, 11.11, precision_digits=2) == 0 and move_line.account_id.reconcile:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference."
+ elif float_compare(move_line.credit, 32.78, precision_digits=2) == 0 and move_line.account_id.reconcile:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference."
+ elif float_compare(move_line.amount_currency, 2.22, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 2.11, precision_digits=2) == 0, "Writeoff amount is wrong."
-
I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
-
I check the residual amount of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"
diff --git a/addons/account_voucher/test/case3_eur_eur.yml b/addons/account_voucher/test/case3_eur_eur.yml
index 064b79ed305..6c48c2e2136 100644
--- a/addons/account_voucher/test/case3_eur_eur.yml
+++ b/addons/account_voucher/test/case3_eur_eur.yml
@@ -54,12 +54,13 @@
I check that first invoice move is correct for debtor account(debit - credit == 150)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 150.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I create the second invoice on 1st February for 80 EUR
-
@@ -87,12 +88,13 @@
I check that second invoice move is correct for debtor account (debit - credit == 80)
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
assert invoice_id.move_id, "Move not created for open invoice"
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.debit - move_line.credit == 80.00), "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 80.00, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I set the context that will be used for the encoding of all the vouchers of this file
-
@@ -118,11 +120,12 @@
I fill amounts 100 for the invoice of 150€ and 20 for the invoice of 80€
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case3'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 150.00:
+ if float_compare(item.amount_unreconciled, 150.00, precision_digits=2) == 0:
data += [(item.id, 100.0)]
else:
data += [(item.id, 20.0)]
@@ -133,9 +136,10 @@
I check that writeoff amount computed is 0.00
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0.00"
+ assert (float_compare(voucher_id.writeoff_amount, 0.00, precision_digits=2) == 0), "Writeoff amount is not 0.00"
-
I confirm the voucher
-
@@ -158,33 +162,36 @@
I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 20 and 100 respectively
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.credit == 20.00:
- assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
- elif move_line.credit == 100.00:
- assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
+ if float_compare(move_line.credit, 20.00, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.credit, 100.00, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
-
I check the residual amount of Invoice1 is 50
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 50.0 and move_line.amount_residual == 50.0) , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 50.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 50.0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
-
I check the residual amuont of Invoice2 is 60
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 60.0 and move_line.amount_residual == 60.0) , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 60.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 60.0, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"
-
I create the second voucher of payment with values 120€, journal EUR, and check to let open the debtor overpaid amount
-
@@ -205,13 +212,14 @@
I fill amounts 50 for the invoice of 150€ and 70 for the invoice of 80€
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_2_case3'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 50.00:
+ if float_compare(item.amount_unreconciled, 50.00, precision_digits=2) == 0:
data += [(item.id, 50.0)]
- elif item.amount_unreconciled == 60.00:
+ elif float_compare(item.amount_unreconciled, 60.00, precision_digits=2) == 0:
data += [(item.id, 70.00)]
for line_id, amount in data:
self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
@@ -220,9 +228,10 @@
I check that writeoff amount computed is 0.00
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0"
+ assert (float_compare(voucher_id.writeoff_amount, 0.00, precision_digits=2) == 0), "Writeoff amount is not 0"
-
I confirm the voucher
-
@@ -246,30 +255,33 @@
I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 70 and 50
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if move_line.credit == 70.00:
- assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
- elif move_line.credit == 50.00:
- assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
+ if float_compare(move_line.credit, 70.00, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.credit, 50.00, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Debtor account has wrong entry."
-
I check the residual amount of Invoice1 is 0
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0 and move_line.amount_residual == 0) , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0, precision_digits=2) == 0) , "Residual amount is not correct for first Invoice"
-
I check the residual amuont of Invoice2 is -10
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == -10.0 and move_line.amount_residual == -10.0) , "Residual amount is not correct for second Invoice"
+ assert (float_compare(move_line.amount_residual_currency, -10.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, -10.0, precision_digits=2) == 0) , "Residual amount is not correct for second Invoice"
diff --git a/addons/account_voucher/test/case4_cad_chf.yml b/addons/account_voucher/test/case4_cad_chf.yml
index 476a22c3f15..e31dd5783c0 100644
--- a/addons/account_voucher/test/case4_cad_chf.yml
+++ b/addons/account_voucher/test/case4_cad_chf.yml
@@ -94,7 +94,7 @@
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert float_compare(move_line.debit - move_line.credit, 149.39, 2) == 0, "Invoice move is incorrect for debtors account"
+ assert (float_compare(move_line.debit - move_line.credit, 149.39, precision_digits=2) == 0), "Invoice move is incorrect for debtors account"
-
I set the context that will be used for the encoding of all the vouchers of this file
-
@@ -121,11 +121,12 @@
!python {model: account.voucher}: |
import time
from openerp import netsvc
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_1_case4'))
data = []
for item in voucher_id.line_cr_ids:
- if item.amount_unreconciled == 186.74:
+ if float_compare(item.amount_unreconciled, 186.74, precision_digits=2) == 0:
data += [(item.id, 186.74)]
else:
data += [(item.id, 0.0)]
@@ -136,9 +137,10 @@
I check that writeoff amount computed is 13.26
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))])
voucher_id = self.browse(cr, uid, voucher[0])
- assert (round(voucher_id.writeoff_amount,2) == 13.26), "Writeoff amount is not 13.26 CHF"
+ assert (float_compare(round(voucher_id.writeoff_amount,2), 13.26, precision_digits=2) == 0), "Writeoff amount is not 13.26 CHF"
-
I confirm the voucher
-
@@ -174,23 +176,24 @@
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
assert move_lines, "Voucher move has no lines"
for move_line in move_line_obj.browse(cr, uid, move_lines):
- if float_compare(move_line.amount_currency, 200, 2) == 0:
- assert float_compare(move_line.debit, 160.00, 2) == 0, "Bank account has wrong entry."
- elif float_compare(move_line.amount_currency, -298.78, 2) == 0:
- assert float_compare(move_line.credit, 149.39, 2) == 0, "Debtor account has wrong entry."
- elif move_line.debit == 0.00 and move_line.credit == 0.00:
- assert move_line.amount_currency == 98.78, "Incorrect Currency Difference, got %s as amount_currency (expected 98.78)." % (move_line.amount_currency)
+ if float_compare(move_line.amount_currency, 200, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 160.00, precision_digits=2) == 0, "Bank account has wrong entry."
+ elif float_compare(move_line.amount_currency, -298.78, precision_digits=2) == 0 :
+ assert float_compare(move_line.credit, 149.39, precision_digits=2) == 0, "Debtor account has wrong entry."
+ elif float_compare(move_line.debit, 0.00, precision_digits=2) == 0 and float_compare(move_line.credit, 0.00, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 98.78, precision_digits=2) == 0, "Incorrect Currency Difference, got %s as amount_currency (expected 98.78)." % (move_line.amount_currency)
assert move_line.currency_id.id == ref('base.CAD'), "Incorrect Currency Difference, got %s (expected 'CAD')" % (move_line.currency_id.name)
- elif move_line.credit == 10.61:
- assert move_line.amount_currency == -13.26, "Writeoff amount is wrong."
+ elif float_compare(move_line.credit, 10.61, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, -13.26, precision_digits=2) == 0, "Writeoff amount is wrong."
else:
assert False, "Wrong entry"
-
I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
diff --git a/addons/account_voucher/test/case5_suppl_usd_usd.yml b/addons/account_voucher/test/case5_suppl_usd_usd.yml
index c20d07a8192..327cd9de25c 100644
--- a/addons/account_voucher/test/case5_suppl_usd_usd.yml
+++ b/addons/account_voucher/test/case5_suppl_usd_usd.yml
@@ -16,14 +16,14 @@
-
!record {model: res.currency.rate, id: nov_usd}:
currency_id: base.USD
- name: !eval "'%s-11-01 00:00:00' %(datetime.now().year)"
+ name: !eval "'%s-11-01' %(datetime.now().year)"
rate: 1.8
-
I create currency USD in OpenERP for December of 1.5 Rate
-
!record {model: res.currency.rate, id: dec_usd}:
currency_id: base.USD
- name: !eval "'%s-12-01 00:00:00' %(datetime.now().year)"
+ name: !eval "'%s-12-01' %(datetime.now().year)"
rate: 1.5
-
I set the income and expense currency accounts on the main company
@@ -98,10 +98,8 @@
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert float_compare(move_line.debit - move_line.credit, -555.56, 2) == 0, \
- "Invoice move is incorrect for creditor account"
- assert float_compare(move_line.amount_currency, -1000, 2) == 0, \
- "Amount currency is incorrect for creditor account"
+ assert (float_compare(move_line.debit - move_line.credit, -555.56, precision_digits=2) == 0), "Invoice move is incorrect for creditor account"
+ assert (float_compare(move_line.amount_currency, -1000, precision_digits=2) == 0), "Amount currency is incorrect for creditor account"
-
I set the context that will be used for the encoding of all the vouchers of this file
-
@@ -128,17 +126,20 @@
-
!python {model: account.voucher}: |
import time
+ from openerp.tools import float_compare
vals = {}
voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow'))
for item in voucher_id.line_dr_ids:
- if item.amount_unreconciled == 1000.00:
+ if float_compare(item.amount_unreconciled, 1000.00, precision_digits=2) == 0:
self.pool.get('account.voucher.line').write(cr, uid, [item.id], {'amount': 1000})
assert (voucher_id.state=='draft'), "Voucher is not in draft state"
-
I check that writeoff amount computed is -50.0
-
- !assert {model: account.voucher, id: account_voucher_case_5_supplier_flow}:
- - writeoff_amount == -50.0
+ !python {model: account.voucher}: |
+ from openerp.tools import float_compare
+ writeoff_amount = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow')).writeoff_amount
+ assert float_compare(writeoff_amount, -50.0, precision_digits=2) == 0
-
I confirm the voucher
-
@@ -163,24 +164,26 @@
I check that my writeoff is correct. 33.34€ in credit with -$50 as amount currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow'))
for move_line in voucher_id.move_id.line_id:
- if move_line.amount_currency == -950.00:
- assert move_line.credit == 633.33, "Wrong bank entry."
- elif move_line.credit == 111.11 or move_line.debit == 111.11:
- assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
- elif move_line.credit == 33.34:
- assert move_line.amount_currency == -50.0, "Writeoff amount is wrong."
- elif move_line.debit == 666.67:
- assert move_line.amount_currency == 1000.0, "Wrong supplier entry."
+ if float_compare(move_line.amount_currency, -950.00, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 633.33, precision_digits=2) == 0, "Wrong bank entry."
+ elif float_compare(move_line.credit, 111.11, precision_digits=2) == 0 or float_compare(move_line.debit, 111.11, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 0.00, precision_digits=2) == 0, "Incorrect Currency Difference."
+ elif float_compare(move_line.credit, 33.34, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, -50.0, precision_digits=2) == 0, "Writeoff amount is wrong."
+ elif float_compare(move_line.debit, 666.67, precision_digits=2) == 0:
+ assert float_compare(move_line.amount_currency, 1000.0, precision_digits=2) == 0, "Wrong supplier entry."
else:
assert False, "Wrong entry. Unrecognized account move line"
-
I check the residual amount of invoice, it should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_supplier_invoice_november"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for supplier invoice"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for supplier invoice"
diff --git a/addons/account_voucher/test/case_eur_usd.yml b/addons/account_voucher/test/case_eur_usd.yml
index 69304c342c9..ce2b71d7ac0 100644
--- a/addons/account_voucher/test/case_eur_usd.yml
+++ b/addons/account_voucher/test/case_eur_usd.yml
@@ -102,10 +102,11 @@
I fill amount 1400 for the invoice of 1400$
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
data = []
voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
for item in voucher.line_cr_ids:
- if item.amount_unreconciled == 1400:
+ if float_compare(item.amount_unreconciled, 1400, precision_digits=2) == 0:
data += [(item.id, 1400)]
assert data, "Credit line not found"
for line_id, amount in data:
@@ -115,8 +116,9 @@
I check that writeoff amount computed is -50.0
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
- assert (voucher.writeoff_amount == -50.0), "Writeoff amount is not -50.0"
+ assert (float_compare(voucher.writeoff_amount, -50.0, precision_digits=2) == 0), "Writeoff amount is not -50.0"
-
I confirm the voucher
-
@@ -148,14 +150,15 @@
I check that my bank account is correct. 964.29 debit and 1350 amount_currency
-
!python {model: account.voucher}: |
+ from openerp.tools import float_compare
voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
for move_line in voucher.move_ids:
- if move_line.amount_currency == 1350:
- assert move_line.debit == 964.29,"debtor account is not correct"
- if move_line.amount_currency == 50:
- assert move_line.debit == 35.71,"write off bank account is not correct"
- if move_line.amount_currency == 0.0:
- assert move_line.credit == 1000,"total reconcile is not correct of invoice"
+ if float_compare(move_line.amount_currency, 1350, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 964.29, precision_digits=2) == 0,"debtor account is not correct"
+ if float_compare(move_line.amount_currency, 50, precision_digits=2) == 0:
+ assert float_compare(move_line.debit, 35.71, precision_digits=2) == 0,"write off bank account is not correct"
+ if float_compare(move_line.amount_currency, 0.0, precision_digits=2) == 0:
+ assert float_compare(move_line.credit, 1000, precision_digits=2) == 0,"total reconcile is not correct of invoice"
-
I check that the move of payment in invoice is valid
-
@@ -167,10 +170,9 @@
I check the residual amount of invoice should be 0 in residual currency and 0 in amount_residual and paid
-
!python {model: account.invoice}: |
+ from openerp.tools import float_compare
invoice_id = self.browse(cr, uid, ref("account_invoice_eur_usd"))
move_line_obj = self.pool.get('account.move.line')
move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
move_line = move_line_obj.browse(cr, uid, move_lines[0])
- assert move_line.amount_residual_currency == 0.0, "Residual amount is not correct for Invoice"
- assert move_line.amount_residual == 0.0, "Residual amount is not correct for Invoice"
- assert invoice_id.state == 'paid', "Invoice is not paid"
+ assert (float_compare(move_line.amount_residual_currency, 0.0, precision_digits=2) == 0 and float_compare(move_line.amount_residual, 0.0, precision_digits=2) == 0 and invoice_id.state == 'paid') , "Residual amount is not correct for Invoice"
diff --git a/addons/delivery/test/delivery_cost.yml b/addons/delivery/test/delivery_cost.yml
index efa22ca5df7..e20d89e91e9 100644
--- a/addons/delivery/test/delivery_cost.yml
+++ b/addons/delivery/test/delivery_cost.yml
@@ -28,10 +28,11 @@
I check sale order after added delivery cost.
-
!python {model: sale.order.line}: |
+ from openerp.tools import float_compare
line_ids = self.search(cr, uid, [('order_id','=', ref('sale_normal_delivery_charges')), ('product_id','=', ref('product_product_delivery'))])
assert len(line_ids), "Delivery cost is not Added"
line_data = self.browse(cr ,uid ,line_ids[0] ,context)
- assert line_data.price_subtotal == 10, "Delivey cost is not correspond."
+ assert float_compare(line_data.price_subtotal, 10, precision_digits=2) == 0, "Delivey cost is not correspond."
-
I confirm the sale order.
-
@@ -79,10 +80,11 @@
I check sale order after added delivery cost.
-
!python {model: sale.order.line}: |
+ from openerp.tools import float_compare
line_ids = self.search(cr, uid, [('order_id','=', ref('sale_free_delivery_charges')), ('product_id','=', ref('product_product_delivery'))])
assert len(line_ids), "Delivery cost is not Added"
line_data = self.browse(cr ,uid ,line_ids[0] ,context)
- assert line_data.price_subtotal == 0, "Delivey cost is not correspond."
+ assert float_compare(line_data.price_subtotal, 0, precision_digits=2) == 0, "Delivey cost is not correspond."
-
I set default delivery policy.
@@ -91,4 +93,4 @@
{}
-
!python {model: sale.config.settings}: |
- self.execute(cr, uid, [ref('default_delivery_policy')], context=context)
\ No newline at end of file
+ self.execute(cr, uid, [ref('default_delivery_policy')], context=context)
diff --git a/addons/fleet/fleet.py b/addons/fleet/fleet.py
index 44dd9abc1f4..266dd08e2e4 100644
--- a/addons/fleet/fleet.py
+++ b/addons/fleet/fleet.py
@@ -146,7 +146,7 @@ class fleet_vehicle_model(osv.Model):
_columns = {
'name': fields.function(_model_name_get_fnc, type="char", string='Name', store=True),
'modelname': fields.char('Model name', required=True),
- 'brand_id': fields.many2one('fleet.vehicle.model.brand', 'Model Brand', required=True, help='Brand of the vehicle'),
+ 'brand_id': fields.many2one('fleet.vehicle.model.brand', 'Make', required=True, help='Make of the vehicle'),
'vendors': fields.many2many('res.partner', 'fleet_vehicle_model_vendors', 'model_id', 'partner_id', string='Vendors'),
'image': fields.related('brand_id', 'image', type="binary", string="Logo"),
'image_medium': fields.related('brand_id', 'image_medium', type="binary", string="Logo (medium)"),
@@ -170,7 +170,7 @@ class fleet_vehicle_model_brand(osv.Model):
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
_columns = {
- 'name': fields.char('Brand Name', required=True),
+ 'name': fields.char('Make', required=True),
'image': fields.binary("Logo",
help="This field holds the image used as logo for the brand, limited to 1024x1024px."),
'image_medium': fields.function(_get_image, fnct_inv=_set_image,
diff --git a/addons/fleet/fleet_view.xml b/addons/fleet/fleet_view.xml
index 8cda28d56a5..d1d0e557f43 100644
--- a/addons/fleet/fleet_view.xml
+++ b/addons/fleet/fleet_view.xml
@@ -62,7 +62,7 @@
Click to create a new model.
- You can define several models (e.g. A3, A4) for each brand (Audi). + You can define several models (e.g. A3, A4) for each make (Audi).
@@ -87,7 +87,7 @@