Merge lp:~openerp-venezuela/openerp-venezuela-localization/l10n_ve_fiscal_req-debit_credit-dev_sabrina into lp:openerp-venezuela-localization

Proposed by Sabrina Romero - http://www.vauxoo.com
Status: Needs review
Proposed branch: lp:~openerp-venezuela/openerp-venezuela-localization/l10n_ve_fiscal_req-debit_credit-dev_sabrina
Merge into: lp:openerp-venezuela-localization
Diff against target: 1399 lines (+1242/-68)
4 files modified
l10n_ve_fiscal_requirements/__openerp__.py (+2/-0)
l10n_ve_fiscal_requirements/test/account_customer_refund.yml (+602/-0)
l10n_ve_fiscal_requirements/test/account_supplier_refund.yml (+622/-0)
l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py (+16/-68)
To merge this branch: bzr merge lp:~openerp-venezuela/openerp-venezuela-localization/l10n_ve_fiscal_req-debit_credit-dev_sabrina
Reviewer Review Type Date Requested Status
Sabrina Romero - http://www.vauxoo.com Needs Resubmitting
hbto [Vauxoo] http://www.vauxoo.com Approve
Review via email: mp+202785@code.launchpad.net

Description of the change

[FIX] Changes for compatibility with debit_credit_note dependency. Removing redundancy.

To post a comment you must log in.
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) :
review: Needs Fixing
975. By Sabrina Romero - http://www.vauxoo.com

[FIX] Methods belonging to OVL were removed of debit_credit_note module.

Revision history for this message
Sabrina Romero - http://www.vauxoo.com (sabrina) wrote :

[FIX] Methods belonging to OVL were removed of debit_credit_note module.

review: Needs Resubmitting
976. By Sabrina Romero - http://www.vauxoo.com

[ADD] Refund tests added for customer and supplier.

Revision history for this message
Sabrina Romero - http://www.vauxoo.com (sabrina) wrote :

[ADD] Refund tests added for customer and supplier.

review: Needs Resubmitting
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote :

It LGTM,

I will make a last revision and after testing the whole OVL

with this new proposal and if everything goes fine I will

merge it today.

Best Regards.

review: Approve
977. By Sabrina Romero - http://www.vauxoo.com

[FIX] amount_total correct assignment.

Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote :

LGTM

review: Approve
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote :

Will be merged when AV70 fixess in Sabrina's branches are merged

978. By Sabrina Romero - http://www.vauxoo.com

[FIX] Using browse method instead read and splitting date removed.

Revision history for this message
Sabrina Romero - http://www.vauxoo.com (sabrina) wrote :

[FIX] Using browse method instead read and splitting date removed.
Tested to review 978, working!

review: Needs Resubmitting

Unmerged revisions

978. By Sabrina Romero - http://www.vauxoo.com

[FIX] Using browse method instead read and splitting date removed.

977. By Sabrina Romero - http://www.vauxoo.com

[FIX] amount_total correct assignment.

976. By Sabrina Romero - http://www.vauxoo.com

[ADD] Refund tests added for customer and supplier.

975. By Sabrina Romero - http://www.vauxoo.com

[FIX] Methods belonging to OVL were removed of debit_credit_note module.

974. By Sabrina Romero - http://www.vauxoo.com

