From 81b9befac14417794d2ea3fc635c4d58612c177d Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 08:34:56 +0200 Subject: [PATCH 01/10] [FIX] rewrite to fix : https://bugs.launchpad.net/banking-addons/+bug/1301781 --- statement_voucher_killer/voucher.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/statement_voucher_killer/voucher.py b/statement_voucher_killer/voucher.py index b924b8a1..b678bfc5 100644 --- a/statement_voucher_killer/voucher.py +++ b/statement_voucher_killer/voucher.py @@ -72,7 +72,7 @@ class AccountStatementFromInvoiceLines(orm.TransientModel): elif line.journal_id.type in ('purchase', 'purhcase_refund'): s_type = 'supplier' vals = self._prepare_statement_line_vals( - cr, uid, line, s_type, statement_id, amount, context=context) + cr, uid, line, s_type, statement_id, amount, context=ctx) statement_line_obj.create(cr, uid, vals, context=context) return {'type': 'ir.actions.act_window_close'} @@ -86,7 +86,7 @@ class AccountStatementFromInvoiceLines(orm.TransientModel): 'statement_id': statement_id, 'ref': move_line.ref, 'voucher_id': False, - 'date': time.strftime('%Y-%m-%d'), + 'date': context['date'], } @@ -111,7 +111,7 @@ class AccountPaymentPopulateStatement(orm.TransientModel): for line in line_obj.browse(cr, uid, line_ids, context=context): ctx = context.copy() # Last value_date earlier,but this field exists no more now - ctx['date'] = line.ml_maturity_date + ctx['date'] = line.date or statement.date amount = currency_obj.compute( cr, uid, line.currency.id, statement.currency.id, line.amount_currency, context=ctx) @@ -119,7 +119,7 @@ class AccountPaymentPopulateStatement(orm.TransientModel): continue context.update({'move_line_ids': [line.move_line_id.id]}) vals = self._prepare_statement_line_vals( - cr, uid, line, -amount, statement, context=context) + cr, uid, line, -amount, statement, context=ctx) st_line_id = statement_line_obj.create(cr, uid, vals, context=context) line_obj.write( @@ -136,6 +136,5 @@ class AccountPaymentPopulateStatement(orm.TransientModel): 'account_id': payment_line.move_line_id.account_id.id, 'statement_id': statement.id, 'ref': payment_line.communication, - 'date': (payment_line.date or payment_line.ml_maturity_date or - statement.date) + 'date': context['date'] } From 9b4688bfe05af7b47621c5998df30860978a0a77 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 09:26:38 +0200 Subject: [PATCH 02/10] [ADD] test file --- .../test/correct_date_in_move_line.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 statement_voucher_killer/test/correct_date_in_move_line.yml diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml new file mode 100644 index 00000000..4bb22d9c --- /dev/null +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -0,0 +1,29 @@ +- + In order to test if the correct date is set in the bank statement + I create a bank statement +- + !record {model: account.bank.statement, id: statement_test_date1}: + name: Statement for Date + journal_id: account.bank_journal + company_id: base.main_company + balance_end_real : 1000.0 +- + I create a statement line for a SO +- + !record {model: account.bank.statement.line, id: statement_line_so}: + name: Test autocompletion based on Sale Order Number + statement_id: statement_test_date1 + ref: DATE1 + date: '2014-12-20' + amount: 1000.0 +- + I confirm the bank statement +- + !python {model: account.bank.statement}: | + result = self.button_confirm_bank(cr, uid, [ref("statement_test_sale1")]) +- + Now I can check that all is nice and shiny, line 1. I expect the Sale Order + Number to be recognised. +- + !assert {model: account.move.line, statement_id: statement_test_date1, string: Check date in move line}: + - date == '2014-12-20' From 4088bf87c272ecce2151df8ad1b889b547b8780e Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 09:29:09 +0200 Subject: [PATCH 03/10] [FIx] include test in __openerp__.py --- statement_voucher_killer/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statement_voucher_killer/__openerp__.py b/statement_voucher_killer/__openerp__.py index 8a595f2e..fc12607e 100644 --- a/statement_voucher_killer/__openerp__.py +++ b/statement_voucher_killer/__openerp__.py @@ -42,6 +42,6 @@ line will be take from imported line in this order: 'data': [ 'statement_view.xml', ], - 'test': [], + 'test': [test/correct_date_in_move_line.yml], 'installable': True, } From e0d576f07126a01f6ba6be566b4b0b0d0d465fbf Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 10:33:33 +0200 Subject: [PATCH 04/10] [FIX] improve test --- statement_voucher_killer/__openerp__.py | 2 +- .../test/correct_date_in_move_line.yml | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/statement_voucher_killer/__openerp__.py b/statement_voucher_killer/__openerp__.py index fc12607e..d82792a8 100644 --- a/statement_voucher_killer/__openerp__.py +++ b/statement_voucher_killer/__openerp__.py @@ -42,6 +42,6 @@ line will be take from imported line in this order: 'data': [ 'statement_view.xml', ], - 'test': [test/correct_date_in_move_line.yml], + 'test': ['test/correct_date_in_move_line.yml'], 'installable': True, } diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 4bb22d9c..6867f562 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -10,20 +10,22 @@ - I create a statement line for a SO - - !record {model: account.bank.statement.line, id: statement_line_so}: + !record {model: account.bank.statement.line, id: statement_line_date}: name: Test autocompletion based on Sale Order Number statement_id: statement_test_date1 ref: DATE1 + account_id : account.a_sale date: '2014-12-20' amount: 1000.0 - I confirm the bank statement - !python {model: account.bank.statement}: | - result = self.button_confirm_bank(cr, uid, [ref("statement_test_sale1")]) + result = self.button_confirm_bank(cr, uid, [ref("statement_test_date1")]) - - Now I can check that all is nice and shiny, line 1. I expect the Sale Order - Number to be recognised. + Now I can check that that the date in move line is equal to line date - - !assert {model: account.move.line, statement_id: statement_test_date1, string: Check date in move line}: - - date == '2014-12-20' + !python {model: account.move.line}: | + line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) + line = self.browse(cr, uid, line_ids)[0] + assert line.date == '2014-12-20', "Date (2014-12-20) not equal to = %s" % line.date From b7c37f8d7cfcb1b28e2de64af22132019f3fc5ee Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 11:28:21 +0200 Subject: [PATCH 05/10] [FIX] test --- .../test/correct_date_in_move_line.yml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 6867f562..4c691bed 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -1,10 +1,26 @@ +- + In order to test the bank statement date , I first need to + create a profile +- + !record {model: account.statement.profile, id: profile_test_date}: + name: Bank EUR Profile for check date + journal_id: account.bank_journal + commission_account_id: account.a_expense + company_id: base.main_company + balance_check: True + rule_ids: + - account_statement_base_completion.bank_statement_completion_rule_4 + - account_statement_base_completion.bank_statement_completion_rule_5 + - account_statement_base_completion.bank_statement_completion_rule_2 + - account_statement_base_completion.bank_statement_completion_rule_3 + - bank_statement_completion_rule_1 - In order to test if the correct date is set in the bank statement I create a bank statement - !record {model: account.bank.statement, id: statement_test_date1}: name: Statement for Date - journal_id: account.bank_journal + profile_id: profile_test_date company_id: base.main_company balance_end_real : 1000.0 - @@ -15,7 +31,7 @@ statement_id: statement_test_date1 ref: DATE1 account_id : account.a_sale - date: '2014-12-20' + date: !eval time.strftime('%Y-12-20') amount: 1000.0 - I confirm the bank statement @@ -28,4 +44,4 @@ !python {model: account.move.line}: | line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] - assert line.date == '2014-12-20', "Date (2014-12-20) not equal to = %s" % line.date + assert line.date == !eval time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date From e8931ac9aeedf92b43dd64e43e6c12ca80364554 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 14:42:22 +0200 Subject: [PATCH 06/10] [FIX] improve test --- .../test/correct_date_in_move_line.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 4c691bed..1206ecc6 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -1,26 +1,10 @@ -- - In order to test the bank statement date , I first need to - create a profile -- - !record {model: account.statement.profile, id: profile_test_date}: - name: Bank EUR Profile for check date - journal_id: account.bank_journal - commission_account_id: account.a_expense - company_id: base.main_company - balance_check: True - rule_ids: - - account_statement_base_completion.bank_statement_completion_rule_4 - - account_statement_base_completion.bank_statement_completion_rule_5 - - account_statement_base_completion.bank_statement_completion_rule_2 - - account_statement_base_completion.bank_statement_completion_rule_3 - - bank_statement_completion_rule_1 - In order to test if the correct date is set in the bank statement I create a bank statement - !record {model: account.bank.statement, id: statement_test_date1}: name: Statement for Date - profile_id: profile_test_date + journal_id: account.bank_journal company_id: base.main_company balance_end_real : 1000.0 - From 50b2e859f025a1e37f38604af64145e8a01bee42 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 14:44:20 +0200 Subject: [PATCH 07/10] [IMP] statement_voucher_killer is a not related to easy_reconcile module, it's useful to make the test without this module installed --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3f41c18..40dc8cb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,11 @@ virtualenv: system_site_packages: true env: - - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_statement_ext_point_of_sale" - - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_statement_ext_point_of_sale" + - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_statement_ext_point_of_sale,statement_voucher_killer" + - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_statement_ext_point_of_sale,statement_voucher_killer" + + - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="statement_voucher_killer" + - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="statement_voucher_killer" install: - git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools From d600eff7a2773d697c16de8473d9ed51e29e9c47 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 15:01:23 +0200 Subject: [PATCH 08/10] [FIX] remove eval in python --- statement_voucher_killer/test/correct_date_in_move_line.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 1206ecc6..84b29520 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -28,4 +28,4 @@ !python {model: account.move.line}: | line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] - assert line.date == !eval time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date + assert line.date == time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date From 7d29ec2f3387460f4d8bc5a9496147b9106521eb Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 15:25:40 +0200 Subject: [PATCH 09/10] [FIX] missing import time --- statement_voucher_killer/test/correct_date_in_move_line.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 84b29520..c7147920 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -26,6 +26,7 @@ Now I can check that that the date in move line is equal to line date - !python {model: account.move.line}: | + import time line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] assert line.date == time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date From 0f9ee8776e1162d054fd1d0f83df643825231b32 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 17:48:09 +0200 Subject: [PATCH 10/10] [FIX] improve test --- .../test/correct_date_in_move_line.yml | 113 ++++++++++++++++-- 1 file changed, 103 insertions(+), 10 deletions(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index c7147920..77e44bfe 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -1,3 +1,96 @@ + +- + In order to test the process of payment order, I start with the supplier invoice. +- + !python {model: account.invoice}: | + self.write(cr, uid, [ref('account.demo_invoice_0')], {'check_total': -14}) + +- + In order to test account move line of journal, I check that there is no move attached to the invoice. +- + !python {model: account.invoice}: | + invoice = self.browse(cr, uid, ref("account.demo_invoice_0")) + assert (not invoice.move_id), "Moves are wrongly created for invoice." +- + I open the invoice. +- + !workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0} +- + I check that the invoice state is now "Open". +- + !assert {model: account.invoice, id: account.demo_invoice_0, severity: error, string: Invoice should be in 'Open' state}: + - state == 'open' +- + I create a payment order +- + !record {model: payment.order, id: date1_payment_order}: + #date_created + #date_done + date_prefered: due + #date_scheduled + #line_ids: + mode: account_payment.payment_mode_1 + #reference + state: draft + total: -14 + #user_id + +- + I confirm the payment order. +- + !workflow {model: payment.order, action: open, ref: date1_payment_order} +- + I check that payment order is now "Confirmed". +- + !assert {model: payment.order, id: date1_payment_order, severity: error, string: Payment Order should be 'Confirmed'.}: + - state == 'open' +- + !record {model: payment.order.create, id: payment_order_create_0}: + duedate: !eval time.strftime('%Y-%m-%d') + +- + I search for the invoice entries to make the payment. +- + !python {model: payment.order.create}: | + self.search_entries(cr, uid, [ref("payment_order_create_0")], { + "active_model": "payment.order", "active_ids": [ref("date1_payment_order")], + "active_id": ref("date1_payment_order"), }) +- + I create payment lines entries. +- + !python {model: payment.order.create}: | + invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0")) + move_line = invoice.move_id.line_id[0] + self.write(cr, uid, [ref("payment_order_create_0")], {'entries': [(6,0,[move_line.id])]}) + self.create_payment(cr, uid, [ref("payment_order_create_0")], { + "active_model": "payment.order", "active_ids": [ref("date1_payment_order")], + "active_id": ref("date1_payment_order")}) + +- + After making all payments, I finish the payment order. +- + !python {model: payment.order}: | + self.set_done(cr, uid, [ref("date1_payment_order")]) +- + I check that payment order is now "Done". +- + !assert {model: payment.order, id: date1_payment_order, severity: error, string: Payment Order should be in 'Done' state}: + - state == 'done' + +- + I check that payment line is created with proper data. +- + !python {model: payment.order}: | + invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0")) + payment = self.browse(cr, uid, ref("date1_payment_order")) + payment_line = payment.line_ids[0] + + assert payment_line.move_line_id, "move line is not created in payment line." + assert invoice.move_id.name == payment_line.ml_inv_ref.number, "invoice reference number is not same created." + assert invoice.partner_id == payment_line.partner_id, "Partner is not correct." + assert invoice.date_due == payment_line.ml_maturity_date, "Due date is not correct." + assert invoice.amount_total == payment_line.amount, "Payment amount is not correct." + - In order to test if the correct date is set in the bank statement I create a bank statement @@ -6,17 +99,17 @@ name: Statement for Date journal_id: account.bank_journal company_id: base.main_company - balance_end_real : 1000.0 + balance_end_real : -14.0 - - I create a statement line for a SO + I import payment order lines for the bank statement. - - !record {model: account.bank.statement.line, id: statement_line_date}: - name: Test autocompletion based on Sale Order Number - statement_id: statement_test_date1 - ref: DATE1 - account_id : account.a_sale - date: !eval time.strftime('%Y-12-20') - amount: 1000.0 + !python {model: account.payment.populate.statement}: | + payment = self.pool.get('payment.order').browse(cr, uid, ref("date1_payment_order")) + payment_line = payment.line_ids[0] + import_payment_id = self.create(cr, uid, {'lines': [(6,0,[payment_line.id])]}) + self.populate_statement(cr, uid, [import_payment_id], {"statement_id": ref("statement_test_date1"), + "active_model": "account.bank.statement", "journal_type": "cash", + "active_id": ref("statement_test_date1")}) - I confirm the bank statement - @@ -29,4 +122,4 @@ import time line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] - assert line.date == time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date + assert line.date == time.strftime('%Y-01-31'), "Date (year-01-31) not equal to = %s" % line.date