-
  Create an invoice for the partner Seagate with amount 450.0
-
  !python {model: account.invoice}: |
    context.update({'type': 'in_invoice'})
-
  !record {model: account.invoice, id: account_invoice_0}:
    account_id: account.a_pay
    company_id: base.main_company
    currency_id: base.EUR
    supplier_invoice_number: '2013/003864'
    invoice_line:
      - account_id: account.a_expense
        name: '[PCSC234] PC Assemble SC234'
        price_unit: 450.0
        quantity: 1.0
        product_id: product.product_product_3
        uos_id: product.product_uom_unit
    journal_id: account.expenses_journal
    partner_id: base.res_partner_19

-
  I check that the invoice is in draft state
-
  !assert {model: account.invoice, id: account_invoice_0}:
    - state == 'draft'

-
  I make the invoice in Open state
-
  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_0}

-
  I will create and post an account voucher of amount 450.0 for the partner Seagate.
-
  !python {model: account.voucher}: |
    import netsvc
    vals = {}
    res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), ref('account.bank_journal'), 0.0, 1, ttype='payment', date=False)
    vals = {
        'account_id': ref('account.cash'),
        'amount': 450.0,
        'company_id': ref('base.main_company'),
        'journal_id': ref('account.bank_journal'),
        'partner_id': ref('base.res_partner_19'),
        'period_id': ref('account.period_8'),
        'type': 'payment',
    }
    if not res['value']['line_dr_ids']:
      res['value']['line_dr_ids'] = [{'type': 'dr', 'account_id': ref('account.a_pay'),}]
    res['value']['line_dr_ids'][0]['amount'] = 450.0
    vals['line_dr_ids'] = [(0,0,i) for i in res['value']['line_dr_ids']]
    id = self.create(cr, uid, vals)
    voucher = self.browse(cr, uid, id)
    assert (voucher.state=='draft'), "Voucher is not in draft state"
    wf_service = netsvc.LocalService("workflow")
    wf_service.trg_validate(uid, 'account.voucher', voucher.id, 'proforma_voucher', cr)
    assert (voucher.line_ids[0].supplier_invoice_number == '2013/003864'), 'wrong supplier_invoice_number'
-
  Finally i will Confirm the state of the invoice is paid
-
  !assert {model: account.invoice, id: account_invoice_0}:
    - state == 'paid'