[FIX] Changes for compatibility with debit_credit_note dependency.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'l10n_ve_fiscal_requirements/__openerp__.py'
--- l10n_ve_fiscal_requirements/__openerp__.py 2014-01-20 13:03:50 +0000
+++ l10n_ve_fiscal_requirements/__openerp__.py 2014-02-11 00:22:34 +0000
@@ -96,6 +96,8 @@
96 'test': [96 'test': [
97 'test/account_customer_invoice.yml',97 'test/account_customer_invoice.yml',
98 'test/account_supplier_invoice.yml',98 'test/account_supplier_invoice.yml',
99 'test/account_customer_refund.yml',
100 'test/account_supplier_refund.yml',
99 'test/fr_vat_search_test.yml',101 'test/fr_vat_search_test.yml',
100 'test/fr_ut_test.yml',102 'test/fr_ut_test.yml',
101 'test/fr_vat_test.yml',103 'test/fr_vat_test.yml',
102104
=== added file 'l10n_ve_fiscal_requirements/test/account_customer_refund.yml'
--- l10n_ve_fiscal_requirements/test/account_customer_refund.yml 1970-01-01 00:00:00 +0000
+++ l10n_ve_fiscal_requirements/test/account_customer_refund.yml 2014-02-11 00:22:34 +0000
@@ -0,0 +1,602 @@
1-
2 I set the context that will be used for the encoding of all the invoices of this file
3-
4 !context
5 'type': 'out_invoice'
6-
7 1.- In order to test account refund with "Create a draft refund" method
8-
9 1.1.- I create a customer invoice
10-
11 !record {model: account.invoice, id: account_invoice_customer0, view: account.invoice_form}: &customer_invoice
12 payment_term: account.account_payment_term_advance
13 journal_id: account.sales_journal
14 partner_id: base.res_partner_3
15 reference_type: none
16 name: 'Test Customer Invoice - debit_credit_note'
17 invoice_line:
18 - product_id: product.product_product_5
19 price_unit: 850.0
20 quantity: 1.0
21-
22 1.2.- I check that Initially customer invoice state is "Draft"
23-
24 !assert {model: account.invoice, id: account_invoice_customer0}:
25 - state == 'draft'
26-
27 1.3.- I check that the customer invoice is a "Customer Invoice"
28-
29 !assert {model: account.invoice, id: account_invoice_customer0, string: This is not a customer invoice}:
30 - type == 'out_invoice'
31-
32 1.4.- I change the state of invoice to open by clicking Validate button
33-
34 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0}
35-
36 1.5.- I check that the invoice state is now "Open"
37-
38 !assert {model: account.invoice, id: account_invoice_customer0}:
39 - state == 'open'
40-
41 1.6.- I create a customer refund using the method "Create a draft refund" and
42 check the state of the account invoice refund resulting
43-
44 !python {model: account.invoice.refund}: |
45 import time
46 values = {
47 'date': time.strftime('%Y-%m-%d'),
48 'period': self.pool.get('account.period').find(
49 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
50 'journal_id': ref('account.refund_expenses_journal'),
51 'description': 'Desde el test',
52 'filter_refund': 'refund',
53 }
54 wzr_id = self.create(cr, uid, values)
55 assert wzr_id, 'The wizard instance was not created.'
56 context['wzr_id'] = wzr_id
57 context['active_ids'] = [ref('account_invoice_customer0')]
58 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
59 assert rfnd_id, 'The refund was not created.'
60 context['rfnd_id'] = rfnd_id
61 obj_inv = self.pool.get('account.invoice')
62 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
63 assert rfnd_customer_inv_brw[0].state == 'draft', 'The customer refund was not properly created, the state must be Draft.'
64-
65 1.7.- I check the correct asigning of parent_id in the customer refund created, for that
66 the customer refund must have the customer invoice id in the fiel parent_id
67-
68 !python {model: account.invoice.refund}: |
69 obj_inv = self.pool.get('account.invoice')
70 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
71 customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer0'))
72 assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
73-
74 2.- In order to test account refund with "Create refund and reconcile" method
75-
76 2.1.- I create a new customer invoice
77-
78 !record {model: account.invoice, id: account_invoice_customer1, view: account.invoice_form }:
79 <<: *customer_invoice
80-
81 2.2.- I check that Initially customer invoice state is "Draft"
82-
83 !assert {model: account.invoice, id: account_invoice_customer1}:
84 - state == 'draft'
85-
86 2.3.- I check that the customer invoice is a "Customer Invoice"
87-
88 !assert {model: account.invoice, id: account_invoice_customer1, string: This is not a customer invoice}:
89 - type == 'out_invoice'
90-
91 2.4.- I change the state of invoice to open by clicking Validate button
92-
93 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer1}
94-
95 2.5.- I check that the invoice state is now "Open"
96-
97 !assert {model: account.invoice, id: account_invoice_customer1}:
98 - state == 'open'
99-
100 2.6.- I create a customer refund using the method "Create refund and reconcile" and
101 check the state of the account invoice refund resulting
102-
103 !python {model: account.invoice.refund}: |
104 import time
105 values = {
106 'date': time.strftime('%Y-%m-%d'),
107 'period': self.pool.get('account.period').find(
108 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
109 'journal_id': ref('account.refund_expenses_journal'),
110 'description': 'Desde el test',
111 'filter_refund': 'cancel',
112 }
113 wzr_id = self.create(cr, uid, values)
114 assert wzr_id, 'The wizard instance was not created.'
115 context['wzr_id'] = wzr_id
116 context['active_ids'] = [ref('account_invoice_customer1')]
117 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
118 assert rfnd_id, 'The refund was not created.'
119 context['rfnd_id'] = rfnd_id
120 obj_inv = self.pool.get('account.invoice')
121 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
122 assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
123-
124 2.7.- I check the correct asigning of parent_id in the customer refund created, for that
125 the customer refund must have the customer invoice id in the fiel parent_id
126-
127 !python {model: account.invoice.refund}: |
128 obj_inv = self.pool.get('account.invoice')
129 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
130 customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer1'))
131 assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
132-
133 3.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
134 method
135-
136 3.1.- I create a new customer invoice
137-
138 !record {model: account.invoice, id: account_invoice_customer2, view: account.invoice_form }:
139 <<: *customer_invoice
140-
141 3.2.- I check that Initially customer invoice state is "Draft"
142-
143 !assert {model: account.invoice, id: account_invoice_customer2}:
144 - state == 'draft'
145-
146 3.3.- I check that the customer invoice is a "Customer Invoice"
147-
148 !assert {model: account.invoice, id: account_invoice_customer2, string: This is not a customer invoice}:
149 - type == 'out_invoice'
150-
151 3.4.- I change the state of invoice to open by clicking Validate button
152-
153 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer2}
154-
155 3.5.- I check that the invoice state is now "Open"
156-
157 !assert {model: account.invoice, id: account_invoice_customer2}:
158 - state == 'open'
159-
160 3.6.- I create a customer refund using the method "Create refund, reconcile and create a new draft invoice" and
161 check the state of the account invoice refund resulting
162-
163 !python {model: account.invoice.refund}: |
164 import time
165 values = {
166 'date': time.strftime('%Y-%m-%d'),
167 'period': self.pool.get('account.period').find(
168 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
169 'journal_id': ref('account.refund_expenses_journal'),
170 'description': 'Desde el test',
171 'filter_refund': 'modify',
172 }
173 wzr_id = self.create(cr, uid, values)
174 assert wzr_id, 'The wizard instance was not created.'
175 context['wzr_id'] = wzr_id
176 context['active_ids'] = [ref('account_invoice_customer2')]
177 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
178 assert rfnd_id, 'The refund was not created.'
179 context['rfnd_id'] = rfnd_id
180 obj_inv = self.pool.get('account.invoice')
181 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
182 assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
183-
184 3.7.- I check the correct asigning of parent_id in the customer refund created, for that
185 the customer refund must have the customer invoice id in the fiel parent_id
186-
187 !python {model: account.invoice.refund}: |
188 obj_inv = self.pool.get('account.invoice')
189 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
190 customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer2'))
191 assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
192-
193 3.8.- I check that the new customer invoice was created in Draft state
194-
195 !python {model: account.invoice.refund}: |
196 obj_inv = self.pool.get('account.invoice')
197 inv_src = obj_inv.search(cr, uid, [], order='id')
198 customer_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
199 assert customer_inv_brw.state == 'draft', 'The new customer invoice was not properly created, the state must be Draft.'
200-
201 4.- In order to test account refund with "Create a draft refund" method in a "Paid" invoice
202-
203 4.1.- I create a new partner
204-
205 !record {model: 'res.partner', id: res_partner8}:
206 name: Juan Perez
207 use_parent_address: True
208 function: Tests
209 email: juan@perez.com
210-
211 4.2.- I create a Sale Journal.
212-
213 !record {model: account.journal, id: sale_journal_debit}:
214 code: sjou_test
215 company_id: base.main_company
216 name: Sale Journal For Debit Credit Note Tests
217 sequence_id: account.sequence_sale_journal
218 type: sale
219-
220 4.3.- I create a new customer invoice
221-
222 !record {model: account.invoice, id: account_invoice_customer3}:
223 account_id: account.a_recv
224 company_id: base.main_company
225 currency_id: base.EUR
226 invoice_line:
227 - account_id: account.a_sale
228 name: '[PCSC234] PC Assemble SC234'
229 price_unit: 450.0
230 quantity: 1.0
231 product_id: product.product_product_3
232 uos_id: product.product_uom_unit
233 journal_id: sale_journal_debit
234 partner_id: res_partner8
235-
236 4.4.- I check that Initially customer invoice state is "Draft"
237-
238 !assert {model: account.invoice, id: account_invoice_customer3}:
239 - state == 'draft'
240-
241 4.5.- I check that the customer invoice is a "Customer Invoice"
242-
243 !assert {model: account.invoice, id: account_invoice_customer3, string: This is not a customer invoice}:
244 - type == 'out_invoice'
245-
246 4.6.- I change the state of invoice to open by clicking Validate button
247-
248 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer3}
249-
250 4.7.- I check that the invoice state is now "Open"
251-
252 !assert {model: account.invoice, id: account_invoice_customer3}:
253 - state == 'open'
254-
255 4.8.- I check that a payment entry gets created in the account.move.line
256-
257 !python {model: account.invoice}: |
258 acc_id=self.browse(cr, uid, ref("account_invoice_customer3"))
259 assert(acc_id.move_id)
260-
261 4.9.- I create a Cash Journal.
262-
263 !record {model: account.journal, id: cash_journal_debit}:
264 code: cjou_test
265 company_id: base.main_company
266 name: Cash Journal For Debit Credit Note Tests
267 sequence_id: account.sequence_cash_journal
268 type: cash
269-
270 4.10.- I will create and post an account voucher with the amount total
271 of the customer invoice created for the partner Juan Perez.
272-
273 !python {model: account.voucher}: |
274 import netsvc
275 import time
276 vals = {}
277 amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer3')], context=None)[0].amount_total
278 journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
279 res = self.onchange_partner_id(cr, uid, [], ref("res_partner8"), journal_id, 0.0, 1, ttype='receipt', date=False)
280 vals = {
281 'account_id': ref('account.cash'),
282 'amount': amount_total,
283 'company_id': ref('base.main_company'),
284 'journal_id': ref('cash_journal_debit'),
285 'partner_id': ref('res_partner8'),
286 'period_id': self.pool.get('account.period').find(
287 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
288 'type': 'receipt',
289 }
290 if not res['value']['line_cr_ids']:
291 res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
292 res['value']['line_cr_ids'][0]['amount'] = amount_total
293 vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
294 id = self.create(cr, uid, vals)
295 voucher_id = self.browse(cr, uid, id)
296 assert (voucher_id.state=='draft'), "Voucher is not in draft state"
297 wf_service = netsvc.LocalService("workflow")
298 wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
299-
300 4.11.- I check if the state of the invoice is "Paid"
301-
302 !assert {model: account.invoice, id: account_invoice_customer3}:
303 - state == 'paid'
304-
305 4.12.- I modified the sale journal record so it can cancel invoice
306-
307 !record {model: account.journal, id: sale_journal_debit}:
308 update_posted: 1
309-
310 4.13.- I modified the cash journal record so it can cancel invoice
311-
312 !record {model: account.journal, id: cash_journal_debit}:
313 update_posted: 1
314-
315 4.14.- I create a Sale Refund Journal.
316-
317 !record {model: account.journal, id: sale_refund_journal_debit}:
318 code: csrjou_test
319 company_id: base.main_company
320 name: Sale Refund Journal For Debit Credit Note Tests
321 sequence_id: account.sequence_refund_sales_journal
322 type: sale_refund
323-
324 4.15.- I create a customer refund using the method "Create a draft refund" and
325 check the state of the account invoice refund resulting
326-
327 !python {model: account.invoice.refund}: |
328 import time
329 values = {
330 'date': time.strftime('%Y-%m-%d'),
331 'period': self.pool.get('account.period').find(
332 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
333 'journal_id': ref('sale_refund_journal_debit'),
334 'description': 'Desde el test',
335 'filter_refund': 'refund',
336 }
337 wzr_id = self.create(cr, uid, values)
338 assert wzr_id, 'The wizard instance was not created.'
339 context['wzr_id'] = wzr_id
340 context['active_ids'] = [ref('account_invoice_customer3')]
341 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
342 assert rfnd_id, 'The refund was not created.'
343 context['rfnd_id'] = rfnd_id
344 obj_inv = self.pool.get('account.invoice')
345 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
346 assert rfnd_customer_inv_brw[0].state == 'draft', 'The customer refund was not properly created, the state must be Draft.'
347-
348 4.16.- I check the correct asigning of parent_id in the customer refund created, for that
349 the customer refund must have the customer invoice id in the fiel parent_id
350-
351 !python {model: account.invoice.refund}: |
352 obj_inv = self.pool.get('account.invoice')
353 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
354 customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer3'))
355 assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
356-
357 5.- In order to test account refund with "Create refund and reconcile" method in a "Paid" invoice
358-
359 5.1.- I create a new partner
360-
361 !record {model: 'res.partner', id: res_partner7}:
362 name: Pedro Perez
363 use_parent_address: True
364 function: Tests
365 email: pedro@perez.com
366-
367 5.2.- I create a new customer invoice
368-
369 !record {model: account.invoice, id: account_invoice_customer4}:
370 account_id: account.a_recv
371 company_id: base.main_company
372 currency_id: base.EUR
373 invoice_line:
374 - account_id: account.a_sale
375 name: '[PCSC234] PC Assemble SC234'
376 price_unit: 450.0
377 quantity: 1.0
378 product_id: product.product_product_3
379 uos_id: product.product_uom_unit
380 journal_id: sale_journal_debit
381 partner_id: res_partner7
382-
383 5.3.- I check that Initially customer invoice state is "Draft"
384-
385 !assert {model: account.invoice, id: account_invoice_customer4}:
386 - state == 'draft'
387-
388 5.4.- I check that the customer invoice is a "Customer Invoice"
389-
390 !assert {model: account.invoice, id: account_invoice_customer4, string: This is not a customer invoice}:
391 - type == 'out_invoice'
392-
393 5.5.- I change the state of invoice to open by clicking Validate button
394-
395 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer4}
396-
397 5.6.- I check that the invoice state is now "Open"
398-
399 !assert {model: account.invoice, id: account_invoice_customer4}:
400 - state == 'open'
401-
402 5.7.- I check that a payment entry gets created in the account.move.line
403-
404 !python {model: account.invoice}: |
405 acc_id=self.browse(cr, uid, ref("account_invoice_customer4"))
406 assert(acc_id.move_id)
407-
408 5.8.- I will create and post an account voucher with the amount total
409 of the customer invoice created for the partner Pedro Perez.
410-
411 !python {model: account.voucher}: |
412 import netsvc
413 import time
414 vals = {}
415 amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer4')], context=None)[0].amount_total
416 journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
417 res = self.onchange_partner_id(cr, uid, [], ref("res_partner7"), journal_id, 0.0, 1, ttype='receipt', date=False)
418 vals = {
419 'account_id': ref('account.cash'),
420 'amount': amount_total,
421 'company_id': ref('base.main_company'),
422 'journal_id': ref('cash_journal_debit'),
423 'partner_id': ref('res_partner7'),
424 'period_id': self.pool.get('account.period').find(
425 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
426 'type': 'receipt',
427 }
428 if not res['value']['line_cr_ids']:
429 res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
430 res['value']['line_cr_ids'][0]['amount'] = amount_total
431 vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
432 id = self.create(cr, uid, vals)
433 voucher_id = self.browse(cr, uid, id)
434 assert (voucher_id.state=='draft'), "Voucher is not in draft state"
435 wf_service = netsvc.LocalService("workflow")
436 wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
437-
438 5.9.- I check if the state of the invoice is "Paid"
439-
440 !assert {model: account.invoice, id: account_invoice_customer4}:
441 - state == 'paid'
442-
443 5.10.- I create a customer refund using the method "Create refund and reconcile" and
444 check the state of the account invoice refund resulting
445-
446 !python {model: account.invoice.refund}: |
447 import time
448 values = {
449 'date': time.strftime('%Y-%m-%d'),
450 'period': self.pool.get('account.period').find(
451 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
452 'journal_id': ref('sale_refund_journal_debit'),
453 'description': 'Desde el test',
454 'filter_refund': 'cancel',
455 }
456 wzr_id = self.create(cr, uid, values)
457 assert wzr_id, 'The wizard instance was not created.'
458 context['wzr_id'] = wzr_id
459 context['active_ids'] = [ref('account_invoice_customer4')]
460 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
461 assert rfnd_id, 'The refund was not created.'
462 context['rfnd_id'] = rfnd_id
463 obj_inv = self.pool.get('account.invoice')
464 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
465 assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
466-
467 5.11.- I check the correct asigning of parent_id in the customer refund created, for that
468 the customer refund must have the customer invoice id in the fiel parent_id
469-
470 !python {model: account.invoice.refund}: |
471 obj_inv = self.pool.get('account.invoice')
472 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
473 customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer4'))
474 assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
475-
476 6.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
477 method in a "Paid" invoice
478-
479 6.1.- I create a new partner
480-
481 !record {model: 'res.partner', id: res_partner9}:
482 name: Maria Perez
483 use_parent_address: True
484 function: Tests
485 email: maria@perez.com
486-
487 6.2.- I create a new customer invoice
488-
489 !record {model: account.invoice, id: account_invoice_customer5}:
490 account_id: account.a_recv
491 company_id: base.main_company
492 currency_id: base.EUR
493 invoice_line:
494 - account_id: account.a_sale
495 name: '[PCSC234] PC Assemble SC234'
496 price_unit: 450.0
497 quantity: 1.0
498 product_id: product.product_product_3
499 uos_id: product.product_uom_unit
500 journal_id: sale_journal_debit
501 partner_id: res_partner9
502-
503 6.3.- I check that Initially customer invoice state is "Draft"
504-
505 !assert {model: account.invoice, id: account_invoice_customer5}:
506 - state == 'draft'
507-
508 6.4.- I check that the customer invoice is a "Customer Invoice"
509-
510 !assert {model: account.invoice, id: account_invoice_customer5, string: This is not a customer invoice}:
511 - type == 'out_invoice'
512-
513 6.5.- I change the state of invoice to open by clicking Validate button
514-
515 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer5}
516-
517 6.6.- I check that the invoice state is now "Open"
518-
519 !assert {model: account.invoice, id: account_invoice_customer5}:
520 - state == 'open'
521-
522 6.7.- I check that a payment entry gets created in the account.move.line
523-
524 !python {model: account.invoice}: |
525 acc_id=self.browse(cr, uid, ref("account_invoice_customer5"))
526 assert(acc_id.move_id)
527-
528 6.8.- I will create and post an account voucher with the amount total
529 of the customer invoice created for the partner Maria Perez.
530-
531 !python {model: account.voucher}: |
532 import netsvc
533 import time
534 vals = {}
535 amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer5')], context=None)[0].amount_total
536 journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
537 res = self.onchange_partner_id(cr, uid, [], ref("res_partner9"), journal_id, 0.0, 1, ttype='receipt', date=False)
538 vals = {
539 'account_id': ref('account.cash'),
540 'amount': amount_total,
541 'company_id': ref('base.main_company'),
542 'journal_id': ref('cash_journal_debit'),
543 'partner_id': ref('res_partner9'),
544 'period_id': self.pool.get('account.period').find(
545 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
546 'type': 'receipt',
547 }
548 if not res['value']['line_cr_ids']:
549 res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
550 res['value']['line_cr_ids'][0]['amount'] = amount_total
551 vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
552 id = self.create(cr, uid, vals)
553 voucher_id = self.browse(cr, uid, id)
554 assert (voucher_id.state=='draft'), "Voucher is not in draft state"
555 wf_service = netsvc.LocalService("workflow")
556 wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
557-
558 6.9.- I check if the state of the invoice is "Paid"
559-
560 !assert {model: account.invoice, id: account_invoice_customer5}:
561 - state == 'paid'
562-
563 6.10.- I create a customer refund using the method "Create refund, reconcile and create a new draft invoice" and
564 check the state of the account invoice refund resulting
565-
566 !python {model: account.invoice.refund}: |
567 import time
568 values = {
569 'date': time.strftime('%Y-%m-%d'),
570 'period': self.pool.get('account.period').find(
571 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
572 'journal_id': ref('sale_refund_journal_debit'),
573 'description': 'Desde el test',
574 'filter_refund': 'modify',
575 }
576 wzr_id = self.create(cr, uid, values)
577 assert wzr_id, 'The wizard instance was not created.'
578 context['wzr_id'] = wzr_id
579 context['active_ids'] = [ref('account_invoice_customer5')]
580 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
581 assert rfnd_id, 'The refund was not created.'
582 context['rfnd_id'] = rfnd_id
583 obj_inv = self.pool.get('account.invoice')
584 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
585 assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
586-
587 6.11.- I check the correct asigning of parent_id in the customer refund created, for that
588 the customer refund must have the customer invoice id in the fiel parent_id
589-
590 !python {model: account.invoice.refund}: |
591 obj_inv = self.pool.get('account.invoice')
592 rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
593 customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer5'))
594 assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
595-
596 6.12.- I check that the new customer invoice was created in Draft state
597-
598 !python {model: account.invoice.refund}: |
599 obj_inv = self.pool.get('account.invoice')
600 inv_src = obj_inv.search(cr, uid, [], order='id')
601 customer_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
602 assert customer_inv_brw.state == 'draft', 'The new customer invoice was not properly created, the state must be Draft.'
0603
=== added file 'l10n_ve_fiscal_requirements/test/account_supplier_refund.yml'
--- l10n_ve_fiscal_requirements/test/account_supplier_refund.yml 1970-01-01 00:00:00 +0000
+++ l10n_ve_fiscal_requirements/test/account_supplier_refund.yml 2014-02-11 00:22:34 +0000
@@ -0,0 +1,622 @@
1-
2 I set the context that will be used for the encoding of all the invoices of this file
3-
4 !context
5 'type': 'in_invoice'
6-
7 1.- In order to test account refund with "Create a draft refund" method
8-
9 1.1.- I create a supplier invoice
10-
11 !record {model: account.invoice, id: account_invoice_supplier0, view: account.invoice_supplier_form }: &supplier_invoice
12 account_id: account.a_pay
13 company_id: base.main_company
14 currency_id: base.EUR
15 invoice_line:
16 - account_id: account.a_expense
17 name: '[PCSC234] PC Assemble SC234'
18 price_unit: 300.0
19 product_id: product.product_product_3
20 quantity: 10.0
21 uos_id: product.product_uom_unit
22 journal_id: account.expenses_journal
23 partner_id: base.res_partner_12
24 reference_type: none
25 type: 'in_invoice'
26-
27 1.2.- I check that Initially supplier invoice state is "Draft"
28-
29 !assert {model: account.invoice, id: account_invoice_supplier0}:
30 - state == 'draft'
31-
32 1.3.- I check that the supplier invoice is a "Supplier Invoice"
33-
34 !assert {model: account.invoice, id: account_invoice_supplier0, string: This is not a supplier invoice}:
35 - type == 'in_invoice'
36-
37 1.4.- I change the state of invoice to open by clicking Validate button
38-
39 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0}
40-
41 1.5.- I check that the invoice state is now "Open"
42-
43 !assert {model: account.invoice, id: account_invoice_supplier0}:
44 - state == 'open'
45-
46 1.6.- I create a supplier refund using the method "Create a draft refund" and
47 check the state of the account invoice refund resulting
48-
49 !python {model: account.invoice.refund}: |
50 import time
51 values = {
52 'date': time.strftime('%Y-%m-%d'),
53 'period': self.pool.get('account.period').find(
54 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
55 'journal_id': ref('account.refund_expenses_journal'),
56 'description': 'Desde el test',
57 'nro_ctrl': 'Desde el test',
58 'filter_refund': 'refund',
59 }
60 wzr_id = self.create(cr, uid, values)
61 context['wzr_id'] = wzr_id
62 context['active_ids'] = [ref('account_invoice_supplier0')]
63 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
64 context['rfnd_id'] = rfnd_id
65 obj_inv = self.pool.get('account.invoice')
66 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
67 assert rfnd_supplier_inv_brw[0].state == 'draft', 'The supplier refund was not properly created, the state must be Draft.'
68-
69 1.7.- I check the correct asigning of parent_id in the supplier refund created, for that
70 the supplier refund must have the supplier invoice id in the fiel parent_id
71-
72 !python {model: account.invoice.refund}: |
73 obj_inv = self.pool.get('account.invoice')
74 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
75 supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier0'))
76 assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
77-
78 2.- In order to test account refund with "Create refund and reconcile" method
79-
80 2.1.- I create a new supplier invoice
81-
82 !record {model: account.invoice, id: account_invoice_supplier1, view: account.invoice_supplier_form }:
83 <<: *supplier_invoice
84-
85 2.2.- I check that Initially supplier invoice state is "Draft"
86-
87 !assert {model: account.invoice, id: account_invoice_supplier1}:
88 - state == 'draft'
89-
90 2.3.- I check that the supplier invoice is a "Supplier Invoice"
91-
92 !assert {model: account.invoice, id: account_invoice_supplier1, string: This is not a supplier invoice}:
93 - type == 'in_invoice'
94-
95 2.4.- I change the state of invoice to open by clicking Validate button
96-
97 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier1}
98-
99 2.5.- I check that the invoice state is now "Open"
100-
101 !assert {model: account.invoice, id: account_invoice_supplier1}:
102 - state == 'open'
103-
104 2.6.- I create a supplier refund using the method "Create refund and reconcile" and
105 check the state of the account invoice refund resulting
106-
107 !python {model: account.invoice.refund}: |
108 import time
109 values = {
110 'date': time.strftime('%Y-%m-%d'),
111 'period': self.pool.get('account.period').find(
112 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
113 'journal_id': ref('account.refund_expenses_journal'),
114 'description': 'Desde el test',
115 'nro_ctrl': 'Desde el test',
116 'filter_refund': 'cancel',
117 }
118 wzr_id = self.create(cr, uid, values)
119 context['wzr_id'] = wzr_id
120 context['active_ids'] = [ref('account_invoice_supplier1')]
121 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
122 context['rfnd_id'] = rfnd_id
123 obj_inv = self.pool.get('account.invoice')
124 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
125 assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
126-
127 2.7.- I check the correct asigning of parent_id in the supplier refund created, for that
128 the supplier refund must have the supplier invoice id in the fiel parent_id
129-
130 !python {model: account.invoice.refund}: |
131 obj_inv = self.pool.get('account.invoice')
132 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
133 supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier1'))
134 assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
135-
136 3.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
137 method
138-
139 3.1.- I create a new supplier invoice
140-
141 !record {model: account.invoice, id: account_invoice_supplier2, view: account.invoice_supplier_form }:
142 <<: *supplier_invoice
143-
144 3.2.- I check that Initially supplier invoice state is "Draft"
145-
146 !assert {model: account.invoice, id: account_invoice_supplier2}:
147 - state == 'draft'
148-
149 3.3.- I check that the supplier invoice is a "Supplier Invoice"
150-
151 !assert {model: account.invoice, id: account_invoice_supplier2, string: This is not a supplier invoice}:
152 - type == 'in_invoice'
153-
154 3.4.- I change the state of invoice to open by clicking Validate button
155-
156 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier2}
157-
158 3.5.- I check that the invoice state is now "Open"
159-
160 !assert {model: account.invoice, id: account_invoice_supplier2}:
161 - state == 'open'
162-
163 3.6.- I create a supplier refund using the method "Create refund, reconcile and create a new draft invoice" and
164 check the state of the account invoice refund resulting
165-
166 !python {model: account.invoice.refund}: |
167 import time
168 values = {
169 'date': time.strftime('%Y-%m-%d'),
170 'period': self.pool.get('account.period').find(
171 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
172 'journal_id': ref('account.refund_expenses_journal'),
173 'description': 'Desde el test',
174 'nro_ctrl': 'Desde el test',
175 'filter_refund': 'modify',
176 }
177 wzr_id = self.create(cr, uid, values)
178 context['wzr_id'] = wzr_id
179 context['active_ids'] = [ref('account_invoice_supplier2')]
180 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
181 context['rfnd_id'] = rfnd_id
182 obj_inv = self.pool.get('account.invoice')
183 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
184 assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
185-
186 3.7.- I check the correct asigning of parent_id in the supplier refund created, for that
187 the supplier refund must have the supplier invoice id in the fiel parent_id
188-
189 !python {model: account.invoice.refund}: |
190 obj_inv = self.pool.get('account.invoice')
191 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
192 supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier2'))
193 assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
194-
195 3.8.- I check that the new supplier invoice was created in Draft state
196-
197 !python {model: account.invoice.refund}: |
198 obj_inv = self.pool.get('account.invoice')
199 inv_src = obj_inv.search(cr, uid, [], order='id')
200 supplier_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
201 assert supplier_inv_brw.state == 'draft', 'The new supplier invoice was not properly created, the state must be Draft.'
202-
203 4.- In order to test account refund with "Create a draft refund" method in a "Paid" invoice
204-
205 4.1.- I create a new partner
206-
207 !record {model: 'res.partner', id: res_partner10}:
208 name: Juan Garcia
209 use_parent_address: True
210 function: Tests
211 email: juan@garcia.com
212 supplier: True
213-
214 4.2.- I create a Purchase Journal.
215-
216 !record {model: account.journal, id: purchase_journal_debit}:
217 code: pjou_test
218 company_id: base.main_company
219 name: Purchase Journal For Debit Credit Note Tests
220 sequence_id: account.sequence_purchase_journal
221 type: purchase
222-
223 4.3.- I create a new supplier invoice
224-
225 !record {model: account.invoice, id: account_invoice_supplier3, view: account.invoice_supplier_form }:
226 account_id: account.a_pay
227 company_id: base.main_company
228 currency_id: base.EUR
229 invoice_line:
230 - account_id: account.a_expense
231 name: '[PCSC234] PC Assemble SC234'
232 price_unit: 300.0
233 product_id: product.product_product_3
234 quantity: 10.0
235 uos_id: product.product_uom_unit
236 journal_id: purchase_journal_debit
237 partner_id: res_partner10
238 reference_type: none
239 type: 'in_invoice'
240-
241 4.4.- I check that initially supplier invoice state is "Draft"
242-
243 !assert {model: account.invoice, id: account_invoice_supplier3}:
244 - state == 'draft'
245-
246 4.5.- I check that the supplier invoice is a "Supplier Invoice"
247-
248 !assert {model: account.invoice, id: account_invoice_supplier3, string: This is not a supplier invoice}:
249 - type == 'in_invoice'
250-
251 4.6.- I change the state of invoice to open by clicking Validate button
252-
253 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier3}
254-
255 4.7.- I check that the invoice state is now "Open"
256-
257 !assert {model: account.invoice, id: account_invoice_supplier3}:
258 - state == 'open'
259-
260 4.8.- I check that a payment entry gets created in the account.move.line
261-
262 !python {model: account.invoice}: |
263 acc_id=self.browse(cr, uid, ref("account_invoice_supplier3"))
264 assert(acc_id.move_id)
265-
266 4.9.- I create a Bank Journal.
267-
268 !record {model: account.journal, id: bank_journal_debit}:
269 name: Bank Journal For Debit Credit Note Tests
270 code: bjou_test
271 type: bank
272 analytic_journal_id: account.sit
273 sequence_id: account.sequence_bank_journal
274 default_debit_account_id: account.cash
275 default_credit_account_id: account.cash
276 company_id: base.main_company
277-
278 4.10.- I will create and post an account voucher of amount 3450.00 for the partner Juan Garcia.
279-
280 !record {model: account.voucher, id: account_voucher0, view: account_voucher.view_vendor_payment_form}:
281 type: payment
282 account_id: account.cash
283 amount: 3450.00
284 company_id: base.main_company
285 journal_id: bank_journal_debit
286 name: Voucher x
287 narration: PC Assemble SC234
288 line_dr_ids:
289 - account_id: account.cash
290 amount: 3450.00
291 name: Voucher x
292 partner_id: res_partner10
293 reference: none
294-
295 4.11.- I check that initially vendor voucher is in the "Draft" state
296-
297 !assert {model: account.voucher, id: account_voucher0}:
298 - state == 'draft'
299-
300 4.12.- I create voucher by clicking on create button
301-
302 !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher0}
303-
304 4.13.- I check that the voucher state is "Posted"
305-
306 !assert {model: account.voucher, id: account_voucher0}:
307 - state == 'posted'
308-
309 4.14.- I check if the state of the invoice is "Paid"
310-
311 !assert {model: account.invoice, id: account_invoice_supplier3}:
312 - state == 'paid'
313-
314 4.15.- I modified the sale journal record so it can cancel invoice
315-
316 !record {model: account.journal, id: purchase_journal_debit}:
317 update_posted: 1
318-
319 4.16.- I modified the cash journal record so it can cancel invoice
320-
321 !record {model: account.journal, id: bank_journal_debit}:
322 update_posted: 1
323-
324 4.17.- I create a Purchase Refund Journal.
325-
326 !record {model: account.journal, id: purchase_refund_journal_debit}:
327 code: sprjou_test
328 company_id: base.main_company
329 name: Purchase Refund Journal For Debit Credit Note Tests
330 sequence_id: account.sequence_refund_purchase_journal
331 type: purchase_refund
332-
333 4.18.- I create a supplier refund using the method "Create a draft refund" and
334 check the state of the account invoice refund resulting
335-
336 !python {model: account.invoice.refund}: |
337 import time
338 values = {
339 'date': time.strftime('%Y-%m-%d'),
340 'period': self.pool.get('account.period').find(
341 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
342 'journal_id': ref('purchase_refund_journal_debit'),
343 'description': 'Desde el test',
344 'nro_ctrl': 'Desde el test',
345 'filter_refund': 'refund',
346 }
347 wzr_id = self.create(cr, uid, values)
348 assert wzr_id, 'The wizard instance was not created.'
349 context['wzr_id'] = wzr_id
350 context['active_ids'] = [ref('account_invoice_supplier3')]
351 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
352 assert rfnd_id, 'The refund was not created.'
353 context['rfnd_id'] = rfnd_id
354 obj_inv = self.pool.get('account.invoice')
355 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
356 assert rfnd_supplier_inv_brw[0].state == 'draft', 'The supplier refund was not properly created, the state must be Draft.'
357-
358 4.19.- I check the correct asigning of parent_id in the supplier refund created, for that
359 the supplier refund must have the supplier invoice id in the fiel parent_id
360-
361 !python {model: account.invoice.refund}: |
362 obj_inv = self.pool.get('account.invoice')
363 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
364 supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier3'))
365 assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
366-
367 5.- In order to test account refund with "Create refund and reconcile" method in a "Paid" invoice
368-
369 5.1.- I create a new partner
370-
371 !record {model: 'res.partner', id: res_partner11}:
372 name: Maria Garcia
373 use_parent_address: True
374 function: Tests
375 email: maria@garcia.com
376 supplier: True
377-
378 5.2.- I create a new supplier invoice
379-
380 !record {model: account.invoice, id: account_invoice_supplier4, view: account.invoice_supplier_form }:
381 account_id: account.a_pay
382 company_id: base.main_company
383 currency_id: base.EUR
384 invoice_line:
385 - account_id: account.a_expense
386 name: '[PCSC234] PC Assemble SC234'
387 price_unit: 300.0
388 product_id: product.product_product_3
389 quantity: 10.0
390 uos_id: product.product_uom_unit
391 journal_id: purchase_journal_debit
392 partner_id: res_partner11
393 reference_type: none
394 type: 'in_invoice'
395-
396 5.3.- I check that initially supplier invoice state is "Draft"
397-
398 !assert {model: account.invoice, id: account_invoice_supplier4}:
399 - state == 'draft'
400-
401 5.4.- I check that the supplier invoice is a "Supplier Invoice"
402-
403 !assert {model: account.invoice, id: account_invoice_supplier4, string: This is not a supplier invoice}:
404 - type == 'in_invoice'
405-
406 5.5.- I change the state of invoice to open by clicking Validate button
407-
408 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier4}
409-
410 5.6.- I check that the invoice state is now "Open"
411-
412 !assert {model: account.invoice, id: account_invoice_supplier4}:
413 - state == 'open'
414-
415 5.7.- I check that a payment entry gets created in the account.move.line
416-
417 !python {model: account.invoice}: |
418 acc_id=self.browse(cr, uid, ref("account_invoice_supplier4"))
419 assert(acc_id.move_id)
420-
421 5.8.- I will create and post an account voucher of amount 3450.00 for the partner Maria Garcia.
422-
423 !record {model: account.voucher, id: account_voucher1, view: account_voucher.view_vendor_payment_form}:
424 type: payment
425 account_id: account.cash
426 amount: 3450.00
427 company_id: base.main_company
428 journal_id: bank_journal_debit
429 name: Voucher x
430 narration: PC Assemble SC234
431 line_dr_ids:
432 - account_id: account.cash
433 amount: 3450.00
434 name: Voucher x
435 partner_id: res_partner11
436 reference: none
437-
438 5.9.- I check that initially vendor voucher is in the "Draft" state
439-
440 !assert {model: account.voucher, id: account_voucher1}:
441 - state == 'draft'
442-
443 5.10.- I create voucher by clicking on create button
444-
445 !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher1}
446-
447 5.11.- I check that the voucher state is "Posted"
448-
449 !assert {model: account.voucher, id: account_voucher1}:
450 - state == 'posted'
451-
452 5.12.- I check if the state of the invoice is "Paid"
453-
454 !assert {model: account.invoice, id: account_invoice_supplier4}:
455 - state == 'paid'
456-
457 5.13.- I create a supplier refund using the method "Create refund and reconcile" and
458 check the state of the account invoice refund resulting
459-
460 !python {model: account.invoice.refund}: |
461 import time
462 values = {
463 'date': time.strftime('%Y-%m-%d'),
464 'period': self.pool.get('account.period').find(
465 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
466 'journal_id': ref('purchase_refund_journal_debit'),
467 'description': 'Desde el test',
468 'nro_ctrl': 'Desde el test',
469 'filter_refund': 'cancel',
470 }
471 wzr_id = self.create(cr, uid, values)
472 assert wzr_id, 'The wizard instance was not created.'
473 context['wzr_id'] = wzr_id
474 context['active_ids'] = [ref('account_invoice_supplier4')]
475 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
476 assert rfnd_id, 'The refund was not created.'
477 context['rfnd_id'] = rfnd_id
478 obj_inv = self.pool.get('account.invoice')
479 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
480 assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
481-
482 5.14.- I check the correct asigning of parent_id in the supplier refund created, for that
483 the supplier refund must have the supplier invoice id in the fiel parent_id
484-
485 !python {model: account.invoice.refund}: |
486 obj_inv = self.pool.get('account.invoice')
487 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
488 supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier4'))
489 assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
490-
491 6.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
492 method in a "Paid" invoice
493-
494 6.1.- I create a new partner
495-
496 !record {model: 'res.partner', id: res_partner12}:
497 name: Pablo Garcia
498 use_parent_address: True
499 function: Tests
500 email: pablo@garcia.com
501 supplier: True
502-
503 6.2.- I create a new supplier invoice
504-
505 !record {model: account.invoice, id: account_invoice_supplier5, view: account.invoice_supplier_form }:
506 account_id: account.a_pay
507 company_id: base.main_company
508 currency_id: base.EUR
509 invoice_line:
510 - account_id: account.a_expense
511 name: '[PCSC234] PC Assemble SC234'
512 price_unit: 300.0
513 product_id: product.product_product_3
514 quantity: 10.0
515 uos_id: product.product_uom_unit
516 journal_id: purchase_journal_debit
517 partner_id: res_partner12
518 reference_type: none
519 type: 'in_invoice'
520-
521 6.3.- I check that initially supplier invoice state is "Draft"
522-
523 !assert {model: account.invoice, id: account_invoice_supplier5}:
524 - state == 'draft'
525-
526 6.4.- I check that the supplier invoice is a "Supplier Invoice"
527-
528 !assert {model: account.invoice, id: account_invoice_supplier5, string: This is not a supplier invoice}:
529 - type == 'in_invoice'
530-
531 6.5.- I change the state of invoice to open by clicking Validate button
532-
533 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier5}
534-
535 5.6.- I check that the invoice state is now "Open"
536-
537 !assert {model: account.invoice, id: account_invoice_supplier5}:
538 - state == 'open'
539-
540 6.7.- I check that a payment entry gets created in the account.move.line
541-
542 !python {model: account.invoice}: |
543 acc_id=self.browse(cr, uid, ref("account_invoice_supplier5"))
544 assert(acc_id.move_id)
545-
546 6.8.- I will create and post an account voucher of amount 3450.00 for the partner Maria Garcia.
547-
548 !record {model: account.voucher, id: account_voucher2, view: account_voucher.view_vendor_payment_form}:
549 type: payment
550 account_id: account.cash
551 amount: 3450.00
552 company_id: base.main_company
553 journal_id: bank_journal_debit
554 name: Voucher x
555 narration: PC Assemble SC234
556 line_dr_ids:
557 - account_id: account.cash
558 amount: 3450.00
559 name: Voucher x
560 partner_id: res_partner12
561 reference: none
562-
563 6.9.- I check that initially vendor voucher is in the "Draft" state
564-
565 !assert {model: account.voucher, id: account_voucher2}:
566 - state == 'draft'
567-
568 6.10.- I create voucher by clicking on create button
569-
570 !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher2}
571-
572 6.11.- I check that the voucher state is "Posted"
573-
574 !assert {model: account.voucher, id: account_voucher2}:
575 - state == 'posted'
576-
577 6.12.- I check if the state of the invoice is "Paid"
578-
579 !assert {model: account.invoice, id: account_invoice_supplier5}:
580 - state == 'paid'
581-
582 6.13.- I create a supplier refund using the method "Create refund, reconcile and create a new draft invoice" and
583 check the state of the account invoice refund resulting
584-
585 !python {model: account.invoice.refund}: |
586 import time
587 values = {
588 'date': time.strftime('%Y-%m-%d'),
589 'period': self.pool.get('account.period').find(
590 cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
591 'journal_id': ref('purchase_refund_journal_debit'),
592 'description': 'Desde el test',
593 'nro_ctrl': 'Desde el test',
594 'filter_refund': 'modify',
595 }
596 wzr_id = self.create(cr, uid, values)
597 assert wzr_id, 'The wizard instance was not created.'
598 context['wzr_id'] = wzr_id
599 context['active_ids'] = [ref('account_invoice_supplier5')]
600 rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
601 assert rfnd_id, 'The refund was not created.'
602 context['rfnd_id'] = rfnd_id
603 obj_inv = self.pool.get('account.invoice')
604 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
605 assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
606-
607 6.14.- I check the correct asigning of parent_id in the supplier refund created, for that
608 the supplier refund must have the supplier invoice id in the fiel parent_id
609-
610 !python {model: account.invoice.refund}: |
611 obj_inv = self.pool.get('account.invoice')
612 rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
613 supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier5'))
614 assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
615-
616 6.15.- I check that the new supplier invoice was created in Draft state
617-
618 !python {model: account.invoice.refund}: |
619 obj_inv = self.pool.get('account.invoice')
620 inv_src = obj_inv.search(cr, uid, [], order='id')
621 supplier_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
622 assert supplier_inv_brw.state == 'draft', 'The new supplier invoice was not properly created, the state must be Draft.'
0623
=== modified file 'l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py'
--- l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2014-01-13 19:38:55 +0000
+++ l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2014-02-11 00:22:34 +0000
@@ -99,17 +99,7 @@
99 journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)99 journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
100 res['fields'][field]['selection'] = journal_select100 res['fields'][field]['selection'] = journal_select
101 return res101 return res
102102
103 def _get_orig(self, cr, uid, inv, ref, context={}):
104 """ Return default origin value
105 """
106 nro_ref = ref
107 if inv.type == 'out_invoice':
108 nro_ref = inv.number
109 orig = 'Devolucion FACT:' +(nro_ref or '') + '- DE FECHA:' + (inv.date_invoice or '') + (' TOTAL:' + str(inv.amount_total) or '')
110 return orig
111
112
113 def cn_iva_validate(self, cr, uid,invoice,context=None):103 def cn_iva_validate(self, cr, uid,invoice,context=None):
114 """ Validates if retentions have been changes to move the state confirmed and done104 """ Validates if retentions have been changes to move the state confirmed and done
115 """105 """
@@ -159,20 +149,20 @@
159 res_users_obj = self.pool.get('res.users')149 res_users_obj = self.pool.get('res.users')
160 if context is None:150 if context is None:
161 context = {}151 context = {}
162 for form in self.read(cr, uid, ids, context=context):152 for form in self.browse(cr, uid, ids, context=context):
163 created_inv = []153 created_inv = []
164 date = False154 date = False
165 period = False155 period = False
166 description = False156 description = False
167 nroctrl = False157 nroctrl = False
168 company = res_users_obj.browse(cr, uid, uid, context=context).company_id158 company = res_users_obj.browse(cr, uid, uid, context=context).company_id
169 journal_brw = form.get('journal_id', False)159 journal_brw = form.journal_id or False
170 for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):160 for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
171 if inv.state in ['draft', 'proforma2', 'cancel']:161 if inv.state in ['draft', 'proforma2', 'cancel']:
172 raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))162 raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
173 if inv.reconciled and mode in ('cancel', 'modify'):163 if inv.reconciled and mode in ('cancel', 'modify'):
174 raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode))164 raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode))
175 period = form.get('period') and form.get('period')[0] or False165 period = form.period.id or False
176 if not period:166 if not period:
177 #Take period from the current date167 #Take period from the current date
178 period = self.pool.get('account.period').find(cr, uid, context=context)168 period = self.pool.get('account.period').find(cr, uid, context=context)
@@ -185,11 +175,11 @@
185 if not journal_brw:175 if not journal_brw:
186 journal_id = inv.journal_id.id176 journal_id = inv.journal_id.id
187 else:177 else:
188 journal_id=journal_brw[0]178 journal_id=journal_brw.id
189179
190 if form['date']:180 if form.date:
191 date = form['date']181 date = form.date
192 if not form['period']:182 if not form.period:
193 cr.execute("select name from ir_model_fields \183 cr.execute("select name from ir_model_fields \
194 where model = 'account.period' \184 where model = 'account.period' \
195 and name = 'company_id'")185 and name = 'company_id'")
@@ -209,14 +199,14 @@
209 #Take current date199 #Take current date
210 #date = inv.date_invoice200 #date = inv.date_invoice
211 date = time.strftime('%Y-%m-%d')201 date = time.strftime('%Y-%m-%d')
212 if form['description']:202 if form.description:
213 description = form['description']203 description = form.description
214 else:204 else:
215 description = inv.name205 description = inv.name
216 206
217 if inv.type in ('in_invoice','in_refund'):207 if inv.type in ('in_invoice','in_refund'):
218 if form['nro_ctrl']:208 if form.nro_ctrl:
219 nroctrl = form['nro_ctrl']209 nroctrl = form.nro_ctrl
220 else:210 else:
221 raise osv.except_osv(_('Control Number !'), \211 raise osv.except_osv(_('Control Number !'), \
222 _('Missing Control Number on Invoice Refund!'))212 _('Missing Control Number on Invoice Refund!'))
@@ -321,19 +311,7 @@
321 orig = self._get_orig(cr, uid, inv, inv.supplier_invoice_number, context)311 orig = self._get_orig(cr, uid, inv, inv.supplier_invoice_number, context)
322 inv_obj.write(cr,uid,created_inv[0],{'origin':inv.origin,'name':wzd_brw.description},context=context)312 inv_obj.write(cr,uid,created_inv[0],{'origin':inv.origin,'name':wzd_brw.description},context=context)
323 return result313 return result
324314
325 def validate_total_payment_inv(self, cr, uid, ids, context=None):
326 """ Method that validate if invoice is totally paid.
327 @param ids: list of invoices.
328 return: True: if invoice is paid.
329 False: if invoice is not paid.
330 """
331 res = False
332 inv_obj = self.pool.get('account.invoice')
333 for inv in inv_obj.browse(cr, uid, ids, context=context):
334 res = inv.reconciled
335 return res
336
337 def validate_wh(self, cr, uid, ids, context=None):315 def validate_wh(self, cr, uid, ids, context=None):
338 """ Method that validate if invoice has non-yet processed withholds.316 """ Method that validate if invoice has non-yet processed withholds.
339317
@@ -345,36 +323,6 @@
345 """323 """
346 return True324 return True
347325
348 def unreconcile_paid_invoices(self, cr, uid, invoiceids, context=None):
349 """ Method that unreconcile the payments of invoice.
350 @param invoiceids: list of invoices.
351 return: True: unreconcile successfully.
352 False: unreconcile unsuccessfully.
353 """
354 inv_obj = self.pool.get('account.invoice')
355 moveline_obj = self.pool.get('account.move.line')
356 voucher_pool = self.pool.get('account.voucher')
357 res = True
358 rec = []
359 mid = []
360 if self.validate_total_payment_inv(cr, uid, invoiceids, context=context):
361 for inv in inv_obj.browse(cr, uid, invoiceids, context=context):
362 movelineids = inv_obj.move_line_id_payment_get(cr, uid,[inv.id])
363 for moveline in moveline_obj.browse(cr, uid, movelineids,context=context):
364 if moveline.reconcile_id:
365 rec += [moveline.reconcile_id.id]
366 if moveline.reconcile_partial_id:
367 rec += [moveline.reconcile_partial_id.id]
368 movelines = moveline_obj.search(cr, uid, [('|'),('reconcile_id','in',rec),('reconcile_partial_id','in',rec)],context=context)
369 for mids in moveline_obj.browse(cr, uid, movelines, context=context):
370 mid +=[mids.move_id.id]
371 voucherids = voucher_pool.search(cr, uid,[('move_id','in',mid)])
372 if voucherids:
373 voucher_pool.cancel_voucher(cr, uid, voucherids, context=context)
374 else:
375 res = False
376 return res
377
378 def invoice_refund(self, cr, uid, ids, context=None):326 def invoice_refund(self, cr, uid, ids, context=None):
379 """ Create a invoice refund327 """ Create a invoice refund
380 """328 """
@@ -383,9 +331,9 @@
383 inv_obj = self.pool.get('account.invoice')331 inv_obj = self.pool.get('account.invoice')
384 period_obj = self.pool.get('account.period')332 period_obj = self.pool.get('account.period')
385 wzr_brw = self.browse(cr,uid,ids,context=context)[0]333 wzr_brw = self.browse(cr,uid,ids,context=context)[0]
386 date = wzr_brw.date and wzr_brw.date.split('-') 334 date = wzr_brw.date
387 period = wzr_brw and wzr_brw.period and wzr_brw.period.id 335 period = wzr_brw and wzr_brw.period and wzr_brw.period.id
388 period_ids = date and len(date) == 3 and period_obj.search(cr,uid,[('code','=','%s/%s'%(date[1],date[0]))],context=context)336 period_ids = date and period_obj.search(cr,uid,[('date_start', '<=', date),('date_stop', '>=', date),('special', '=', False)],context=context)
389 if period not in period_ids:337 if period not in period_ids:
390 raise osv.except_osv(_('Error !'), \338 raise osv.except_osv(_('Error !'), \
391 _('The date should be chosen to belong to the period')) 339 _('The date should be chosen to belong to the period'))