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
1=== modified file 'l10n_ve_fiscal_requirements/__openerp__.py'
2--- l10n_ve_fiscal_requirements/__openerp__.py 2014-01-20 13:03:50 +0000
3+++ l10n_ve_fiscal_requirements/__openerp__.py 2014-02-11 00:22:34 +0000
4@@ -96,6 +96,8 @@
5 'test': [
6 'test/account_customer_invoice.yml',
7 'test/account_supplier_invoice.yml',
8+ 'test/account_customer_refund.yml',
9+ 'test/account_supplier_refund.yml',
10 'test/fr_vat_search_test.yml',
11 'test/fr_ut_test.yml',
12 'test/fr_vat_test.yml',
13
14=== added file 'l10n_ve_fiscal_requirements/test/account_customer_refund.yml'
15--- l10n_ve_fiscal_requirements/test/account_customer_refund.yml 1970-01-01 00:00:00 +0000
16+++ l10n_ve_fiscal_requirements/test/account_customer_refund.yml 2014-02-11 00:22:34 +0000
17@@ -0,0 +1,602 @@
18+-
19+ I set the context that will be used for the encoding of all the invoices of this file
20+-
21+ !context
22+ 'type': 'out_invoice'
23+-
24+ 1.- In order to test account refund with "Create a draft refund" method
25+-
26+ 1.1.- I create a customer invoice
27+-
28+ !record {model: account.invoice, id: account_invoice_customer0, view: account.invoice_form}: &customer_invoice
29+ payment_term: account.account_payment_term_advance
30+ journal_id: account.sales_journal
31+ partner_id: base.res_partner_3
32+ reference_type: none
33+ name: 'Test Customer Invoice - debit_credit_note'
34+ invoice_line:
35+ - product_id: product.product_product_5
36+ price_unit: 850.0
37+ quantity: 1.0
38+-
39+ 1.2.- I check that Initially customer invoice state is "Draft"
40+-
41+ !assert {model: account.invoice, id: account_invoice_customer0}:
42+ - state == 'draft'
43+-
44+ 1.3.- I check that the customer invoice is a "Customer Invoice"
45+-
46+ !assert {model: account.invoice, id: account_invoice_customer0, string: This is not a customer invoice}:
47+ - type == 'out_invoice'
48+-
49+ 1.4.- I change the state of invoice to open by clicking Validate button
50+-
51+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer0}
52+-
53+ 1.5.- I check that the invoice state is now "Open"
54+-
55+ !assert {model: account.invoice, id: account_invoice_customer0}:
56+ - state == 'open'
57+-
58+ 1.6.- I create a customer refund using the method "Create a draft refund" and
59+ check the state of the account invoice refund resulting
60+-
61+ !python {model: account.invoice.refund}: |
62+ import time
63+ values = {
64+ 'date': time.strftime('%Y-%m-%d'),
65+ 'period': self.pool.get('account.period').find(
66+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
67+ 'journal_id': ref('account.refund_expenses_journal'),
68+ 'description': 'Desde el test',
69+ 'filter_refund': 'refund',
70+ }
71+ wzr_id = self.create(cr, uid, values)
72+ assert wzr_id, 'The wizard instance was not created.'
73+ context['wzr_id'] = wzr_id
74+ context['active_ids'] = [ref('account_invoice_customer0')]
75+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
76+ assert rfnd_id, 'The refund was not created.'
77+ context['rfnd_id'] = rfnd_id
78+ obj_inv = self.pool.get('account.invoice')
79+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
80+ assert rfnd_customer_inv_brw[0].state == 'draft', 'The customer refund was not properly created, the state must be Draft.'
81+-
82+ 1.7.- I check the correct asigning of parent_id in the customer refund created, for that
83+ the customer refund must have the customer invoice id in the fiel parent_id
84+-
85+ !python {model: account.invoice.refund}: |
86+ obj_inv = self.pool.get('account.invoice')
87+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
88+ customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer0'))
89+ assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
90+-
91+ 2.- In order to test account refund with "Create refund and reconcile" method
92+-
93+ 2.1.- I create a new customer invoice
94+-
95+ !record {model: account.invoice, id: account_invoice_customer1, view: account.invoice_form }:
96+ <<: *customer_invoice
97+-
98+ 2.2.- I check that Initially customer invoice state is "Draft"
99+-
100+ !assert {model: account.invoice, id: account_invoice_customer1}:
101+ - state == 'draft'
102+-
103+ 2.3.- I check that the customer invoice is a "Customer Invoice"
104+-
105+ !assert {model: account.invoice, id: account_invoice_customer1, string: This is not a customer invoice}:
106+ - type == 'out_invoice'
107+-
108+ 2.4.- I change the state of invoice to open by clicking Validate button
109+-
110+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer1}
111+-
112+ 2.5.- I check that the invoice state is now "Open"
113+-
114+ !assert {model: account.invoice, id: account_invoice_customer1}:
115+ - state == 'open'
116+-
117+ 2.6.- I create a customer refund using the method "Create refund and reconcile" and
118+ check the state of the account invoice refund resulting
119+-
120+ !python {model: account.invoice.refund}: |
121+ import time
122+ values = {
123+ 'date': time.strftime('%Y-%m-%d'),
124+ 'period': self.pool.get('account.period').find(
125+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
126+ 'journal_id': ref('account.refund_expenses_journal'),
127+ 'description': 'Desde el test',
128+ 'filter_refund': 'cancel',
129+ }
130+ wzr_id = self.create(cr, uid, values)
131+ assert wzr_id, 'The wizard instance was not created.'
132+ context['wzr_id'] = wzr_id
133+ context['active_ids'] = [ref('account_invoice_customer1')]
134+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
135+ assert rfnd_id, 'The refund was not created.'
136+ context['rfnd_id'] = rfnd_id
137+ obj_inv = self.pool.get('account.invoice')
138+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
139+ assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
140+-
141+ 2.7.- I check the correct asigning of parent_id in the customer refund created, for that
142+ the customer refund must have the customer invoice id in the fiel parent_id
143+-
144+ !python {model: account.invoice.refund}: |
145+ obj_inv = self.pool.get('account.invoice')
146+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
147+ customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer1'))
148+ assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
149+-
150+ 3.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
151+ method
152+-
153+ 3.1.- I create a new customer invoice
154+-
155+ !record {model: account.invoice, id: account_invoice_customer2, view: account.invoice_form }:
156+ <<: *customer_invoice
157+-
158+ 3.2.- I check that Initially customer invoice state is "Draft"
159+-
160+ !assert {model: account.invoice, id: account_invoice_customer2}:
161+ - state == 'draft'
162+-
163+ 3.3.- I check that the customer invoice is a "Customer Invoice"
164+-
165+ !assert {model: account.invoice, id: account_invoice_customer2, string: This is not a customer invoice}:
166+ - type == 'out_invoice'
167+-
168+ 3.4.- I change the state of invoice to open by clicking Validate button
169+-
170+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer2}
171+-
172+ 3.5.- I check that the invoice state is now "Open"
173+-
174+ !assert {model: account.invoice, id: account_invoice_customer2}:
175+ - state == 'open'
176+-
177+ 3.6.- I create a customer refund using the method "Create refund, reconcile and create a new draft invoice" and
178+ check the state of the account invoice refund resulting
179+-
180+ !python {model: account.invoice.refund}: |
181+ import time
182+ values = {
183+ 'date': time.strftime('%Y-%m-%d'),
184+ 'period': self.pool.get('account.period').find(
185+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
186+ 'journal_id': ref('account.refund_expenses_journal'),
187+ 'description': 'Desde el test',
188+ 'filter_refund': 'modify',
189+ }
190+ wzr_id = self.create(cr, uid, values)
191+ assert wzr_id, 'The wizard instance was not created.'
192+ context['wzr_id'] = wzr_id
193+ context['active_ids'] = [ref('account_invoice_customer2')]
194+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
195+ assert rfnd_id, 'The refund was not created.'
196+ context['rfnd_id'] = rfnd_id
197+ obj_inv = self.pool.get('account.invoice')
198+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
199+ assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
200+-
201+ 3.7.- I check the correct asigning of parent_id in the customer refund created, for that
202+ the customer refund must have the customer invoice id in the fiel parent_id
203+-
204+ !python {model: account.invoice.refund}: |
205+ obj_inv = self.pool.get('account.invoice')
206+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
207+ customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer2'))
208+ assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
209+-
210+ 3.8.- I check that the new customer invoice was created in Draft state
211+-
212+ !python {model: account.invoice.refund}: |
213+ obj_inv = self.pool.get('account.invoice')
214+ inv_src = obj_inv.search(cr, uid, [], order='id')
215+ customer_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
216+ assert customer_inv_brw.state == 'draft', 'The new customer invoice was not properly created, the state must be Draft.'
217+-
218+ 4.- In order to test account refund with "Create a draft refund" method in a "Paid" invoice
219+-
220+ 4.1.- I create a new partner
221+-
222+ !record {model: 'res.partner', id: res_partner8}:
223+ name: Juan Perez
224+ use_parent_address: True
225+ function: Tests
226+ email: juan@perez.com
227+-
228+ 4.2.- I create a Sale Journal.
229+-
230+ !record {model: account.journal, id: sale_journal_debit}:
231+ code: sjou_test
232+ company_id: base.main_company
233+ name: Sale Journal For Debit Credit Note Tests
234+ sequence_id: account.sequence_sale_journal
235+ type: sale
236+-
237+ 4.3.- I create a new customer invoice
238+-
239+ !record {model: account.invoice, id: account_invoice_customer3}:
240+ account_id: account.a_recv
241+ company_id: base.main_company
242+ currency_id: base.EUR
243+ invoice_line:
244+ - account_id: account.a_sale
245+ name: '[PCSC234] PC Assemble SC234'
246+ price_unit: 450.0
247+ quantity: 1.0
248+ product_id: product.product_product_3
249+ uos_id: product.product_uom_unit
250+ journal_id: sale_journal_debit
251+ partner_id: res_partner8
252+-
253+ 4.4.- I check that Initially customer invoice state is "Draft"
254+-
255+ !assert {model: account.invoice, id: account_invoice_customer3}:
256+ - state == 'draft'
257+-
258+ 4.5.- I check that the customer invoice is a "Customer Invoice"
259+-
260+ !assert {model: account.invoice, id: account_invoice_customer3, string: This is not a customer invoice}:
261+ - type == 'out_invoice'
262+-
263+ 4.6.- I change the state of invoice to open by clicking Validate button
264+-
265+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer3}
266+-
267+ 4.7.- I check that the invoice state is now "Open"
268+-
269+ !assert {model: account.invoice, id: account_invoice_customer3}:
270+ - state == 'open'
271+-
272+ 4.8.- I check that a payment entry gets created in the account.move.line
273+-
274+ !python {model: account.invoice}: |
275+ acc_id=self.browse(cr, uid, ref("account_invoice_customer3"))
276+ assert(acc_id.move_id)
277+-
278+ 4.9.- I create a Cash Journal.
279+-
280+ !record {model: account.journal, id: cash_journal_debit}:
281+ code: cjou_test
282+ company_id: base.main_company
283+ name: Cash Journal For Debit Credit Note Tests
284+ sequence_id: account.sequence_cash_journal
285+ type: cash
286+-
287+ 4.10.- I will create and post an account voucher with the amount total
288+ of the customer invoice created for the partner Juan Perez.
289+-
290+ !python {model: account.voucher}: |
291+ import netsvc
292+ import time
293+ vals = {}
294+ amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer3')], context=None)[0].amount_total
295+ journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
296+ res = self.onchange_partner_id(cr, uid, [], ref("res_partner8"), journal_id, 0.0, 1, ttype='receipt', date=False)
297+ vals = {
298+ 'account_id': ref('account.cash'),
299+ 'amount': amount_total,
300+ 'company_id': ref('base.main_company'),
301+ 'journal_id': ref('cash_journal_debit'),
302+ 'partner_id': ref('res_partner8'),
303+ 'period_id': self.pool.get('account.period').find(
304+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
305+ 'type': 'receipt',
306+ }
307+ if not res['value']['line_cr_ids']:
308+ res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
309+ res['value']['line_cr_ids'][0]['amount'] = amount_total
310+ vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
311+ id = self.create(cr, uid, vals)
312+ voucher_id = self.browse(cr, uid, id)
313+ assert (voucher_id.state=='draft'), "Voucher is not in draft state"
314+ wf_service = netsvc.LocalService("workflow")
315+ wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
316+-
317+ 4.11.- I check if the state of the invoice is "Paid"
318+-
319+ !assert {model: account.invoice, id: account_invoice_customer3}:
320+ - state == 'paid'
321+-
322+ 4.12.- I modified the sale journal record so it can cancel invoice
323+-
324+ !record {model: account.journal, id: sale_journal_debit}:
325+ update_posted: 1
326+-
327+ 4.13.- I modified the cash journal record so it can cancel invoice
328+-
329+ !record {model: account.journal, id: cash_journal_debit}:
330+ update_posted: 1
331+-
332+ 4.14.- I create a Sale Refund Journal.
333+-
334+ !record {model: account.journal, id: sale_refund_journal_debit}:
335+ code: csrjou_test
336+ company_id: base.main_company
337+ name: Sale Refund Journal For Debit Credit Note Tests
338+ sequence_id: account.sequence_refund_sales_journal
339+ type: sale_refund
340+-
341+ 4.15.- I create a customer refund using the method "Create a draft refund" and
342+ check the state of the account invoice refund resulting
343+-
344+ !python {model: account.invoice.refund}: |
345+ import time
346+ values = {
347+ 'date': time.strftime('%Y-%m-%d'),
348+ 'period': self.pool.get('account.period').find(
349+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
350+ 'journal_id': ref('sale_refund_journal_debit'),
351+ 'description': 'Desde el test',
352+ 'filter_refund': 'refund',
353+ }
354+ wzr_id = self.create(cr, uid, values)
355+ assert wzr_id, 'The wizard instance was not created.'
356+ context['wzr_id'] = wzr_id
357+ context['active_ids'] = [ref('account_invoice_customer3')]
358+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
359+ assert rfnd_id, 'The refund was not created.'
360+ context['rfnd_id'] = rfnd_id
361+ obj_inv = self.pool.get('account.invoice')
362+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
363+ assert rfnd_customer_inv_brw[0].state == 'draft', 'The customer refund was not properly created, the state must be Draft.'
364+-
365+ 4.16.- I check the correct asigning of parent_id in the customer refund created, for that
366+ the customer refund must have the customer invoice id in the fiel parent_id
367+-
368+ !python {model: account.invoice.refund}: |
369+ obj_inv = self.pool.get('account.invoice')
370+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
371+ customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer3'))
372+ assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
373+-
374+ 5.- In order to test account refund with "Create refund and reconcile" method in a "Paid" invoice
375+-
376+ 5.1.- I create a new partner
377+-
378+ !record {model: 'res.partner', id: res_partner7}:
379+ name: Pedro Perez
380+ use_parent_address: True
381+ function: Tests
382+ email: pedro@perez.com
383+-
384+ 5.2.- I create a new customer invoice
385+-
386+ !record {model: account.invoice, id: account_invoice_customer4}:
387+ account_id: account.a_recv
388+ company_id: base.main_company
389+ currency_id: base.EUR
390+ invoice_line:
391+ - account_id: account.a_sale
392+ name: '[PCSC234] PC Assemble SC234'
393+ price_unit: 450.0
394+ quantity: 1.0
395+ product_id: product.product_product_3
396+ uos_id: product.product_uom_unit
397+ journal_id: sale_journal_debit
398+ partner_id: res_partner7
399+-
400+ 5.3.- I check that Initially customer invoice state is "Draft"
401+-
402+ !assert {model: account.invoice, id: account_invoice_customer4}:
403+ - state == 'draft'
404+-
405+ 5.4.- I check that the customer invoice is a "Customer Invoice"
406+-
407+ !assert {model: account.invoice, id: account_invoice_customer4, string: This is not a customer invoice}:
408+ - type == 'out_invoice'
409+-
410+ 5.5.- I change the state of invoice to open by clicking Validate button
411+-
412+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer4}
413+-
414+ 5.6.- I check that the invoice state is now "Open"
415+-
416+ !assert {model: account.invoice, id: account_invoice_customer4}:
417+ - state == 'open'
418+-
419+ 5.7.- I check that a payment entry gets created in the account.move.line
420+-
421+ !python {model: account.invoice}: |
422+ acc_id=self.browse(cr, uid, ref("account_invoice_customer4"))
423+ assert(acc_id.move_id)
424+-
425+ 5.8.- I will create and post an account voucher with the amount total
426+ of the customer invoice created for the partner Pedro Perez.
427+-
428+ !python {model: account.voucher}: |
429+ import netsvc
430+ import time
431+ vals = {}
432+ amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer4')], context=None)[0].amount_total
433+ journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
434+ res = self.onchange_partner_id(cr, uid, [], ref("res_partner7"), journal_id, 0.0, 1, ttype='receipt', date=False)
435+ vals = {
436+ 'account_id': ref('account.cash'),
437+ 'amount': amount_total,
438+ 'company_id': ref('base.main_company'),
439+ 'journal_id': ref('cash_journal_debit'),
440+ 'partner_id': ref('res_partner7'),
441+ 'period_id': self.pool.get('account.period').find(
442+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
443+ 'type': 'receipt',
444+ }
445+ if not res['value']['line_cr_ids']:
446+ res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
447+ res['value']['line_cr_ids'][0]['amount'] = amount_total
448+ vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
449+ id = self.create(cr, uid, vals)
450+ voucher_id = self.browse(cr, uid, id)
451+ assert (voucher_id.state=='draft'), "Voucher is not in draft state"
452+ wf_service = netsvc.LocalService("workflow")
453+ wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
454+-
455+ 5.9.- I check if the state of the invoice is "Paid"
456+-
457+ !assert {model: account.invoice, id: account_invoice_customer4}:
458+ - state == 'paid'
459+-
460+ 5.10.- I create a customer refund using the method "Create refund and reconcile" and
461+ check the state of the account invoice refund resulting
462+-
463+ !python {model: account.invoice.refund}: |
464+ import time
465+ values = {
466+ 'date': time.strftime('%Y-%m-%d'),
467+ 'period': self.pool.get('account.period').find(
468+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
469+ 'journal_id': ref('sale_refund_journal_debit'),
470+ 'description': 'Desde el test',
471+ 'filter_refund': 'cancel',
472+ }
473+ wzr_id = self.create(cr, uid, values)
474+ assert wzr_id, 'The wizard instance was not created.'
475+ context['wzr_id'] = wzr_id
476+ context['active_ids'] = [ref('account_invoice_customer4')]
477+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
478+ assert rfnd_id, 'The refund was not created.'
479+ context['rfnd_id'] = rfnd_id
480+ obj_inv = self.pool.get('account.invoice')
481+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
482+ assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
483+-
484+ 5.11.- I check the correct asigning of parent_id in the customer refund created, for that
485+ the customer refund must have the customer invoice id in the fiel parent_id
486+-
487+ !python {model: account.invoice.refund}: |
488+ obj_inv = self.pool.get('account.invoice')
489+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
490+ customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer4'))
491+ assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
492+-
493+ 6.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
494+ method in a "Paid" invoice
495+-
496+ 6.1.- I create a new partner
497+-
498+ !record {model: 'res.partner', id: res_partner9}:
499+ name: Maria Perez
500+ use_parent_address: True
501+ function: Tests
502+ email: maria@perez.com
503+-
504+ 6.2.- I create a new customer invoice
505+-
506+ !record {model: account.invoice, id: account_invoice_customer5}:
507+ account_id: account.a_recv
508+ company_id: base.main_company
509+ currency_id: base.EUR
510+ invoice_line:
511+ - account_id: account.a_sale
512+ name: '[PCSC234] PC Assemble SC234'
513+ price_unit: 450.0
514+ quantity: 1.0
515+ product_id: product.product_product_3
516+ uos_id: product.product_uom_unit
517+ journal_id: sale_journal_debit
518+ partner_id: res_partner9
519+-
520+ 6.3.- I check that Initially customer invoice state is "Draft"
521+-
522+ !assert {model: account.invoice, id: account_invoice_customer5}:
523+ - state == 'draft'
524+-
525+ 6.4.- I check that the customer invoice is a "Customer Invoice"
526+-
527+ !assert {model: account.invoice, id: account_invoice_customer5, string: This is not a customer invoice}:
528+ - type == 'out_invoice'
529+-
530+ 6.5.- I change the state of invoice to open by clicking Validate button
531+-
532+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer5}
533+-
534+ 6.6.- I check that the invoice state is now "Open"
535+-
536+ !assert {model: account.invoice, id: account_invoice_customer5}:
537+ - state == 'open'
538+-
539+ 6.7.- I check that a payment entry gets created in the account.move.line
540+-
541+ !python {model: account.invoice}: |
542+ acc_id=self.browse(cr, uid, ref("account_invoice_customer5"))
543+ assert(acc_id.move_id)
544+-
545+ 6.8.- I will create and post an account voucher with the amount total
546+ of the customer invoice created for the partner Maria Perez.
547+-
548+ !python {model: account.voucher}: |
549+ import netsvc
550+ import time
551+ vals = {}
552+ amount_total = self.pool.get('account.invoice').browse(cr, uid, [ref('account_invoice_customer5')], context=None)[0].amount_total
553+ journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
554+ res = self.onchange_partner_id(cr, uid, [], ref("res_partner9"), journal_id, 0.0, 1, ttype='receipt', date=False)
555+ vals = {
556+ 'account_id': ref('account.cash'),
557+ 'amount': amount_total,
558+ 'company_id': ref('base.main_company'),
559+ 'journal_id': ref('cash_journal_debit'),
560+ 'partner_id': ref('res_partner9'),
561+ 'period_id': self.pool.get('account.period').find(
562+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
563+ 'type': 'receipt',
564+ }
565+ if not res['value']['line_cr_ids']:
566+ res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
567+ res['value']['line_cr_ids'][0]['amount'] = amount_total
568+ vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
569+ id = self.create(cr, uid, vals)
570+ voucher_id = self.browse(cr, uid, id)
571+ assert (voucher_id.state=='draft'), "Voucher is not in draft state"
572+ wf_service = netsvc.LocalService("workflow")
573+ wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
574+-
575+ 6.9.- I check if the state of the invoice is "Paid"
576+-
577+ !assert {model: account.invoice, id: account_invoice_customer5}:
578+ - state == 'paid'
579+-
580+ 6.10.- I create a customer refund using the method "Create refund, reconcile and create a new draft invoice" and
581+ check the state of the account invoice refund resulting
582+-
583+ !python {model: account.invoice.refund}: |
584+ import time
585+ values = {
586+ 'date': time.strftime('%Y-%m-%d'),
587+ 'period': self.pool.get('account.period').find(
588+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
589+ 'journal_id': ref('sale_refund_journal_debit'),
590+ 'description': 'Desde el test',
591+ 'filter_refund': 'modify',
592+ }
593+ wzr_id = self.create(cr, uid, values)
594+ assert wzr_id, 'The wizard instance was not created.'
595+ context['wzr_id'] = wzr_id
596+ context['active_ids'] = [ref('account_invoice_customer5')]
597+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
598+ assert rfnd_id, 'The refund was not created.'
599+ context['rfnd_id'] = rfnd_id
600+ obj_inv = self.pool.get('account.invoice')
601+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
602+ assert rfnd_customer_inv_brw[0].state == 'paid', 'The customer refund was not properly created, the state must be Paid.'
603+-
604+ 6.11.- I check the correct asigning of parent_id in the customer refund created, for that
605+ the customer refund must have the customer invoice id in the fiel parent_id
606+-
607+ !python {model: account.invoice.refund}: |
608+ obj_inv = self.pool.get('account.invoice')
609+ rfnd_customer_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
610+ customer_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_customer5'))
611+ assert (rfnd_customer_inv_brw[0].parent_id.id == customer_inv_brw.id), 'The customer refund dont have the correct parent_id.'
612+-
613+ 6.12.- I check that the new customer invoice was created in Draft state
614+-
615+ !python {model: account.invoice.refund}: |
616+ obj_inv = self.pool.get('account.invoice')
617+ inv_src = obj_inv.search(cr, uid, [], order='id')
618+ customer_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
619+ assert customer_inv_brw.state == 'draft', 'The new customer invoice was not properly created, the state must be Draft.'
620
621=== added file 'l10n_ve_fiscal_requirements/test/account_supplier_refund.yml'
622--- l10n_ve_fiscal_requirements/test/account_supplier_refund.yml 1970-01-01 00:00:00 +0000
623+++ l10n_ve_fiscal_requirements/test/account_supplier_refund.yml 2014-02-11 00:22:34 +0000
624@@ -0,0 +1,622 @@
625+-
626+ I set the context that will be used for the encoding of all the invoices of this file
627+-
628+ !context
629+ 'type': 'in_invoice'
630+-
631+ 1.- In order to test account refund with "Create a draft refund" method
632+-
633+ 1.1.- I create a supplier invoice
634+-
635+ !record {model: account.invoice, id: account_invoice_supplier0, view: account.invoice_supplier_form }: &supplier_invoice
636+ account_id: account.a_pay
637+ company_id: base.main_company
638+ currency_id: base.EUR
639+ invoice_line:
640+ - account_id: account.a_expense
641+ name: '[PCSC234] PC Assemble SC234'
642+ price_unit: 300.0
643+ product_id: product.product_product_3
644+ quantity: 10.0
645+ uos_id: product.product_uom_unit
646+ journal_id: account.expenses_journal
647+ partner_id: base.res_partner_12
648+ reference_type: none
649+ type: 'in_invoice'
650+-
651+ 1.2.- I check that Initially supplier invoice state is "Draft"
652+-
653+ !assert {model: account.invoice, id: account_invoice_supplier0}:
654+ - state == 'draft'
655+-
656+ 1.3.- I check that the supplier invoice is a "Supplier Invoice"
657+-
658+ !assert {model: account.invoice, id: account_invoice_supplier0, string: This is not a supplier invoice}:
659+ - type == 'in_invoice'
660+-
661+ 1.4.- I change the state of invoice to open by clicking Validate button
662+-
663+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0}
664+-
665+ 1.5.- I check that the invoice state is now "Open"
666+-
667+ !assert {model: account.invoice, id: account_invoice_supplier0}:
668+ - state == 'open'
669+-
670+ 1.6.- I create a supplier refund using the method "Create a draft refund" and
671+ check the state of the account invoice refund resulting
672+-
673+ !python {model: account.invoice.refund}: |
674+ import time
675+ values = {
676+ 'date': time.strftime('%Y-%m-%d'),
677+ 'period': self.pool.get('account.period').find(
678+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
679+ 'journal_id': ref('account.refund_expenses_journal'),
680+ 'description': 'Desde el test',
681+ 'nro_ctrl': 'Desde el test',
682+ 'filter_refund': 'refund',
683+ }
684+ wzr_id = self.create(cr, uid, values)
685+ context['wzr_id'] = wzr_id
686+ context['active_ids'] = [ref('account_invoice_supplier0')]
687+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
688+ context['rfnd_id'] = rfnd_id
689+ obj_inv = self.pool.get('account.invoice')
690+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
691+ assert rfnd_supplier_inv_brw[0].state == 'draft', 'The supplier refund was not properly created, the state must be Draft.'
692+-
693+ 1.7.- I check the correct asigning of parent_id in the supplier refund created, for that
694+ the supplier refund must have the supplier invoice id in the fiel parent_id
695+-
696+ !python {model: account.invoice.refund}: |
697+ obj_inv = self.pool.get('account.invoice')
698+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
699+ supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier0'))
700+ assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
701+-
702+ 2.- In order to test account refund with "Create refund and reconcile" method
703+-
704+ 2.1.- I create a new supplier invoice
705+-
706+ !record {model: account.invoice, id: account_invoice_supplier1, view: account.invoice_supplier_form }:
707+ <<: *supplier_invoice
708+-
709+ 2.2.- I check that Initially supplier invoice state is "Draft"
710+-
711+ !assert {model: account.invoice, id: account_invoice_supplier1}:
712+ - state == 'draft'
713+-
714+ 2.3.- I check that the supplier invoice is a "Supplier Invoice"
715+-
716+ !assert {model: account.invoice, id: account_invoice_supplier1, string: This is not a supplier invoice}:
717+ - type == 'in_invoice'
718+-
719+ 2.4.- I change the state of invoice to open by clicking Validate button
720+-
721+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier1}
722+-
723+ 2.5.- I check that the invoice state is now "Open"
724+-
725+ !assert {model: account.invoice, id: account_invoice_supplier1}:
726+ - state == 'open'
727+-
728+ 2.6.- I create a supplier refund using the method "Create refund and reconcile" and
729+ check the state of the account invoice refund resulting
730+-
731+ !python {model: account.invoice.refund}: |
732+ import time
733+ values = {
734+ 'date': time.strftime('%Y-%m-%d'),
735+ 'period': self.pool.get('account.period').find(
736+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
737+ 'journal_id': ref('account.refund_expenses_journal'),
738+ 'description': 'Desde el test',
739+ 'nro_ctrl': 'Desde el test',
740+ 'filter_refund': 'cancel',
741+ }
742+ wzr_id = self.create(cr, uid, values)
743+ context['wzr_id'] = wzr_id
744+ context['active_ids'] = [ref('account_invoice_supplier1')]
745+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
746+ context['rfnd_id'] = rfnd_id
747+ obj_inv = self.pool.get('account.invoice')
748+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
749+ assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
750+-
751+ 2.7.- I check the correct asigning of parent_id in the supplier refund created, for that
752+ the supplier refund must have the supplier invoice id in the fiel parent_id
753+-
754+ !python {model: account.invoice.refund}: |
755+ obj_inv = self.pool.get('account.invoice')
756+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
757+ supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier1'))
758+ assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
759+-
760+ 3.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
761+ method
762+-
763+ 3.1.- I create a new supplier invoice
764+-
765+ !record {model: account.invoice, id: account_invoice_supplier2, view: account.invoice_supplier_form }:
766+ <<: *supplier_invoice
767+-
768+ 3.2.- I check that Initially supplier invoice state is "Draft"
769+-
770+ !assert {model: account.invoice, id: account_invoice_supplier2}:
771+ - state == 'draft'
772+-
773+ 3.3.- I check that the supplier invoice is a "Supplier Invoice"
774+-
775+ !assert {model: account.invoice, id: account_invoice_supplier2, string: This is not a supplier invoice}:
776+ - type == 'in_invoice'
777+-
778+ 3.4.- I change the state of invoice to open by clicking Validate button
779+-
780+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier2}
781+-
782+ 3.5.- I check that the invoice state is now "Open"
783+-
784+ !assert {model: account.invoice, id: account_invoice_supplier2}:
785+ - state == 'open'
786+-
787+ 3.6.- I create a supplier refund using the method "Create refund, reconcile and create a new draft invoice" and
788+ check the state of the account invoice refund resulting
789+-
790+ !python {model: account.invoice.refund}: |
791+ import time
792+ values = {
793+ 'date': time.strftime('%Y-%m-%d'),
794+ 'period': self.pool.get('account.period').find(
795+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
796+ 'journal_id': ref('account.refund_expenses_journal'),
797+ 'description': 'Desde el test',
798+ 'nro_ctrl': 'Desde el test',
799+ 'filter_refund': 'modify',
800+ }
801+ wzr_id = self.create(cr, uid, values)
802+ context['wzr_id'] = wzr_id
803+ context['active_ids'] = [ref('account_invoice_supplier2')]
804+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
805+ context['rfnd_id'] = rfnd_id
806+ obj_inv = self.pool.get('account.invoice')
807+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
808+ assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
809+-
810+ 3.7.- I check the correct asigning of parent_id in the supplier refund created, for that
811+ the supplier refund must have the supplier invoice id in the fiel parent_id
812+-
813+ !python {model: account.invoice.refund}: |
814+ obj_inv = self.pool.get('account.invoice')
815+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
816+ supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier2'))
817+ assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
818+-
819+ 3.8.- I check that the new supplier invoice was created in Draft state
820+-
821+ !python {model: account.invoice.refund}: |
822+ obj_inv = self.pool.get('account.invoice')
823+ inv_src = obj_inv.search(cr, uid, [], order='id')
824+ supplier_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
825+ assert supplier_inv_brw.state == 'draft', 'The new supplier invoice was not properly created, the state must be Draft.'
826+-
827+ 4.- In order to test account refund with "Create a draft refund" method in a "Paid" invoice
828+-
829+ 4.1.- I create a new partner
830+-
831+ !record {model: 'res.partner', id: res_partner10}:
832+ name: Juan Garcia
833+ use_parent_address: True
834+ function: Tests
835+ email: juan@garcia.com
836+ supplier: True
837+-
838+ 4.2.- I create a Purchase Journal.
839+-
840+ !record {model: account.journal, id: purchase_journal_debit}:
841+ code: pjou_test
842+ company_id: base.main_company
843+ name: Purchase Journal For Debit Credit Note Tests
844+ sequence_id: account.sequence_purchase_journal
845+ type: purchase
846+-
847+ 4.3.- I create a new supplier invoice
848+-
849+ !record {model: account.invoice, id: account_invoice_supplier3, view: account.invoice_supplier_form }:
850+ account_id: account.a_pay
851+ company_id: base.main_company
852+ currency_id: base.EUR
853+ invoice_line:
854+ - account_id: account.a_expense
855+ name: '[PCSC234] PC Assemble SC234'
856+ price_unit: 300.0
857+ product_id: product.product_product_3
858+ quantity: 10.0
859+ uos_id: product.product_uom_unit
860+ journal_id: purchase_journal_debit
861+ partner_id: res_partner10
862+ reference_type: none
863+ type: 'in_invoice'
864+-
865+ 4.4.- I check that initially supplier invoice state is "Draft"
866+-
867+ !assert {model: account.invoice, id: account_invoice_supplier3}:
868+ - state == 'draft'
869+-
870+ 4.5.- I check that the supplier invoice is a "Supplier Invoice"
871+-
872+ !assert {model: account.invoice, id: account_invoice_supplier3, string: This is not a supplier invoice}:
873+ - type == 'in_invoice'
874+-
875+ 4.6.- I change the state of invoice to open by clicking Validate button
876+-
877+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier3}
878+-
879+ 4.7.- I check that the invoice state is now "Open"
880+-
881+ !assert {model: account.invoice, id: account_invoice_supplier3}:
882+ - state == 'open'
883+-
884+ 4.8.- I check that a payment entry gets created in the account.move.line
885+-
886+ !python {model: account.invoice}: |
887+ acc_id=self.browse(cr, uid, ref("account_invoice_supplier3"))
888+ assert(acc_id.move_id)
889+-
890+ 4.9.- I create a Bank Journal.
891+-
892+ !record {model: account.journal, id: bank_journal_debit}:
893+ name: Bank Journal For Debit Credit Note Tests
894+ code: bjou_test
895+ type: bank
896+ analytic_journal_id: account.sit
897+ sequence_id: account.sequence_bank_journal
898+ default_debit_account_id: account.cash
899+ default_credit_account_id: account.cash
900+ company_id: base.main_company
901+-
902+ 4.10.- I will create and post an account voucher of amount 3450.00 for the partner Juan Garcia.
903+-
904+ !record {model: account.voucher, id: account_voucher0, view: account_voucher.view_vendor_payment_form}:
905+ type: payment
906+ account_id: account.cash
907+ amount: 3450.00
908+ company_id: base.main_company
909+ journal_id: bank_journal_debit
910+ name: Voucher x
911+ narration: PC Assemble SC234
912+ line_dr_ids:
913+ - account_id: account.cash
914+ amount: 3450.00
915+ name: Voucher x
916+ partner_id: res_partner10
917+ reference: none
918+-
919+ 4.11.- I check that initially vendor voucher is in the "Draft" state
920+-
921+ !assert {model: account.voucher, id: account_voucher0}:
922+ - state == 'draft'
923+-
924+ 4.12.- I create voucher by clicking on create button
925+-
926+ !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher0}
927+-
928+ 4.13.- I check that the voucher state is "Posted"
929+-
930+ !assert {model: account.voucher, id: account_voucher0}:
931+ - state == 'posted'
932+-
933+ 4.14.- I check if the state of the invoice is "Paid"
934+-
935+ !assert {model: account.invoice, id: account_invoice_supplier3}:
936+ - state == 'paid'
937+-
938+ 4.15.- I modified the sale journal record so it can cancel invoice
939+-
940+ !record {model: account.journal, id: purchase_journal_debit}:
941+ update_posted: 1
942+-
943+ 4.16.- I modified the cash journal record so it can cancel invoice
944+-
945+ !record {model: account.journal, id: bank_journal_debit}:
946+ update_posted: 1
947+-
948+ 4.17.- I create a Purchase Refund Journal.
949+-
950+ !record {model: account.journal, id: purchase_refund_journal_debit}:
951+ code: sprjou_test
952+ company_id: base.main_company
953+ name: Purchase Refund Journal For Debit Credit Note Tests
954+ sequence_id: account.sequence_refund_purchase_journal
955+ type: purchase_refund
956+-
957+ 4.18.- I create a supplier refund using the method "Create a draft refund" and
958+ check the state of the account invoice refund resulting
959+-
960+ !python {model: account.invoice.refund}: |
961+ import time
962+ values = {
963+ 'date': time.strftime('%Y-%m-%d'),
964+ 'period': self.pool.get('account.period').find(
965+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
966+ 'journal_id': ref('purchase_refund_journal_debit'),
967+ 'description': 'Desde el test',
968+ 'nro_ctrl': 'Desde el test',
969+ 'filter_refund': 'refund',
970+ }
971+ wzr_id = self.create(cr, uid, values)
972+ assert wzr_id, 'The wizard instance was not created.'
973+ context['wzr_id'] = wzr_id
974+ context['active_ids'] = [ref('account_invoice_supplier3')]
975+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
976+ assert rfnd_id, 'The refund was not created.'
977+ context['rfnd_id'] = rfnd_id
978+ obj_inv = self.pool.get('account.invoice')
979+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
980+ assert rfnd_supplier_inv_brw[0].state == 'draft', 'The supplier refund was not properly created, the state must be Draft.'
981+-
982+ 4.19.- I check the correct asigning of parent_id in the supplier refund created, for that
983+ the supplier refund must have the supplier invoice id in the fiel parent_id
984+-
985+ !python {model: account.invoice.refund}: |
986+ obj_inv = self.pool.get('account.invoice')
987+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
988+ supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier3'))
989+ assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
990+-
991+ 5.- In order to test account refund with "Create refund and reconcile" method in a "Paid" invoice
992+-
993+ 5.1.- I create a new partner
994+-
995+ !record {model: 'res.partner', id: res_partner11}:
996+ name: Maria Garcia
997+ use_parent_address: True
998+ function: Tests
999+ email: maria@garcia.com
1000+ supplier: True
1001+-
1002+ 5.2.- I create a new supplier invoice
1003+-
1004+ !record {model: account.invoice, id: account_invoice_supplier4, view: account.invoice_supplier_form }:
1005+ account_id: account.a_pay
1006+ company_id: base.main_company
1007+ currency_id: base.EUR
1008+ invoice_line:
1009+ - account_id: account.a_expense
1010+ name: '[PCSC234] PC Assemble SC234'
1011+ price_unit: 300.0
1012+ product_id: product.product_product_3
1013+ quantity: 10.0
1014+ uos_id: product.product_uom_unit
1015+ journal_id: purchase_journal_debit
1016+ partner_id: res_partner11
1017+ reference_type: none
1018+ type: 'in_invoice'
1019+-
1020+ 5.3.- I check that initially supplier invoice state is "Draft"
1021+-
1022+ !assert {model: account.invoice, id: account_invoice_supplier4}:
1023+ - state == 'draft'
1024+-
1025+ 5.4.- I check that the supplier invoice is a "Supplier Invoice"
1026+-
1027+ !assert {model: account.invoice, id: account_invoice_supplier4, string: This is not a supplier invoice}:
1028+ - type == 'in_invoice'
1029+-
1030+ 5.5.- I change the state of invoice to open by clicking Validate button
1031+-
1032+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier4}
1033+-
1034+ 5.6.- I check that the invoice state is now "Open"
1035+-
1036+ !assert {model: account.invoice, id: account_invoice_supplier4}:
1037+ - state == 'open'
1038+-
1039+ 5.7.- I check that a payment entry gets created in the account.move.line
1040+-
1041+ !python {model: account.invoice}: |
1042+ acc_id=self.browse(cr, uid, ref("account_invoice_supplier4"))
1043+ assert(acc_id.move_id)
1044+-
1045+ 5.8.- I will create and post an account voucher of amount 3450.00 for the partner Maria Garcia.
1046+-
1047+ !record {model: account.voucher, id: account_voucher1, view: account_voucher.view_vendor_payment_form}:
1048+ type: payment
1049+ account_id: account.cash
1050+ amount: 3450.00
1051+ company_id: base.main_company
1052+ journal_id: bank_journal_debit
1053+ name: Voucher x
1054+ narration: PC Assemble SC234
1055+ line_dr_ids:
1056+ - account_id: account.cash
1057+ amount: 3450.00
1058+ name: Voucher x
1059+ partner_id: res_partner11
1060+ reference: none
1061+-
1062+ 5.9.- I check that initially vendor voucher is in the "Draft" state
1063+-
1064+ !assert {model: account.voucher, id: account_voucher1}:
1065+ - state == 'draft'
1066+-
1067+ 5.10.- I create voucher by clicking on create button
1068+-
1069+ !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher1}
1070+-
1071+ 5.11.- I check that the voucher state is "Posted"
1072+-
1073+ !assert {model: account.voucher, id: account_voucher1}:
1074+ - state == 'posted'
1075+-
1076+ 5.12.- I check if the state of the invoice is "Paid"
1077+-
1078+ !assert {model: account.invoice, id: account_invoice_supplier4}:
1079+ - state == 'paid'
1080+-
1081+ 5.13.- I create a supplier refund using the method "Create refund and reconcile" and
1082+ check the state of the account invoice refund resulting
1083+-
1084+ !python {model: account.invoice.refund}: |
1085+ import time
1086+ values = {
1087+ 'date': time.strftime('%Y-%m-%d'),
1088+ 'period': self.pool.get('account.period').find(
1089+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
1090+ 'journal_id': ref('purchase_refund_journal_debit'),
1091+ 'description': 'Desde el test',
1092+ 'nro_ctrl': 'Desde el test',
1093+ 'filter_refund': 'cancel',
1094+ }
1095+ wzr_id = self.create(cr, uid, values)
1096+ assert wzr_id, 'The wizard instance was not created.'
1097+ context['wzr_id'] = wzr_id
1098+ context['active_ids'] = [ref('account_invoice_supplier4')]
1099+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
1100+ assert rfnd_id, 'The refund was not created.'
1101+ context['rfnd_id'] = rfnd_id
1102+ obj_inv = self.pool.get('account.invoice')
1103+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
1104+ assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
1105+-
1106+ 5.14.- I check the correct asigning of parent_id in the supplier refund created, for that
1107+ the supplier refund must have the supplier invoice id in the fiel parent_id
1108+-
1109+ !python {model: account.invoice.refund}: |
1110+ obj_inv = self.pool.get('account.invoice')
1111+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
1112+ supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier4'))
1113+ assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
1114+-
1115+ 6.- In order to test account refund with "Create refund, reconcile and create a new draft invoice"
1116+ method in a "Paid" invoice
1117+-
1118+ 6.1.- I create a new partner
1119+-
1120+ !record {model: 'res.partner', id: res_partner12}:
1121+ name: Pablo Garcia
1122+ use_parent_address: True
1123+ function: Tests
1124+ email: pablo@garcia.com
1125+ supplier: True
1126+-
1127+ 6.2.- I create a new supplier invoice
1128+-
1129+ !record {model: account.invoice, id: account_invoice_supplier5, view: account.invoice_supplier_form }:
1130+ account_id: account.a_pay
1131+ company_id: base.main_company
1132+ currency_id: base.EUR
1133+ invoice_line:
1134+ - account_id: account.a_expense
1135+ name: '[PCSC234] PC Assemble SC234'
1136+ price_unit: 300.0
1137+ product_id: product.product_product_3
1138+ quantity: 10.0
1139+ uos_id: product.product_uom_unit
1140+ journal_id: purchase_journal_debit
1141+ partner_id: res_partner12
1142+ reference_type: none
1143+ type: 'in_invoice'
1144+-
1145+ 6.3.- I check that initially supplier invoice state is "Draft"
1146+-
1147+ !assert {model: account.invoice, id: account_invoice_supplier5}:
1148+ - state == 'draft'
1149+-
1150+ 6.4.- I check that the supplier invoice is a "Supplier Invoice"
1151+-
1152+ !assert {model: account.invoice, id: account_invoice_supplier5, string: This is not a supplier invoice}:
1153+ - type == 'in_invoice'
1154+-
1155+ 6.5.- I change the state of invoice to open by clicking Validate button
1156+-
1157+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier5}
1158+-
1159+ 5.6.- I check that the invoice state is now "Open"
1160+-
1161+ !assert {model: account.invoice, id: account_invoice_supplier5}:
1162+ - state == 'open'
1163+-
1164+ 6.7.- I check that a payment entry gets created in the account.move.line
1165+-
1166+ !python {model: account.invoice}: |
1167+ acc_id=self.browse(cr, uid, ref("account_invoice_supplier5"))
1168+ assert(acc_id.move_id)
1169+-
1170+ 6.8.- I will create and post an account voucher of amount 3450.00 for the partner Maria Garcia.
1171+-
1172+ !record {model: account.voucher, id: account_voucher2, view: account_voucher.view_vendor_payment_form}:
1173+ type: payment
1174+ account_id: account.cash
1175+ amount: 3450.00
1176+ company_id: base.main_company
1177+ journal_id: bank_journal_debit
1178+ name: Voucher x
1179+ narration: PC Assemble SC234
1180+ line_dr_ids:
1181+ - account_id: account.cash
1182+ amount: 3450.00
1183+ name: Voucher x
1184+ partner_id: res_partner12
1185+ reference: none
1186+-
1187+ 6.9.- I check that initially vendor voucher is in the "Draft" state
1188+-
1189+ !assert {model: account.voucher, id: account_voucher2}:
1190+ - state == 'draft'
1191+-
1192+ 6.10.- I create voucher by clicking on create button
1193+-
1194+ !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher2}
1195+-
1196+ 6.11.- I check that the voucher state is "Posted"
1197+-
1198+ !assert {model: account.voucher, id: account_voucher2}:
1199+ - state == 'posted'
1200+-
1201+ 6.12.- I check if the state of the invoice is "Paid"
1202+-
1203+ !assert {model: account.invoice, id: account_invoice_supplier5}:
1204+ - state == 'paid'
1205+-
1206+ 6.13.- I create a supplier refund using the method "Create refund, reconcile and create a new draft invoice" and
1207+ check the state of the account invoice refund resulting
1208+-
1209+ !python {model: account.invoice.refund}: |
1210+ import time
1211+ values = {
1212+ 'date': time.strftime('%Y-%m-%d'),
1213+ 'period': self.pool.get('account.period').find(
1214+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': ref('base.main_company')})[0],
1215+ 'journal_id': ref('purchase_refund_journal_debit'),
1216+ 'description': 'Desde el test',
1217+ 'nro_ctrl': 'Desde el test',
1218+ 'filter_refund': 'modify',
1219+ }
1220+ wzr_id = self.create(cr, uid, values)
1221+ assert wzr_id, 'The wizard instance was not created.'
1222+ context['wzr_id'] = wzr_id
1223+ context['active_ids'] = [ref('account_invoice_supplier5')]
1224+ rfnd_id = self.invoice_refund(cr, uid, [wzr_id], context=context)
1225+ assert rfnd_id, 'The refund was not created.'
1226+ context['rfnd_id'] = rfnd_id
1227+ obj_inv = self.pool.get('account.invoice')
1228+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, rfnd_id['domain'][1][2])
1229+ assert rfnd_supplier_inv_brw[0].state == 'paid', 'The supplier refund was not properly created, the state must be Paid.'
1230+-
1231+ 6.14.- I check the correct asigning of parent_id in the supplier refund created, for that
1232+ the supplier refund must have the supplier invoice id in the fiel parent_id
1233+-
1234+ !python {model: account.invoice.refund}: |
1235+ obj_inv = self.pool.get('account.invoice')
1236+ rfnd_supplier_inv_brw = obj_inv.browse(cr, uid, context['rfnd_id']['domain'][1][2])
1237+ supplier_inv_brw = obj_inv.browse(cr, uid, ref('account_invoice_supplier5'))
1238+ assert (rfnd_supplier_inv_brw[0].parent_id.id == supplier_inv_brw.id), 'The supplier refund dont have the correct parent_id.'
1239+-
1240+ 6.15.- I check that the new supplier invoice was created in Draft state
1241+-
1242+ !python {model: account.invoice.refund}: |
1243+ obj_inv = self.pool.get('account.invoice')
1244+ inv_src = obj_inv.search(cr, uid, [], order='id')
1245+ supplier_inv_brw = obj_inv.browse(cr, uid, inv_src[-1])
1246+ assert supplier_inv_brw.state == 'draft', 'The new supplier invoice was not properly created, the state must be Draft.'
1247
1248=== modified file 'l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py'
1249--- l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2014-01-13 19:38:55 +0000
1250+++ l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2014-02-11 00:22:34 +0000
1251@@ -99,17 +99,7 @@
1252 journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
1253 res['fields'][field]['selection'] = journal_select
1254 return res
1255-
1256- def _get_orig(self, cr, uid, inv, ref, context={}):
1257- """ Return default origin value
1258- """
1259- nro_ref = ref
1260- if inv.type == 'out_invoice':
1261- nro_ref = inv.number
1262- orig = 'Devolucion FACT:' +(nro_ref or '') + '- DE FECHA:' + (inv.date_invoice or '') + (' TOTAL:' + str(inv.amount_total) or '')
1263- return orig
1264-
1265-
1266+
1267 def cn_iva_validate(self, cr, uid,invoice,context=None):
1268 """ Validates if retentions have been changes to move the state confirmed and done
1269 """
1270@@ -159,20 +149,20 @@
1271 res_users_obj = self.pool.get('res.users')
1272 if context is None:
1273 context = {}
1274- for form in self.read(cr, uid, ids, context=context):
1275+ for form in self.browse(cr, uid, ids, context=context):
1276 created_inv = []
1277 date = False
1278 period = False
1279 description = False
1280 nroctrl = False
1281 company = res_users_obj.browse(cr, uid, uid, context=context).company_id
1282- journal_brw = form.get('journal_id', False)
1283+ journal_brw = form.journal_id or False
1284 for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
1285 if inv.state in ['draft', 'proforma2', 'cancel']:
1286 raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode))
1287 if inv.reconciled and mode in ('cancel', 'modify'):
1288 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))
1289- period = form.get('period') and form.get('period')[0] or False
1290+ period = form.period.id or False
1291 if not period:
1292 #Take period from the current date
1293 period = self.pool.get('account.period').find(cr, uid, context=context)
1294@@ -185,11 +175,11 @@
1295 if not journal_brw:
1296 journal_id = inv.journal_id.id
1297 else:
1298- journal_id=journal_brw[0]
1299+ journal_id=journal_brw.id
1300
1301- if form['date']:
1302- date = form['date']
1303- if not form['period']:
1304+ if form.date:
1305+ date = form.date
1306+ if not form.period:
1307 cr.execute("select name from ir_model_fields \
1308 where model = 'account.period' \
1309 and name = 'company_id'")
1310@@ -209,14 +199,14 @@
1311 #Take current date
1312 #date = inv.date_invoice
1313 date = time.strftime('%Y-%m-%d')
1314- if form['description']:
1315- description = form['description']
1316+ if form.description:
1317+ description = form.description
1318 else:
1319 description = inv.name
1320
1321 if inv.type in ('in_invoice','in_refund'):
1322- if form['nro_ctrl']:
1323- nroctrl = form['nro_ctrl']
1324+ if form.nro_ctrl:
1325+ nroctrl = form.nro_ctrl
1326 else:
1327 raise osv.except_osv(_('Control Number !'), \
1328 _('Missing Control Number on Invoice Refund!'))
1329@@ -321,19 +311,7 @@
1330 orig = self._get_orig(cr, uid, inv, inv.supplier_invoice_number, context)
1331 inv_obj.write(cr,uid,created_inv[0],{'origin':inv.origin,'name':wzd_brw.description},context=context)
1332 return result
1333-
1334- def validate_total_payment_inv(self, cr, uid, ids, context=None):
1335- """ Method that validate if invoice is totally paid.
1336- @param ids: list of invoices.
1337- return: True: if invoice is paid.
1338- False: if invoice is not paid.
1339- """
1340- res = False
1341- inv_obj = self.pool.get('account.invoice')
1342- for inv in inv_obj.browse(cr, uid, ids, context=context):
1343- res = inv.reconciled
1344- return res
1345-
1346+
1347 def validate_wh(self, cr, uid, ids, context=None):
1348 """ Method that validate if invoice has non-yet processed withholds.
1349
1350@@ -345,36 +323,6 @@
1351 """
1352 return True
1353
1354- def unreconcile_paid_invoices(self, cr, uid, invoiceids, context=None):
1355- """ Method that unreconcile the payments of invoice.
1356- @param invoiceids: list of invoices.
1357- return: True: unreconcile successfully.
1358- False: unreconcile unsuccessfully.
1359- """
1360- inv_obj = self.pool.get('account.invoice')
1361- moveline_obj = self.pool.get('account.move.line')
1362- voucher_pool = self.pool.get('account.voucher')
1363- res = True
1364- rec = []
1365- mid = []
1366- if self.validate_total_payment_inv(cr, uid, invoiceids, context=context):
1367- for inv in inv_obj.browse(cr, uid, invoiceids, context=context):
1368- movelineids = inv_obj.move_line_id_payment_get(cr, uid,[inv.id])
1369- for moveline in moveline_obj.browse(cr, uid, movelineids,context=context):
1370- if moveline.reconcile_id:
1371- rec += [moveline.reconcile_id.id]
1372- if moveline.reconcile_partial_id:
1373- rec += [moveline.reconcile_partial_id.id]
1374- movelines = moveline_obj.search(cr, uid, [('|'),('reconcile_id','in',rec),('reconcile_partial_id','in',rec)],context=context)
1375- for mids in moveline_obj.browse(cr, uid, movelines, context=context):
1376- mid +=[mids.move_id.id]
1377- voucherids = voucher_pool.search(cr, uid,[('move_id','in',mid)])
1378- if voucherids:
1379- voucher_pool.cancel_voucher(cr, uid, voucherids, context=context)
1380- else:
1381- res = False
1382- return res
1383-
1384 def invoice_refund(self, cr, uid, ids, context=None):
1385 """ Create a invoice refund
1386 """
1387@@ -383,9 +331,9 @@
1388 inv_obj = self.pool.get('account.invoice')
1389 period_obj = self.pool.get('account.period')
1390 wzr_brw = self.browse(cr,uid,ids,context=context)[0]
1391- date = wzr_brw.date and wzr_brw.date.split('-')
1392- period = wzr_brw and wzr_brw.period and wzr_brw.period.id
1393- period_ids = date and len(date) == 3 and period_obj.search(cr,uid,[('code','=','%s/%s'%(date[1],date[0]))],context=context)
1394+ date = wzr_brw.date
1395+ period = wzr_brw and wzr_brw.period and wzr_brw.period.id
1396+ period_ids = date and period_obj.search(cr,uid,[('date_start', '<=', date),('date_stop', '>=', date),('special', '=', False)],context=context)
1397 if period not in period_ids:
1398 raise osv.except_osv(_('Error !'), \
1399 _('The date should be chosen to belong to the period'))