2 In order to check the Account_voucher module with multi-currency in OpenERP,
3 I create 2 Invoices in EUR and make 2 Payments in EUR based on the currency rating on that particular date.
5 I create currency EUR in OpenERP for January of 1.000000 Rate
7 !record {model: res.currency.rate, id: jan_eur}:
9 name: !eval "'%s-01-01' %(datetime.now().year)"
12 I modify the debtor account in order to make sure there is no currency_id linked
14 !python {model: account.account}: |
15 from datetime import datetime
16 ids = self.search(cr, uid, [('name', 'ilike', 'debtor')])
17 self.write(cr, uid, ids, {'currency_id': False})
19 I create a bank journal with EUR as currency
21 !record {model: account.journal, id: bank_journal_EUR}:
22 name: Bank Journal(EUR)
25 analytic_journal_id: account.sit
26 sequence_id: account.sequence_bank_journal
27 default_debit_account_id: account.cash
28 default_credit_account_id: account.cash
30 company_id: base.main_company
31 view_id: account.account_journal_bank_view
33 I create the first invoice on 1st January for 150 EUR
35 !record {model: account.invoice, id: account_first_invoice_jan_eur}:
36 account_id: account.a_recv
37 address_contact_id: base.res_partner_address_3000
38 address_invoice_id: base.res_partner_address_3000
39 company_id: base.main_company
41 date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
42 period_id: account.period_1
44 - account_id: account.a_sale
45 name: '[PC1] Basic PC'
48 product_id: product.product_product_pc1
49 uos_id: product.product_uom_unit
50 journal_id: account.sales_journal
51 partner_id: base.res_partner_seagate
54 I Validate invoice by clicking on Validate button
56 !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_eur}
58 I check that first invoice move is correct for debtor account(debit - credit == 150)
60 !python {model: account.invoice}: |
61 invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
62 assert invoice_id.move_id, "Move not created for open invoice"
63 move_line_obj = self.pool.get('account.move.line')
64 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
65 move_line = move_line_obj.browse(cr, uid, move_lines[0])
66 assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
68 I create the second invoice on 1st February for 80 EUR
70 !record {model: account.invoice, id: account_second_invoice_feb_eur}:
71 account_id: account.a_recv
72 address_contact_id: base.res_partner_address_3000
73 address_invoice_id: base.res_partner_address_3000
74 company_id: base.main_company
76 date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
77 period_id: account.period_1
79 - account_id: account.a_sale
80 name: '[PC1] Basic PC'
83 product_id: product.product_product_pc1
84 uos_id: product.product_uom_unit
85 journal_id: account.sales_journal
86 partner_id: base.res_partner_seagate
89 I Validate invoice by clicking on Validate button
91 !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_eur}
93 I check that second invoice move is correct for debtor account (debit - credit == 80)
95 !python {model: account.invoice}: |
96 invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
97 assert invoice_id.move_id, "Move not created for open invoice"
98 move_line_obj = self.pool.get('account.move.line')
99 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
100 move_line = move_line_obj.browse(cr, uid, move_lines[0])
101 assert (move_line.debit - move_line.credit == 80.00), "Invoice move is incorrect for debtors account"
103 I create the first voucher of payment
104 <create with values 120 EUR, journal EUR, and fill amounts 100 for the invoice of 150 EUR and 20 for the invoice of 80 EUR>
106 !python {model: account.voucher}: |
109 res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_seagate"), ref('bank_journal_EUR'), 120.00, False, ttype='receipt', date=False)
111 'account_id': ref('account.cash'),
113 'company_id': ref('base.main_company'),
114 'currency_id': ref('base.EUR'),
115 'journal_id': ref('bank_journal_EUR'),
116 'partner_id': ref('base.res_partner_seagate'),
117 'period_id': ref('account.period_3'),
119 'date': time.strftime("%Y-03-01"),
120 'payment_option': 'with_writeoff',
121 'writeoff_acc_id': ref('account.a_expense'),
122 'comment': 'Write Off',
123 'name': 'First payment: Case 3',
125 if not res['value']['line_cr_ids']:
126 res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
127 for item in res['value']['line_cr_ids']:
128 if item['amount_unreconciled'] == 150.00:
129 item['amount'] = 100.00
131 item['amount'] = 20.00
132 vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
133 id = self.create(cr, uid, vals)
134 voucher_id = self.browse(cr, uid, id)
135 assert (voucher_id.state=='draft'), "Voucher is not in draft state"
137 I check that writeoff amount computed is 0.00
139 !python {model: account.voucher}: |
140 voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_seagate'))])
141 voucher_id = self.browse(cr, uid, voucher[0])
142 assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0.00"
144 I confirm the voucher
146 !python {model: account.voucher}: |
148 voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_seagate'))])
149 wf_service = netsvc.LocalService("workflow")
150 wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
152 I check that the move of my first voucher is valid
154 !python {model: account.voucher}: |
155 voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_seagate'))])
156 voucher_id = self.browse(cr, uid, voucher[0])
157 move_line_obj = self.pool.get('account.move.line')
158 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
159 for move_line in move_line_obj.browse(cr, uid, move_lines):
160 assert move_line.state == 'valid', "Voucher move is not valid"
162 I check that my debtor account is correct
164 I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 20 and 100 respectively
166 !python {model: account.voucher}: |
167 voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_seagate'))])
168 voucher_id = self.browse(cr, uid, voucher[0])
169 move_line_obj = self.pool.get('account.move.line')
170 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
171 for move_line in move_line_obj.browse(cr, uid, move_lines):
172 if move_line.credit == 20.00:
173 assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
174 elif move_line.credit == 100.00:
175 assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
177 I check the residual amount of Invoice1 is 50
179 !python {model: account.invoice}: |
180 invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
181 move_line_obj = self.pool.get('account.move.line')
182 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
183 move_line = move_line_obj.browse(cr, uid, move_lines[0])
184 assert (move_line.amount_residual_currency == 50.0 and move_line.amount_residual == 50.0) , "Residual amount is not correct for first Invoice"
186 I check the residual amuont of Invoice2 is 60
188 !python {model: account.invoice}: |
189 invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
190 move_line_obj = self.pool.get('account.move.line')
191 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
192 move_line = move_line_obj.browse(cr, uid, move_lines[0])
193 assert (move_line.amount_residual_currency == 60.0 and move_line.amount_residual == 60.0) , "Residual amount is not correct for second Invoice"
195 I create the second voucher of payment and check to let open the debtor overpaid amount.
196 <create with values 120 EUR, journal EUR, and fill amounts 50 for the invoice of 150 EUR and 70 for the invoice of 80 EUR>
198 !python {model: account.voucher}: |
201 res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_seagate"), ref('bank_journal_EUR'), 120.00, False, ttype='receipt', date=False)
203 'account_id': ref('account.cash'),
205 'company_id': ref('base.main_company'),
206 'currency_id': ref('base.EUR'),
207 'journal_id': ref('bank_journal_EUR'),
208 'partner_id': ref('base.res_partner_seagate'),
209 'period_id': ref('account.period_3'),
211 'date': time.strftime("%Y-04-01"),
212 'payment_option': 'with_writeoff',
213 'writeoff_acc_id': ref('account.a_expense'),
214 'comment': 'Write Off',
215 'name': 'Second payment: Case 3',
217 if not res['value']['line_cr_ids']:
218 res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
219 for item in res['value']['line_cr_ids']:
220 if item['amount_unreconciled'] == 50.00:
221 item['amount'] = 50.00
222 elif item['amount_unreconciled'] == 60.00:
223 item['amount'] = 70.00
224 vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
225 id = self.create(cr, uid, vals)
226 voucher_id = self.browse(cr, uid, id)
227 assert (voucher_id.state=='draft'), "Voucher is not in draft state"
229 I check that writeoff amount computed is 0.00
231 !python {model: account.voucher}: |
232 voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'),('partner_id', '=', ref('base.res_partner_seagate'))])
233 voucher_id = self.browse(cr, uid, voucher[0])
234 assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0"
236 I confirm the voucher
238 !python {model: account.voucher}: |
240 voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_seagate'))])
241 wf_service = netsvc.LocalService("workflow")
242 wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
244 I check that the move of my second voucher is valid
246 !python {model: account.voucher}: |
247 voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_seagate'))])
248 voucher_id = self.browse(cr, uid, voucher[0])
249 move_line_obj = self.pool.get('account.move.line')
250 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
251 for move_line in move_line_obj.browse(cr, uid, move_lines):
252 assert move_line.state == 'valid', "Voucher move is not valid"
254 I check that my debtor account is correct
256 I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 70 and 50
258 !python {model: account.voucher}: |
259 voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_seagate'))])
260 voucher_id = self.browse(cr, uid, voucher[0])
261 move_line_obj = self.pool.get('account.move.line')
262 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
263 for move_line in move_line_obj.browse(cr, uid, move_lines):
264 if move_line.credit == 70.00:
265 assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
266 elif move_line.credit == 50.00:
267 assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
269 I check the residual amount of Invoice1 is 0
271 !python {model: account.invoice}: |
272 invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
273 move_line_obj = self.pool.get('account.move.line')
274 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
275 move_line = move_line_obj.browse(cr, uid, move_lines[0])
276 assert (move_line.amount_residual_currency == 0 and move_line.amount_residual == 0) , "Residual amount is not correct for first Invoice"
278 I check the residual amuont of Invoice2 is -10
280 !python {model: account.invoice}: |
281 invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
282 move_line_obj = self.pool.get('account.move.line')
283 move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
284 move_line = move_line_obj.browse(cr, uid, move_lines[0])
285 assert (move_line.amount_residual_currency == -10.0 and move_line.amount_residual == -10.0) , "Residual amount is not correct for second Invoice"