-
  In order to test account invoice I create a new customer invoice
-
  I will create bank detail
-
  !record {model: res.partner.bank, id: res_partner_bank_0}:
    state: bank
    company_id: base.main_company
    partner_id: base.main_partner
    acc_number: 123456789
    footer: True
    bank: base.res_bank_1
    bank_name: Reserve
-
  I create a customer invoice
-
  !record {model: account.invoice, id: account_invoice_customer0, view: invoice_form}:
    payment_term: account.account_payment_term_advance
    partner_bank_id: res_partner_bank_0
    journal_id: account.sales_journal
    partner_id: base.res_partner_3
    reference_type: none
    name: 'Test Customer Invoice'
    invoice_line:
      - product_id: product.product_product_5
        quantity: 10.0
-
  I manually assign tax on invoice
-
  !python {model: account.invoice.tax}: |
    amt = self.amount_change(cr, uid, [], 50.0, ref('base.EUR'), ref('base.main_company'), False)
    base_amt = self.base_change(cr, uid, [], 9000.0, ref('base.EUR'), ref('base.main_company'), False)
    invoice_tax_line = {
        'name':  'Test Tax for Customer Invoice',
        'manual': 1,
        'base': base_amt['value']['base_amount'],
        'amount': amt['value']['tax_amount'],
        'account_id': ref('account.ova'),
        'invoice_id': ref("account_invoice_customer0"),
        }
    tax = self.create(cr, uid, invoice_tax_line)
    assert tax, "Tax has not been assigned correctly"

-
  I check that Initially customer invoice is in the "Draft" state
-
  !assert {model: account.invoice, id: account_invoice_customer0}:
    - state == 'draft'
-
  I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
-
  !workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_customer0}
-
  I check that the invoice state is now "Proforma2"
-
  !assert {model: account.invoice, id: account_invoice_customer0}:
    - state == 'proforma2'
-
  I check that there is no move attached to the invoice
-
  !python {model: account.invoice}: |
    acc_id=self.browse(cr, uid, ref("account_invoice_customer0"))
    assert (not acc_id.move_id), "Move falsely created at pro-forma"
-
  I create invoice by clicking on Create button
-
  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0}
-
  I check that the invoice state is "Open"
-
  !assert {model: account.invoice, id: account_invoice_customer0}:
    - state == 'open'

-
  I check that now there is a move attached to the invoice
-
  !python {model: account.invoice}: |
    acc_id=self.browse(cr, uid, ref("account_invoice_customer0"))
    assert acc_id.move_id, "Move not created for open invoice"
-
  I pay the Invoice
-
  !python {model: account.invoice}: |
    import time
    pay = self.pay_and_reconcile(cr, uid, [ref('account_invoice_customer0')],
        9050.0, ref('cash'), ref('account.period_10'),
        ref('bank_journal'), ref('cash'),
        ref('account.period_10'), ref('bank_journal'),
        name='Payment for test customer invoice')
    assert (pay == True), "Incorrect Payment"
-
  I verify that invoice is now in Paid state
-
  !python {model: account.invoice}: |
    inv = self.browse(cr, uid, ref("account_invoice_customer0"))
    assert (inv.state == 'paid'), "Invoice is not in Paid state"
-
  I refund the invoice Using Refund Button
-
  !record {model: account.invoice.refund, id: account_invoice_refund_0}:
    description: Refund To China Export
    period: account.period_5
    filter_refund: refund
-
  I clicked on refund button
-
  !python {model: account.invoice.refund}: |
    self.invoice_refund(cr, uid, [ref("account_invoice_refund_0")], {"lang": 'en_US', "tz": False, "active_model": "account.invoice", "active_ids": [ref("account.account_invoice_customer0")], "type": "out_invoice", "active_id": ref("account.account_invoice_customer0"), })
-
  I checked that a new entry with state "Draft" created in account move line


