[IMP] improvement in yml test code in account_payment module
bzr revid: tpa@tinyerp.com-20111219065214-m5a570xuc4z3f5vy
This commit is contained in:
parent
ef17878ec7
commit
f44e88a67d
|
@ -51,10 +51,11 @@ This module provides :
|
|||
],
|
||||
'demo_xml': ['account_payment_demo.xml'],
|
||||
'test': [
|
||||
'test/account_payment_demo.yml',
|
||||
'test/draft2cancel_payment_order.yml',
|
||||
'test/draft2done_payment_order.yml',
|
||||
'test/account_payment_order_wiz.yml',
|
||||
'test/draft2valid_bank_statement.yml',
|
||||
'account_payment_demo.yml',
|
||||
'test/account_payment_report.yml'
|
||||
],
|
||||
'installable': True,
|
||||
|
|
|
@ -68,7 +68,7 @@ class payment_order(osv.osv):
|
|||
_rec_name = 'reference'
|
||||
_order = 'id desc'
|
||||
|
||||
#TODO:REMOVE this function is not used
|
||||
#dead code
|
||||
def get_wizard(self, type):
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel("warning", netsvc.LOG_WARNING,
|
||||
|
@ -236,7 +236,7 @@ class payment_line(osv.osv):
|
|||
break
|
||||
return result
|
||||
|
||||
#TODO:REMOVE this function is not used
|
||||
#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')
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
-
|
||||
!record {model: res.partner.bank, id: partner_bank_1}:
|
||||
name: Reserve Bank
|
||||
acc_number: 00987654321
|
||||
partner_id: base.res_partner_agrolait
|
||||
bank: base.res_bank_1
|
||||
state: bank
|
||||
|
||||
-
|
||||
!record {model: payment.mode, id: payment_mode_1}:
|
||||
name: Direct Payment
|
||||
journal: account.bank_journal
|
||||
bank_id: account_payment.partner_bank_1
|
||||
|
||||
-
|
||||
!record {model: payment.order, id: payment_order_1}:
|
||||
mode: account_payment.payment_mode_1
|
||||
user_id: base.user_root
|
||||
date_prefered: now
|
|
@ -0,0 +1,18 @@
|
|||
-
|
||||
!record {model: res.company, id: company_1}:
|
||||
name: TinyERP
|
||||
-
|
||||
!record {model: payment.mode, id: payment_mode_1}:
|
||||
company_id: company_1
|
||||
#-
|
||||
# call onchange.
|
||||
#-
|
||||
#!python {model: payment.order}: |
|
||||
#pay_line_obj = self.pool.get('payment.line')
|
||||
#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]
|
||||
#pay_line_obj.onchange_move_line(cr, uid, [payment_line.id] ,invoice.move_id.line_id[0].id ,payment.mode, payment.date_prefered, payment.date_scheduled, payment_line.currency, payment_line.company_currency, context)
|
||||
#pay_line_obj.onchange_amount(cr, uid, [payment_line.id] , payment_line.amount_currency, payment_line.currency.id, payment_line.company_currency.id, context)
|
||||
#pay_line_obj.onchange_partner(cr, uid, [payment_line.id] , ref("base.res_partner_maxtor"), payment.mode, context)
|
||||
#-
|
|
@ -0,0 +1,37 @@
|
|||
-
|
||||
In order to test the Select invoice to pay wizard
|
||||
-
|
||||
I create a record for payment order.
|
||||
-
|
||||
!record {model: payment.order.create, id: payment_order_create_0}:
|
||||
duedate: !eval time.strftime('%Y-%m-%d')
|
||||
-
|
||||
I perform a action to search the entries for create a payment line
|
||||
-
|
||||
!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"), })
|
||||
-
|
||||
In order to make entries in payment line, I create a 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 a 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 same created."
|
||||
assert invoice.date_due == payment_line.ml_maturity_date, "due date is not same created."
|
||||
assert invoice.amount_total == payment_line.amount, "payment amount is not same created."
|
|
@ -1,8 +1,8 @@
|
|||
-
|
||||
In order to test the PDF reports defined on Account Payment, Print a Payment Order
|
||||
-
|
||||
-
|
||||
!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)
|
|
@ -1,21 +1,30 @@
|
|||
-
|
||||
In order to test the process of payment order
|
||||
-
|
||||
I perform action to change the state of payment order to "confirmed"
|
||||
I confirm payment order.
|
||||
-
|
||||
!workflow {model: payment.order, action: open, ref: account_payment.payment_order_1}
|
||||
!workflow {model: payment.order, action: open, ref: payment_order_1}
|
||||
-
|
||||
I check that Payment order is now "Confirmed"
|
||||
I check that Payment order is now "Confirmed".
|
||||
-
|
||||
!assert {model: payment.order, id: account_payment.payment_order_1}:
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be 'Confirmed' state}:
|
||||
- state == 'open'
|
||||
-
|
||||
In order to not payment line so I perform action to change the state of payment order to "cancel"
|
||||
In order to not payment line so I perform action to change the state of payment order to "cancel".
|
||||
-
|
||||
!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 in 'Confirmed' state}:
|
||||
- state == 'cancel'
|
||||
-
|
||||
I set the payment order in "Draft" state.
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
self.set_to_draft(cr, uid, [ref("account_payment.payment_order_1")])
|
||||
self.set_to_draft(cr, uid, [ref("payment_order_1")])
|
||||
-
|
||||
I check that Payment order is now "draft"
|
||||
I check that Payment order is now "draft".
|
||||
-
|
||||
!assert {model: payment.order, id: account_payment.payment_order_1}:
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be in 'Draft' state}:
|
||||
- state == 'draft'
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
-
|
||||
In order to test the process of supplier invoice, I enter the amount for a total of invoice
|
||||
-
|
||||
|
@ -11,79 +10,36 @@
|
|||
invoice = self.browse(cr, uid, ref("account.demo_invoice_0"))
|
||||
assert (not invoice.move_id), "Move wrongly created at draft"
|
||||
-
|
||||
I perform action to change the state of invoice to "open"
|
||||
I change the state of invoice to "open".
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0}
|
||||
-
|
||||
I check that the invoice state is now "Open"
|
||||
I check that the invoice state is now "Open".
|
||||
-
|
||||
!assert {model: account.invoice, id: account.demo_invoice_0}:
|
||||
- state == 'open'
|
||||
|
||||
-
|
||||
In order to test the process of payment order and payment line
|
||||
-
|
||||
I create a record for payment order
|
||||
-
|
||||
!record {model: payment.order.create, id: payment_order_create_0}:
|
||||
duedate: !eval time.strftime('%Y-%m-%d')
|
||||
|
||||
-
|
||||
I perform a action to search the entries for create a payment line
|
||||
-
|
||||
!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("account_payment.payment_order_1")],
|
||||
"tz": False, "active_id": ref("account_payment.payment_order_1"), })
|
||||
|
||||
-
|
||||
In order to make entries in payment line, I create a 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")], {"lang": "en_US",
|
||||
"active_model": "payment.order", "active_ids": [ref("account_payment.payment_order_1")],
|
||||
"tz": False, "active_id": ref("account_payment.payment_order_1"), })
|
||||
|
||||
-
|
||||
I check a 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("account_payment.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 same created"
|
||||
assert invoice.date_due == payment_line.ml_maturity_date, "due date is not same created"
|
||||
assert invoice.amount_total == payment_line.amount, "payment amount is not same created"
|
||||
|
||||
-
|
||||
I perform action to change the state of payment order to "confirmed"
|
||||
-
|
||||
!workflow {model: payment.order, action: open, ref: account_payment.payment_order_1}
|
||||
-
|
||||
I check that Payment order is now "Confirmed"
|
||||
-
|
||||
!assert {model: payment.order, id: account_payment.payment_order_1}:
|
||||
!assert {model: account.invoice, id: account.demo_invoice_0, severity: error, string: Invoice should be in 'Open' state}:
|
||||
- state == 'open'
|
||||
-
|
||||
I perform action to change the state of payment order to "done"
|
||||
I change the state of Payment Order to "Confirmed".
|
||||
-
|
||||
!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 in 'Confirmed' state}:
|
||||
- state == 'open'
|
||||
-
|
||||
I change the state of payment order to "done".
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
self.set_done(cr, uid, [ref("account_payment.payment_order_1")])
|
||||
self.set_done(cr, uid, [ref("payment_order_1")])
|
||||
-
|
||||
I check that Payment order is now "done"
|
||||
I check that Payment order is now "done".
|
||||
-
|
||||
!assert {model: payment.order, id: account_payment.payment_order_1}:
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be in 'Done' state}:
|
||||
- state == 'done'
|
||||
|
||||
-
|
||||
I check a payment order is done with proper data
|
||||
I check a payment order is done with proper data.
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
payment = self.browse(cr, uid, ref("account_payment.payment_order_1"))
|
||||
payment = self.browse(cr, uid, ref("payment_order_1"))
|
||||
assert payment.date_done, "date is not created after done payment order"
|
|
@ -10,59 +10,43 @@
|
|||
journal_id: account.bank_journal
|
||||
name: /
|
||||
period_id: account.period_10
|
||||
|
||||
-
|
||||
In order to make entries in bank statement line, I import payment order lines
|
||||
In order to make entries in bank statement line, I import payment order lines.
|
||||
-
|
||||
!python {model: account.payment.populate.statement}: |
|
||||
payment = self.pool.get('payment.order').browse(cr, uid, ref("account_payment.payment_order_1"))
|
||||
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], {"lang": "en_US", "tz": False, "statement_id": ref("account_bank_statement_1"), "active_model": "account.bank.statement", "journal_type": "cash", "active_ids": [ref("account_bank_statement_1")], "active_id": ref("account_bank_statement_1")})
|
||||
|
||||
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 check that payment line is import successfully in bank statement line
|
||||
I check that payment line is import successfully in bank statement line.
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
bank = self.browse(cr, uid, ref("account_bank_statement_1"))
|
||||
assert bank.line_ids, "bank statement line is not created"
|
||||
|
||||
assert bank.line_ids, "bank statement line is not created."
|
||||
-
|
||||
I modify the bank statement and set the Closing Balance.
|
||||
-
|
||||
!record {model: account.bank.statement, id: account_bank_statement_1}:
|
||||
balance_end_real: -14.0
|
||||
|
||||
-
|
||||
I perform action to confirm the bank statement.
|
||||
I confirm the bank statement.
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
self.button_confirm_bank(cr, uid, [ref("account_bank_statement_1")])
|
||||
-
|
||||
I check that bank statement state is now "Closed"
|
||||
I check that bank statement state is now "Confirm"
|
||||
-
|
||||
!assert {model: account.bank.statement, id: account_bank_statement_1}:
|
||||
- state == 'confirm'
|
||||
-
|
||||
I check that move lines created for bank statement
|
||||
I check that move lines created for bank statement.
|
||||
-
|
||||
!python {model: account.bank.statement}: |
|
||||
bank = self.browse(cr, uid, ref("account_bank_statement_1"))
|
||||
move_line = bank.move_line_ids[0]
|
||||
|
||||
assert bank.move_line_ids, "Move lines not created for bank statement"
|
||||
assert move_line.state == 'valid', "Move state is not valid"
|
||||
-
|
||||
I check that the payment is created with proper data in supplier invoice
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice = self.browse(cr, uid, ref("account.demo_invoice_0"))
|
||||
payment_line = invoice.payment_ids[0]
|
||||
|
||||
assert invoice.state == 'paid', "invoice state is not paid"
|
||||
assert invoice.reconciled == True, "invoice reconcile is not True"
|
||||
assert invoice.residual == 0.0, "invoice residua amount is not filly paid"
|
||||
assert payment_line, "payment line not created for paid invoice"
|
||||
assert payment_line.debit == invoice.amount_total and payment_line.credit == 0.0, "proper amount is not debit to payment account "
|
||||
assert payment_line.reconcile_id, "reconcile is not created for paid invoice"
|
||||
|
||||
|
||||
assert bank.move_line_ids, "Move lines not created for bank statement."
|
||||
assert move_line.state == 'valid', "Move state is not valid."
|
|
@ -76,7 +76,7 @@ class account_payment_populate_statement(osv.osv_memory):
|
|||
statement.currency.id, line.amount_currency, context=ctx)
|
||||
|
||||
context.update({'move_line_ids': [line.move_line_id.id]})
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype='payment', date=line.ml_maturity_date, context=context)
|
||||
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, amount=abs(amount), currency_id= statement.currency.id, ttype='payment', date=line.ml_maturity_date, context=context)
|
||||
|
||||
if line.move_line_id:
|
||||
voucher_res = {
|
||||
|
|
Loading…
Reference in New Issue