diff --git a/addons/account_payment/__openerp__.py b/addons/account_payment/__openerp__.py index 1912dfa5198..e368623a000 100644 --- a/addons/account_payment/__openerp__.py +++ b/addons/account_payment/__openerp__.py @@ -51,8 +51,10 @@ This module provides : ], 'demo_xml': ['account_payment_demo.xml'], 'test': [ - 'test/account_payment.yml', - 'test/account_payment_report.yml' + 'test/account_payment_demo.yml', + 'test/cancel_payment_order.yml', + 'test/payment_order_process.yml', + 'test/account_payment_report.yml', ], 'installable': True, 'active': False, diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index ba98c71fc3e..1de715dc777 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -68,6 +68,7 @@ class payment_order(osv.osv): _rec_name = 'reference' _order = 'id desc' + #dead code def get_wizard(self, type): logger = netsvc.Logger() logger.notifyChannel("warning", netsvc.LOG_WARNING, @@ -235,6 +236,7 @@ class payment_line(osv.osv): break return result + #dead code def select_by_name(self, cr, uid, ids, name, args, context=None): if not ids: return {} partner_obj = self.pool.get('res.partner') diff --git a/addons/account_payment/test/account_payment.yml b/addons/account_payment/test/account_payment.yml deleted file mode 100644 index 13c5b5b20a4..00000000000 --- a/addons/account_payment/test/account_payment.yml +++ /dev/null @@ -1,118 +0,0 @@ -- - In order to test account_payment in OpenERP I created a new Bank Record -- - Creating a res.partner.bank record -- - !record {model: res.partner.bank, id: res_partner_bank_0}: - acc_number: '126-2013269-08' - partner_id: base.res_partner_9 - sequence: 0.0 - state: bank - bank: base.res_bank_1 -- - I created a new Payment Mode -- - Creating a payment.mode record -- - !record {model: payment.mode, id: payment_mode_m0}: - bank_id: res_partner_bank_0 - journal: account.bank_journal - name: TestMode - -- - I created a Supplier Invoice -- - Creating a account.invoice record -- - !record {model: account.invoice, id: account_invoice_payment}: - account_id: account.a_pay - address_contact_id: base.res_partner_address_tang - address_invoice_id: base.res_partner_address_tang - check_total: 300.0 - company_id: base.main_company - currency_id: base.EUR - invoice_line: - - account_id: account.a_expense - name: '[PC1] Basic PC' - price_unit: 300.0 - product_id: product.product_product_pc1 - quantity: 1.0 - uos_id: product.product_uom_unit - journal_id: account.expenses_journal - partner_id: base.res_partner_asus - reference_type: none - type: in_invoice - -- - I make the supplier invoice in Open state -- - Performing a workflow action invoice_open on module account.invoice -- - !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_payment} - -- - I create a new payment order -- - Creating a payment.order record -- - !record {model: payment.order, id: payment_order_0}: - date_prefered: due - mode: payment_mode_m0 - reference: !eval "'%s/006' %(datetime.now().year)" - user_id: base.user_root - - -- - Creating a payment.order.create record -- - !record {model: payment.order.create, id: payment_order_create_0}: - duedate: !eval time.strftime('%Y-%m-%d') - -- - I searched the entries using "Payment Create Order" wizard -- - Performing an osv_memory action search_entries on module payment.order.create -- - !python {model: payment.order.create}: | - self.search_entries(cr, uid, [ref("payment_order_create_0")], {"lang": "en_US", - "active_model": "payment.order", "active_ids": [ref("payment_order_0")], - "tz": False, "active_id": ref("payment_order_0"), }) -- - I check that Initially Payment order is in "draft" state -- - !assert {model: payment.order, id: payment_order_0}: - - state == 'draft' -- - I pressed the confirm payment button to confirm the payment -- - Performing a workflow action open on module payment.order -- - !workflow {model: payment.order, action: open, ref: payment_order_0} -- - I check that Payment order is in "Confirmed" state -- - !assert {model: payment.order, id: payment_order_0}: - - state == 'open' -- - I paid the payment using "Make Payments" Button -- - Creating a account.payment.make.payment record -- - !record {model: account.payment.make.payment, id: account_payment_make_payment_0}: - {} - -- - Performing an osv_memory action launch_wizard on module account.payment.make.payment -- - !python {model: account.payment.make.payment}: | - self.launch_wizard(cr, uid, [ref("account_payment_make_payment_0")], {"lang": - "en_US", "active_model": "payment.order", "active_ids": [ref("payment_order_0")], "tz": - False, "active_id": ref("payment_order_0"), }) - -- - I check that Payment order is in "Done" state -- - !assert {model: payment.order, id: payment_order_0}: - - state == 'done' - - diff --git a/addons/account_payment/test/account_payment_demo.yml b/addons/account_payment/test/account_payment_demo.yml new file mode 100644 index 00000000000..14add1475c7 --- /dev/null +++ b/addons/account_payment/test/account_payment_demo.yml @@ -0,0 +1,13 @@ +- + !record {model: payment.mode, id: payment_mode_1}: + company_id: base.main_company +- + !record {model: payment.order, id: payment_order_2}: + mode: payment_mode_1 +- + !record {model: payment.line, id: payment_line_0}: + name: Test + communication: Test + partner_id: base.res_partner_agrolait + order_id: payment_order_2 + amount_currency: 100.00 diff --git a/addons/account_payment/test/account_payment_report.yml b/addons/account_payment/test/account_payment_report.yml index 45022e19a73..8786841bf1a 100644 --- a/addons/account_payment/test/account_payment_report.yml +++ b/addons/account_payment/test/account_payment_report.yml @@ -1,8 +1,8 @@ - - In order to test the PDF reports defined on Account Payment, Print a Payment Order -- + In order to test the PDF reports defined on Account Payment, I print a Payment Order report. +- !python {model: payment.order}: | import netsvc, tools, os - (data, format) = netsvc.LocalService('report.payment.order').create(cr, uid, [ref('account_payment.payment_order_1')], {}, {}) + (data, format) = netsvc.LocalService('report.payment.order').create(cr, uid, [ref('payment_order_1')], {}, {}) if tools.config['test_report_directory']: - file(os.path.join(tools.config['test_report_directory'], 'account_payment-payment_order_report.'+format), 'wb+').write(data) \ No newline at end of file + file(os.path.join(tools.config['test_report_directory'], 'account_payment-payment_order_report.'+format), 'wb+').write(data) diff --git a/addons/account_payment/test/cancel_payment_order.yml b/addons/account_payment/test/cancel_payment_order.yml new file mode 100644 index 00000000000..9337581f219 --- /dev/null +++ b/addons/account_payment/test/cancel_payment_order.yml @@ -0,0 +1,30 @@ +- + In order to test the process of cancelling the payment order, +- + I confirm payment order. +- + !workflow {model: payment.order, action: open, ref: payment_order_1} +- + I check that payment order is now "Confirmed". +- + !assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be 'Confirmed'.}: + - state == 'open' +- + Now, I cancel the payment order. +- + !workflow {model: payment.order, action: cancel, ref: payment_order_1} +- + I check that payment order is now "Cancelled". +- + !assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be 'Cancelled'.}: + - state == 'cancel' +- + I again set the payment order to draft. +- + !python {model: payment.order}: | + self.set_to_draft(cr, uid, [ref("payment_order_1")]) +- + I check that payment order is now "Draft". +- + !assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be in 'Draft' state.}: + - state == 'draft' diff --git a/addons/account_payment/test/payment_order_process.yml b/addons/account_payment/test/payment_order_process.yml new file mode 100644 index 00000000000..2bb04807a64 --- /dev/null +++ b/addons/account_payment/test/payment_order_process.yml @@ -0,0 +1,107 @@ +- + 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 confirm the payment order. +- + !workflow {model: payment.order, action: open, ref: payment_order_1} +- + I check that payment order is now "Confirmed". +- + !assert {model: payment.order, id: payment_order_1, 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("payment_order_1")], + "active_id": ref("payment_order_1"), }) +- + 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("payment_order_1")], + "active_id": ref("payment_order_1")}) +- + 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("payment_order_1")) + 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." +- + After making all payments, I finish the payment order. +- + !python {model: payment.order}: | + self.set_done(cr, uid, [ref("payment_order_1")]) +- + I check that payment order is now "Done". +- + !assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be in 'Done' state}: + - state == 'done' +- + I check that payment order is done with proper data. +- + !python {model: payment.order}: | + payment = self.browse(cr, uid, ref("payment_order_1")) + assert payment.date_done, "Date is not created." +- + I create a bank statement. +- + !record {model: account.bank.statement, id: account_bank_statement_1}: + balance_end_real: 0.0 + balance_start: 0.0 + date: !eval time.strftime('%Y-%m-%d') + journal_id: account.bank_journal + name: / + period_id: account.period_10 +- + 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("payment_order_1")) + 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("account_bank_statement_1"), + "active_model": "account.bank.statement", "journal_type": "cash", + "active_id": ref("account_bank_statement_1")}) +- + I am checking whether the calculations of Owner Account and Destination Account are done correctly or not in payment line. +- + !python {model: payment.line}: | + payment = self.pool.get('payment.order').browse(cr, uid, ref("payment_order_1")) + line_id = self.browse(cr, uid,payment.line_ids[0].id,context) + assert line_id.info_owner, "Owner Account not proper." + assert line_id.info_partner, "Destination Account not proper." + assert line_id.ml_inv_ref, "Invoice reference is not proper." diff --git a/addons/account_payment/wizard/account_payment_create_order_view.xml b/addons/account_payment/wizard/account_payment_create_order_view.xml index c454a84bffd..538d32efe80 100644 --- a/addons/account_payment/wizard/account_payment_create_order_view.xml +++ b/addons/account_payment/wizard/account_payment_create_order_view.xml @@ -27,7 +27,8 @@
- + + diff --git a/addons/account_payment/wizard/account_payment_pay.py b/addons/account_payment/wizard/account_payment_pay.py index ca9311b1f88..6bcb04fa490 100644 --- a/addons/account_payment/wizard/account_payment_pay.py +++ b/addons/account_payment/wizard/account_payment_pay.py @@ -21,6 +21,7 @@ from osv import osv +#TODO:REMOVE this wizard is not used class account_payment_make_payment(osv.osv_memory): _name = "account.payment.make.payment" _description = "Account make payment" diff --git a/addons/account_payment/wizard/account_payment_pay_view.xml b/addons/account_payment/wizard/account_payment_pay_view.xml index 3d732aea6e2..a8835e0da8f 100644 --- a/addons/account_payment/wizard/account_payment_pay_view.xml +++ b/addons/account_payment/wizard/account_payment_pay_view.xml @@ -1,7 +1,7 @@ - + account.payment.make.payment.form account.payment.make.payment