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 diff --git a/statement_voucher_killer/__openerp__.py b/statement_voucher_killer/__openerp__.py index 8a595f2e..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': ['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 new file mode 100644 index 00000000..77e44bfe --- /dev/null +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -0,0 +1,125 @@ + +- + 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 +- + !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 : -14.0 +- + I import payment order lines for the bank statement. +- + !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 +- + !python {model: account.bank.statement}: | + result = self.button_confirm_bank(cr, uid, [ref("statement_test_date1")]) +- + 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-01-31'), "Date (year-01-31) not equal to = %s" % line.date 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'] }