[FIX] account_voucher: Fixed wrong writeoff(Payment Difference) calculation by recomp...
[odoo/odoo.git] / addons / account_voucher / test / sales_payment.yml
1 -
2   Create an invoice for the partner Seagate with amount 450.0
3 -
4   !record {model: account.invoice, id: account_invoice_0}:
5     account_id: account.a_recv
6     company_id: base.main_company
7     currency_id: base.EUR
8     invoice_line:
9       - account_id: account.a_sale
10         name: '[PCSC234] PC Assemble SC234'
11         price_unit: 450.0
12         quantity: 1.0
13         product_id: product.product_product_3
14         uos_id: product.product_uom_unit
15     journal_id: account.sales_journal
16     partner_id: base.res_partner_19
17
18 -
19   I check that the customer invoice is in draft state
20 -
21   !assert {model: account.invoice, id: account_invoice_0}:
22     - state == 'draft'
23
24 -
25   I make the invoice in Open state
26 -
27   !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_0}
28
29 -
30   I check that a payment entry gets created in the account.move.line
31 -
32   !python {model: account.invoice}: |
33     acc_id=self.browse(cr, uid, ref("account_invoice_0"))
34     assert(acc_id.move_id)
35
36 -
37   I will create and post an account voucher of amount 450.0 for the partner Seagate.
38 -
39   !python {model: account.voucher}: |
40     import netsvc
41     vals = {}
42     journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
43     res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), journal_id, 0.0, 1, ttype='receipt', date=False)
44     vals = {
45         'account_id': ref('account.cash'),
46         'amount': 450.0,
47         'company_id': ref('base.main_company'),
48         'journal_id': ref('account.bank_journal'),
49         'partner_id': ref('base.res_partner_19'),
50         'period_id': ref('account.period_8'),
51         'type': 'receipt',
52     }
53     if not res['value']['line_cr_ids']:
54       res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
55     #clients aren't sending value of readonly fields in the view, and there is a good reason for that, so here the
56     #create should only use values of fields that are not readonly. That's why i'm removing some of these values
57     del(res['value']['line_cr_ids'][0]['date_original'])
58     del(res['value']['line_cr_ids'][0]['date_due'])
59     res['value']['line_cr_ids'][0]['amount'] = 450.0
60     vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
61     id = self.create(cr, uid, vals)
62     voucher_id = self.browse(cr, uid, id)
63     assert (voucher_id.state=='draft'), "Voucher is not in draft state"
64     wf_service = netsvc.LocalService("workflow")
65     wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
66
67 -
68   Finally i will Confirm the state of the invoice is paid
69 -
70   !assert {model: account.invoice, id: account_invoice_0}:
71     - state == 'paid'