Merge lp:~vauxoo/openerp-venezuela-localization/7.0-lp1251135_wh_core-dev-hbto into lp:openerp-venezuela-localization

Proposed by hbto [Vauxoo] http://www.vauxoo.com
Status: Superseded
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/7.0-lp1251135_wh_core-dev-hbto
Merge into: lp:openerp-venezuela-localization
Diff against target: 6837 lines (+3498/-1825)
68 files modified
l10n_ve_fiscal_book/model/fiscal_book.py (+23/-14)
l10n_ve_fiscal_book/wizard/fiscal_book_wizard.py (+5/-3)
l10n_ve_imex/__openerp__.py (+1/-1)
l10n_ve_imex/model/customs_form.py (+5/-3)
l10n_ve_imex/model/invoice.py (+4/-2)
l10n_ve_withholding/model/invoice.py (+2/-1)
l10n_ve_withholding_islr/__openerp__.py (+3/-5)
l10n_ve_withholding_islr/demo/l10n_ve_islr_withholding_demo.xml (+161/-3)
l10n_ve_withholding_islr/model/invoice.py (+16/-2)
l10n_ve_withholding_islr/model/islr_wh_doc.py (+72/-23)
l10n_ve_withholding_islr/model/islr_xml_wh.py (+5/-3)
l10n_ve_withholding_islr/test/customer_wh_islr_doc.yml (+300/-0)
l10n_ve_withholding_islr/test/supplier_wh_islr_doc.yml (+914/-0)
l10n_ve_withholding_islr/test/supplier_wh_islr_invoice.yml (+186/-0)
l10n_ve_withholding_islr/test/test.yml (+0/-103)
l10n_ve_withholding_islr/test/test_duplicate.yml (+0/-70)
l10n_ve_withholding_islr/test/test_notax.yml (+0/-62)
l10n_ve_withholding_islr/test/test_sale.yml (+0/-89)
l10n_ve_withholding_islr/view/islr_wh_doc_view.xml (+14/-3)
l10n_ve_withholding_islr/view/islr_xml_wh.xml (+7/-3)
l10n_ve_withholding_iva/__openerp__.py (+2/-15)
l10n_ve_withholding_iva/model/generate_txt.py (+12/-7)
l10n_ve_withholding_iva/model/invoice.py (+23/-19)
l10n_ve_withholding_iva/model/wh_iva.py (+38/-25)
l10n_ve_withholding_iva/report/withholding_vat.py (+3/-2)
l10n_ve_withholding_iva/test/iva_invoice.yml (+0/-41)
l10n_ve_withholding_iva/test/iva_purchase.yml (+0/-58)
l10n_ve_withholding_iva/test/iva_purchase_nret1.yml (+0/-87)
l10n_ve_withholding_iva/test/iva_purchase_nret2.yml (+0/-97)
l10n_ve_withholding_iva/test/iva_purchase_nret3.yml (+0/-107)
l10n_ve_withholding_iva/test/iva_purchase_wh.yml (+0/-92)
l10n_ve_withholding_iva/test/iva_sale.yml (+0/-68)
l10n_ve_withholding_iva/test/iva_sale_2.yml (+0/-58)
l10n_ve_withholding_iva/test/iva_sale_wh.yml (+0/-205)
l10n_ve_withholding_iva/test/iva_sale_withholding.yml (+0/-58)
l10n_ve_withholding_iva/test/iva_test_invoice.yml (+0/-67)
l10n_ve_withholding_iva/test/iva_test_wh.yml (+0/-57)
l10n_ve_withholding_iva/test/iva_test_wh_2.yml (+0/-70)
l10n_ve_withholding_iva/test/iva_test_wh_3.yml (+0/-62)
l10n_ve_withholding_iva/test/iva_test_wh_4.yml (+0/-60)
l10n_ve_withholding_iva/test/purchase_invoice_wh_iva.yml (+11/-0)
l10n_ve_withholding_iva/test/purchase_wh_iva.yml (+52/-1)
l10n_ve_withholding_iva/test/purchase_wh_iva_sequence.yml (+209/-3)
l10n_ve_withholding_iva/test/purchase_wh_iva_txt.yml (+300/-0)
l10n_ve_withholding_iva/test/sale_wh_iva.yml (+48/-0)
l10n_ve_withholding_iva/test/sale_wh_iva_sequence.yml (+127/-0)
l10n_ve_withholding_iva/view/wh_iva_view.xml (+18/-4)
l10n_ve_withholding_muni/__openerp__.py (+4/-0)
l10n_ve_withholding_muni/data/wh_muni_sequence.xml (+4/-4)
l10n_ve_withholding_muni/demo/demo_accounts.xml (+23/-0)
l10n_ve_withholding_muni/demo/demo_partners.xml (+85/-0)
l10n_ve_withholding_muni/model/invoice.py (+27/-2)
l10n_ve_withholding_muni/model/wh_muni.py (+100/-77)
l10n_ve_withholding_muni/test/awm_customer.yml (+104/-0)
l10n_ve_withholding_muni/test/awm_supplier.yml (+100/-0)
l10n_ve_withholding_muni/view/partner_view.xml (+3/-3)
l10n_ve_withholding_muni/view/wh_muni_view.xml (+9/-7)
l10n_ve_withholding_muni/workflow/l10n_ve_wh_muni_wf.xml (+35/-1)
l10n_ve_withholding_src/__openerp__.py (+6/-1)
l10n_ve_withholding_src/demo/demo_accounts.xml (+24/-0)
l10n_ve_withholding_src/demo/demo_company.xml (+10/-0)
l10n_ve_withholding_src/model/invoice.py (+28/-12)
l10n_ve_withholding_src/model/wh_src.py (+105/-35)
l10n_ve_withholding_src/report/wh_src_report.py (+5/-5)
l10n_ve_withholding_src/test/aws_customer.yml (+104/-0)
l10n_ve_withholding_src/test/aws_supplier.yml (+104/-0)
l10n_ve_withholding_src/view/wh_src_view.xml (+43/-21)
l10n_ve_withholding_src/workflow/l10n_ve_wh_src_wf.xml (+14/-4)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/7.0-lp1251135_wh_core-dev-hbto
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Pending
Review via email: mp+199564@code.launchpad.net

This proposal supersedes a proposal from 2013-12-17.

This proposal has been superseded by a proposal from 2014-01-08.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_fiscal_book/model/fiscal_book.py'
2--- l10n_ve_fiscal_book/model/fiscal_book.py 2013-06-14 16:36:37 +0000
3+++ l10n_ve_fiscal_book/model/fiscal_book.py 2014-01-08 15:40:54 +0000
4@@ -62,13 +62,15 @@
5 @param field_name: field [get_partner_addr]
6 """
7 context = context or {}
8+ rp_obj = self.pool.get('res.partner')
9 res = {}.fromkeys(ids, 'NO HAY DIRECCION FISCAL DEFINIDA')
10 #~ TODO: ASK: what company, fisal.book.company_id?
11- addr = self.pool.get('res.users').browse(
12- cr, uid, uid, context=context).company_id.partner_id
13+ ru_obj = self.pool.get('res.users')
14+ rc_brw = ru_obj.browse(cr, uid, uid, context=context).company_id
15+ addr = rp_obj._find_accounting_partner(rc_brw.partner_id)
16 for fb_id in ids:
17 if addr:
18- res[fb_id] = addr.type == 'invoice' and (addr.street or '') + \
19+ res[fb_id] = (addr.street or '') + \
20 ' ' + (addr.street2 or '') + ' ' + (addr.zip or '') + ' ' \
21 + (addr.city or '') + ' ' + \
22 (addr.country_id and addr.country_id.name or '') + \
23@@ -240,7 +242,7 @@
24 " according to the Venezuelan RLIVA statement for fiscal" \
25 " accounting books. Options:" \
26 " - Art. 75: Pruchase Book." \
27- " - Art. 76: Sale Book. Reflects every individual operation datail." \
28+ " - Art. 76: Sale Book. Reflects every individual operation detail." \
29 " - Art. 77: Sale Book. Groups Non-Tax Payer operations in one " \
30 " consolidated line. Only fiscal billing." \
31 " - Art. 78: Sale Book. Hybrid for 76 and 77 article. Show" \
32@@ -698,12 +700,13 @@
33 """
34 context = context or {}
35 iwdl_obj = self.pool.get('account.wh.iva.line')
36+ rp_obj = self.pool.get('res.partner')
37 fb_brw = self.browse(cr, uid, fb_id, context=context)
38 #~ Relate wh iva lines
39 iwdl_ids = self._get_wh_iva_line_ids(cr, uid, fb_id, context=context)
40
41- if fb_brw.type == "purchase" and iwdl_ids \
42- and not fb_brw.company_id.partner_id.wh_iva_agent:
43+ if fb_brw.type == "purchase" and iwdl_ids and not \
44+ rp_obj._find_accounting_partner(fb_brw.company_id.partner_id).wh_iva_agent:
45 raise osv.except_osv(_("Error!"),
46 _("You have withholdings registred but you are not a withholding agent"))
47
48@@ -833,6 +836,7 @@
49 cf_obj = self.pool.get('customs.form')
50 fbl_obj = self.pool.get('fiscal.book.line')
51 fb_brw = self.browse(cr, uid, fb_id, context=context)
52+ rp_obj = self.pool.get('res.partner')
53
54 #~ add book lines for withholding iva lines
55 if fb_brw.iwdl_ids:
56@@ -845,6 +849,7 @@
57 t_type = fb_brw.type == 'sale' and 'tp' or 'do'
58 for iwdl_brw in iwdl_obj.browse(cr, uid, iwdl_ids,
59 context=context):
60+ rp_brw = rp_obj._find_accounting_partner(iwdl_brw.retention_id.partner_id)
61 values = {
62 'iwdl_id': iwdl_brw.id,
63 'rank': my_rank,
64@@ -854,8 +859,8 @@
65 'doc_type': self.get_doc_type(cr, uid, iwdl_id=iwdl_brw.id,
66 context=context),
67 'wh_number': iwdl_brw.retention_id.number or False,
68- 'partner_name': iwdl_brw.retention_id.partner_id.name or False,
69- 'partner_vat': iwdl_brw.retention_id.partner_id.vat or False,
70+ 'partner_name': rp_brw.name or 'N/A',
71+ 'partner_vat': rp_brw.vat or 'N/A',
72 'affected_invoice': iwdl_brw.invoice_id.fiscal_printer
73 and iwdl_brw.invoice_id.invoice_printer
74 or (fb_brw.type == 'sale'
75@@ -877,6 +882,7 @@
76 context=context)
77 doc_type = self.get_doc_type(cr, uid, inv_id=inv_brw.id,
78 context=context)
79+ rp_brw = rp_obj._find_accounting_partner(inv_brw.partner_id)
80 values = {
81 'invoice_id': inv_brw.id,
82 'rank': my_rank,
83@@ -899,9 +905,9 @@
84 'affected_invoice': (doc_type == "N/DE" or doc_type == "N/CR") \
85 and (inv_brw.parent_id and inv_brw.parent_id.number or False) \
86 or False,
87- 'partner_name': inv_brw.partner_id.name or False,
88- 'partner_vat': inv_brw.partner_id.vat \
89- and inv_brw.partner_id.vat[2:] or 'N/A',
90+ 'partner_name': rp_brw.name or 'N/A',
91+ 'partner_vat': rp_brw.vat \
92+ and rp_brw.vat[2:] or 'N/A',
93 'invoice_number': inv_brw.fiscal_printer
94 and inv_brw.invoice_printer
95 or (fb_brw.type == 'sale'
96@@ -928,7 +934,7 @@
97 for cf_brw in fb_brw.cf_ids:
98
99 cf_partner_brws = \
100- list(set([cfl_brw.tax_code.partner_id
101+ list(set([rp_obj._find_accounting_partner(cfl_brw.tax_code.partner_id)
102 for cfl_brw in cf_brw.cfl_ids
103 if not cfl_brw.tax_code.vat_detail]))
104
105@@ -943,7 +949,7 @@
106 for partner_brw in cf_partner_brws:
107 values = common_values.copy()
108 values['rank'] = my_rank
109- values['partner_name'] = partner_brw.name or False
110+ values['partner_name'] = partner_brw.name or 'N/A'
111 values['partner_vat'] = partner_brw.vat \
112 and partner_brw.vat[2:] or 'N/A'
113 values['total_with_iva'] = \
114@@ -972,6 +978,7 @@
115 @param cf_id: customs form id
116 @param partner_id: partner id
117 """
118+ #KEEP AN EYE ON HERE, No check has been made on accounting partner
119 context = context or {}
120 cf_obj = self.pool.get('customs.form')
121 cfl_brws = cf_obj.browse(cr, uid, cf_id, context=context).cfl_ids
122@@ -1660,12 +1667,14 @@
123 """
124 context = context or {}
125 inv_obj = self.pool.get('account.invoice')
126+ rp_obj = self.pool.get('res.partner')
127 inv_brw = inv_obj.browse(cr, uid, inv_id, context=context)
128+ rp_brw = rp_obj._find_accounting_partner(inv_brw.partner_id).id,
129 fb_brw = self.browse(cr, uid, fb_id, context=context)
130 return inv_brw.customs_form_id \
131 and (fb_brw.type == 'sale' and 'ex' or 'im') \
132 or (fb_brw.type == 'purchase' and 'do' \
133- or (inv_brw.partner_id.vat_subjected and 'tp' or 'ntp' ))
134+ or (rp_brw.vat_subjected and 'tp' or 'ntp' ))
135
136 def unlink(self, cr, uid, ids, context=None):
137 """ Overwrite the unlink method to throw an exception if the book is
138
139=== modified file 'l10n_ve_fiscal_book/wizard/fiscal_book_wizard.py'
140--- l10n_ve_fiscal_book/wizard/fiscal_book_wizard.py 2013-05-30 21:11:54 +0000
141+++ l10n_ve_fiscal_book/wizard/fiscal_book_wizard.py 2014-01-08 15:40:54 +0000
142@@ -87,14 +87,16 @@
143 def _do_new_record(self, control, inv_browse):
144 invoice = [i for i in inv_browse if i.nro_ctrl == control][0]
145 amount = (invoice.amount_tax * invoice.p_ret) / 100
146+ rp_obj = self.pool.get('res.partner')
147+ rp_brw = rp_obj._find_accounting_partner(invoice.partner_id).id,
148 return (invoice.date_invoice,
149 invoice.date_document,
150- invoice.partner_id.vat,
151- invoice.partner_id.id,
152+ rp_brw.vat,
153+ rp_brw.id,
154 invoice.number,
155 invoice.nro_ctrl,
156 amount,
157- invoice.partner_id.name)
158+ rp_brw.name)
159
160 def _do_sale_report(self, cr, uid, data, context=None):
161 """
162
163=== modified file 'l10n_ve_imex/__openerp__.py'
164--- l10n_ve_imex/__openerp__.py 2013-11-18 08:53:35 +0000
165+++ l10n_ve_imex/__openerp__.py 2014-01-08 15:40:54 +0000
166@@ -27,7 +27,7 @@
167
168 {
169 "name": "Imex",
170- "version": "0.1",
171+ "version": "0.2",
172 "depends": ["base",
173 "account",
174 "decimal_precision",
175
176=== modified file 'l10n_ve_imex/model/customs_form.py'
177--- l10n_ve_imex/model/customs_form.py 2013-06-14 13:39:39 +0000
178+++ l10n_ve_imex/model/customs_form.py 2014-01-08 15:40:54 +0000
179@@ -151,10 +151,12 @@
180 context = context or {}
181 company_id = context.get('f86_company_id')
182 f86_cfg = context.get('f86_config')
183+ rp_obj = self.pool.get('res.partner')
184
185 #~ expenses
186 for line in f86.cfl_ids:
187 debits = []
188+ acc_part_brw = rp_obj._find_accounting_partner(line.tax_code.partner_id)
189 if line.tax_code.vat_detail:
190 for vat in line.imex_tax_line:
191 debits.append(
192@@ -166,7 +168,7 @@
193 'amount': line.amount, 'tax_info': ''})
194
195 credit_account_id = \
196- line.tax_code.partner_id.property_account_payable.id
197+ acc_part_brw.property_account_payable.id
198
199 for debit in debits:
200 if not debit['account_id'] or not credit_account_id:
201@@ -176,13 +178,13 @@
202 lines.append(
203 self._gen_account_move_line(
204 company_id, debit['account_id'],
205- line.tax_code.partner_id.id, '[%s] %s - %s%s'
206+ acc_part_brw.id, '[%s] %s - %s%s'
207 % (line.tax_code.code, line.tax_code.ref,
208 line.tax_code.name, debit['tax_info']),
209 debit['amount'], 0.0)
210 )
211 lines.append(self._gen_account_move_line(
212- company_id, credit_account_id, line.tax_code.partner_id.id,
213+ company_id, credit_account_id, acc_part_brw.id,
214 'F86 #%s - %s' % (f86.name, line.tax_code.name), 0.0,
215 line.amount))
216
217
218=== modified file 'l10n_ve_imex/model/invoice.py'
219--- l10n_ve_imex/model/invoice.py 2013-11-18 08:53:35 +0000
220+++ l10n_ve_imex/model/invoice.py 2014-01-08 15:40:54 +0000
221@@ -143,11 +143,13 @@
222
223 def on_change_invoice_id(self, cr, uid, ids, invoice_id, context=None):
224 context = context or {}
225+ rp_obj = self.pool.get('res.partner')
226 res = {}
227 if invoice_id:
228 obj_inv = self.pool.get('account.invoice')
229- inv = obj_inv.browse(cr, uid, invoice_id, context=context)
230- res = {'value': {'partner_id': inv.partner_id.id,
231+ inv_brw = obj_inv.browse(cr, uid, invoice_id, context=context)
232+ acc_part_brw = rp_obj._find_accounting_partner(inv_brw.partner_id)
233+ res = {'value': {'partner_id': acc_part_brw.id,
234 'supplier_invoice_number': inv.supplier_invoice_number}}
235 return res
236
237
238=== modified file 'l10n_ve_withholding/model/invoice.py'
239--- l10n_ve_withholding/model/invoice.py 2013-12-08 02:37:57 +0000
240+++ l10n_ve_withholding/model/invoice.py 2014-01-08 15:40:54 +0000
241@@ -49,6 +49,7 @@
242 """
243 if context is None:
244 context = {}
245+ rp_obj = self.pool.get('res.partner')
246
247 #TODO check if we can use different period for payment and the writeoff line
248 assert len(ids)==1, "Can only pay one invoice at a time"
249@@ -62,7 +63,7 @@
250 'debit': direction * pay_amount>0 and direction * pay_amount,
251 'credit': direction * pay_amount<0 and - direction * pay_amount,
252 'account_id': src_account_id,
253- 'partner_id': invoice.partner_id.id,
254+ 'partner_id': rp_obj._find_accounting_partner(invoice.partner_id).id,
255 'ref':invoice.number,
256 'date': date,
257 'currency_id': False,
258
259=== modified file 'l10n_ve_withholding_islr/__openerp__.py'
260--- l10n_ve_withholding_islr/__openerp__.py 2013-11-18 03:33:54 +0000
261+++ l10n_ve_withholding_islr/__openerp__.py 2014-01-08 15:40:54 +0000
262@@ -67,11 +67,9 @@
263 #"edi/islr_wh_doc_action_data.xml",
264 ],
265 'test': [
266-# 'test/fr_tax_except.yml',
267-# 'test/test.yml',
268-# 'test/test_sale.yml',
269-# 'test/test_notax.yml',
270-# 'test/test_duplicate.yml',
271+ 'test/supplier_wh_islr_invoice.yml',
272+ 'test/supplier_wh_islr_doc.yml',
273+ 'test/customer_wh_islr_doc.yml',
274 ],
275 "active": False,
276 "installable": True,
277
278=== modified file 'l10n_ve_withholding_islr/demo/l10n_ve_islr_withholding_demo.xml'
279--- l10n_ve_withholding_islr/demo/l10n_ve_islr_withholding_demo.xml 2013-11-16 17:57:37 +0000
280+++ l10n_ve_withholding_islr/demo/l10n_ve_islr_withholding_demo.xml 2014-01-08 15:40:54 +0000
281@@ -32,12 +32,162 @@
282 <!--Concepts
283 Just adding accounts to concepts to be able to execute the withholding
284 -->
285- <record id="l10n_ve_withholding_islr.islr_wh_concept_hprof_no_mercantiles" model="islr.wh.concept">
286+ <record id="islr_wh_concept_hprof_no_mercantiles" model="islr.wh.concept">
287 <field name="property_retencion_islr_payable" ref="islr_pay"/>
288 <field name="property_retencion_islr_receivable" ref="islr_rec"/>
289 </record>
290
291- <record id="l10n_ve_withholding_islr.islr_wh_concept_pago_contratistas" model="islr.wh.concept">
292+ <record id="islr_wh_concept_pago_contratistas" model="islr.wh.concept">
293+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
294+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
295+ </record>
296+
297+ <record id="islr_wh_concept_no_apply_withholding" model="islr.wh.concept">
298+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
299+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
300+ </record>
301+
302+ <record id="islr_wh_concept_cualquie_cosa_menos_sueldos" model="islr.wh.concept">
303+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
304+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
305+ </record>
306+
307+ <record id="islr_wh_concept_pagos_transportes_y_fletes" model="islr.wh.concept">
308+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
309+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
310+ </record>
311+
312+ <record id="islr_wh_concept_pagos_de_servicios_publicitarios" model="islr.wh.concept">
313+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
314+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
315+ </record>
316+
317+ <record id="islr_wh_concept_pagos_administradores_en_el_pais" model="islr.wh.concept">
318+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
319+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
320+ </record>
321+
322+ <record id="islr_wh_concept_sueldos_y_salarios" model="islr.wh.concept">
323+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
324+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
325+ </record>
326+
327+ <record id="islr_wh_concept_hprof_mancomunados_no_mercantiles" model="islr.wh.concept">
328+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
329+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
330+ </record>
331+
332+ <record id="islr_wh_concept_hprof_jinetes_entrenadores_preparadores" model="islr.wh.concept">
333+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
334+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
335+ </record>
336+
337+ <record id="islr_wh_concept_hprof_sin_relacion_otras_instituciones" model="islr.wh.concept">
338+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
339+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
340+ </record>
341+
342+ <record id="islr_wh_concept_comisiones_venta_inmuebles" model="islr.wh.concept">
343+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
344+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
345+ </record>
346+
347+ <record id="islr_rh_concept_interes_capital_invertido_en_renta" model="islr.wh.concept">
348+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
349+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
350+ </record>
351+
352+ <record id="islr_wh_concept_int_prestamos_exterior" model="islr.wh.concept">
353+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
354+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
355+ </record>
356+
357+ <record id="islr_wh_concept_intereses_por_personas_juridicas_o_comunidades" model="islr.wh.concept">
358+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
359+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
360+ </record>
361+
362+ <record id="islr_wh_concept_exhibicion_de_peliculas" model="islr.wh.concept">
363+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
364+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
365+ </record>
366+
367+ <record id="islr_wh_concept_regalias" model="islr.wh.concept">
368+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
369+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
370+ </record>
371+
372+ <record id="islr_wh_concept_asistencia_tecnica" model="islr.wh.concept">
373+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
374+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
375+ </record>
376+
377+ <record id="islr_wh_concept_servicios_tecnologicos" model="islr.wh.concept">
378+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
379+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
380+ </record>
381+
382+ <record id="islr_wh_concept_primas_seguros_reaseguros" model="islr.wh.concept">
383+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
384+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
385+ </record>
386+
387+ <record id="islr_wh_concept_juegos_y_apuestas" model="islr.wh.concept">
388+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
389+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
390+ </record>
391+
392+ <record id="islr_wh_concept_loterias_e_hipodromos" model="islr.wh.concept">
393+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
394+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
395+ </record>
396+
397+ <record id="islr_wh_concept_pagos_propietarios_animales_carrera_premios" model="islr.wh.concept">
398+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
399+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
400+ </record>
401+
402+ <record id="islr_wh_concept_pago_arrendadores_en_el_pais" model="islr.wh.concept">
403+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
404+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
405+ </record>
406+
407+ <record id="islr_wh_concept_canon_arrendamiento_bienes_en_el_pais" model="islr.wh.concept">
408+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
409+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
410+ </record>
411+
412+ <record id="islr_wh_concept_tarjetas_de_credito_cualquier_concepto" model="islr.wh.concept">
413+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
414+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
415+ </record>
416+
417+ <record id="islr_wh_concept_tarjetas_de_credito_gasolina" model="islr.wh.concept">
418+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
419+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
420+ </record>
421+
422+ <record id="islr_wh_concept_seguros_prestacion" model="islr.wh.concept">
423+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
424+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
425+ </record>
426+
427+ <record id="islr_wh_concept_pago_seguros_reparacion_damage" model="islr.wh.concept">
428+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
429+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
430+ </record>
431+
432+ <record id="islr_wh_concept_pagos_seguros_a_clinicas" model="islr.wh.concept">
433+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
434+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
435+ </record>
436+
437+ <record id="islr_wh_concept_fondos_de_comercio_en_el_pais" model="islr.wh.concept">
438+ <field name="property_retencion_islr_payable" ref="islr_pay"/>
439+ <field name="property_retencion_islr_receivable" ref="islr_rec"/>
440+ </record>
441+
442+ <record id="islr_wh_concept_pub_emisoras" model="islr.wh.concept">
443 <field name="property_retencion_islr_payable" ref="islr_pay"/>
444 <field name="property_retencion_islr_receivable" ref="islr_rec"/>
445 </record>
446@@ -68,7 +218,15 @@
447 <field name="padding">6</field>
448 <field name="number_increment">1</field>
449 </record>
450-
451+ _
452+ <!--
453+ Product
454+ -->
455+
456+ <record id="product.product_product_4" model="product.product">
457+ <field name="concept_id" ref="islr_wh_concept_hprof_no_mercantiles"/>
458+ </record>
459+
460 <!--
461 Journal
462 -->
463
464=== modified file 'l10n_ve_withholding_islr/model/invoice.py'
465--- l10n_ve_withholding_islr/model/invoice.py 2013-12-04 21:17:57 +0000
466+++ l10n_ve_withholding_islr/model/invoice.py 2014-01-08 15:40:54 +0000
467@@ -155,8 +155,20 @@
468 wh_doc_obj = self.pool.get('islr.wh.doc')
469 inv_obj = self.pool.get('account.invoice.line')
470 rate_obj = self.pool.get('islr.rates')
471+ rp_obj = self.pool.get('res.partner')
472
473 row = self.browse(cr, uid, ids[0], context=context)
474+ acc_part_id = rp_obj._find_accounting_partner(row.partner_id)
475+
476+ res = False
477+ if row.type in ('out_invoice', 'out_refund'):
478+ return False
479+ if row.type in ('in_invoice', 'in_refund') and \
480+ rp_obj._find_accounting_partner(row.company_id.partner_id).islr_withholding_agent:
481+ res = True
482+
483+ if not res: return True
484+
485 context['type'] = row.type
486 wh_ret_code = wh_doc_obj.retencion_seq_get(cr, uid)
487
488@@ -164,7 +176,7 @@
489 journal = wh_doc_obj._get_journal(cr, uid, context=context)
490 islr_wh_doc_id = wh_doc_obj.create(cr, uid,
491 {'name': wh_ret_code,
492- 'partner_id': row.partner_id.id,
493+ 'partner_id': acc_part_id.id,
494 'period_id': row.period_id.id,
495 'account_id': row.account_id.id,
496 'type': row.type,
497@@ -251,6 +263,7 @@
498 @param name: description
499 """
500 context = context or {}
501+ rp_obj = self.pool.get('res.partner')
502 ids = isinstance(ids, (int, long)) and [ids] or ids
503 res = super(account_invoice, self)._get_move_lines(cr, uid, ids, to_wh,
504 period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id,
505@@ -260,6 +273,7 @@
506 return res
507
508 inv_brw = self.browse(cr, uid, ids[0])
509+ acc_part_id = rp_obj._find_accounting_partner(inv_brw.partner_id)
510
511 types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1,
512 'in_refund': -1}
513@@ -284,7 +298,7 @@
514 'credit': direction * iwdl_brw.amount > 0 and direction *
515 iwdl_brw.amount,
516 'account_id': acc,
517- 'partner_id': inv_brw.partner_id.id,
518+ 'partner_id': acc_part_id.id,
519 'ref': inv_brw.number,
520 'date': date,
521 'currency_id': False,
522
523=== modified file 'l10n_ve_withholding_islr/model/islr_wh_doc.py'
524--- l10n_ve_withholding_islr/model/islr_wh_doc.py 2013-12-05 20:57:09 +0000
525+++ l10n_ve_withholding_islr/model/islr_wh_doc.py 2014-01-08 15:40:54 +0000
526@@ -149,6 +149,23 @@
527 'automatic_income_wh': False,
528 }
529
530+ def _check_partner(self, cr, uid, ids, context={}):
531+ """ Determine if a given partner is a Income Withholding Agent
532+ """
533+ rp_obj = self.pool.get('res.partner')
534+ obj = self.browse(cr, uid, ids[0])
535+ if obj.type in ('out_invoice', 'out_refund') and \
536+ rp_obj._find_accounting_partner(obj.partner_id).islr_withholding_agent:
537+ return True
538+ if obj.type in ('in_invoice', 'in_refund') and \
539+ rp_obj._find_accounting_partner(obj.company_id.partner_id).islr_withholding_agent:
540+ return True
541+ return False
542+
543+ _constraints = [
544+ (_check_partner, 'Error! The partner must be income withholding agent.', ['partner_id']),
545+ ]
546+
547 def check_income_wh(self, cr, uid, ids, context=None):
548 """ Check invoices to be retained and have
549 their fair share of taxes.
550@@ -297,9 +314,8 @@
551 acc_id = False
552 res = {}
553 res_wh_lines = []
554+ rp_obj = self.pool.get('res.partner')
555 inv_obj = self.pool.get('account.invoice')
556- args = [('state', '=', 'open'), ('islr_wh_doc_id', '=', False),
557- ('partner_id', '=', partner_id)]
558
559 # Unlink previous iwdi
560 iwdi_obj = self.pool.get('islr.wh.doc.invoices')
561@@ -318,14 +334,20 @@
562 iwdl_ids = []
563
564 if partner_id:
565- p = self.pool.get('res.partner').browse(cr, uid, partner_id)
566+ acc_part_id = rp_obj._find_accounting_partner(rp_obj.browse(cr, uid, partner_id))
567+ args = [('state', '=', 'open'),
568+ ('islr_wh_doc_id', '=', False),
569+ '|',
570+ ('partner_id', '=', acc_part_id.id),
571+ ('partner_id', 'child_of', acc_part_id.id),
572+ ]
573 if type in ('out_invoice', 'out_refund'):
574- acc_id = p.property_account_receivable and \
575- p.property_account_receivable.id
576+ acc_id = acc_part_id.property_account_receivable and \
577+ acc_part_id.property_account_receivable.id
578 args += [('type', 'in', ('out_invoice', 'out_refund'))]
579 else:
580- acc_id = p.property_account_payable and \
581- p.property_account_payable.id
582+ acc_id = acc_part_id.property_account_payable and \
583+ acc_part_id.property_account_payable.id
584 args += [('type', 'in', ('in_invoice', 'in_refund'))]
585
586 inv_ids = inv_obj.search(cr, uid, args, context=context)
587@@ -493,12 +515,14 @@
588 @param name: withholding voucher name
589 """
590 inv_obj = self.pool.get('account.invoice')
591+ rp_obj = self.pool.get('res.partner')
592 ret = self.browse(cr, uid, ids)[0]
593 if context is None:
594 context = {}
595 # TODO check if we can use different period for payment and the writeoff line
596 #~ assert len(invoice_ids)==1, "Can only pay one invoice at a time"
597 invoice = inv_obj.browse(cr, uid, invoice_id)
598+ acc_part_id = rp_obj._find_accounting_partner(invoice.partner_id)
599 src_account_id = invoice.account_id.id
600 # Take the seq as name for move
601 types = {'out_invoice': -1, 'in_invoice':
602@@ -511,7 +535,7 @@
603 'debit': direction * pay_amount > 0 and direction * pay_amount,
604 'credit': direction * pay_amount < 0 and - direction * pay_amount,
605 'account_id': src_account_id,
606- 'partner_id': invoice.partner_id.id,
607+ 'partner_id': acc_part_id.id,
608 'ref': invoice.number,
609 'date': date,
610 'currency_id': False,
611@@ -520,7 +544,7 @@
612 'debit': direction * pay_amount < 0 and - direction * pay_amount,
613 'credit': direction * pay_amount > 0 and direction * pay_amount,
614 'account_id': pay_account_id,
615- 'partner_id': invoice.partner_id.id,
616+ 'partner_id': acc_part_id.id,
617 'ref': invoice.number,
618 'date': date,
619 'currency_id': False,
620@@ -716,8 +740,25 @@
621 'move_id': fields.many2one('account.move', 'Journal Entry',
622 readonly=True, help="Accounting voucher"),
623 }
624+
625 _rec_rame = 'invoice_id'
626
627+ def _check_invoice(self, cr, uid, ids, context=None):
628+ """ Determine if the given invoices are in Open State
629+ """
630+ #import pdb; pdb.set_trace()
631+ context = context or {}
632+ ids = isinstance(ids, (int, long)) and [ids] or ids
633+ inv_str = ''
634+ for iwdi_brw in self.browse(cr, uid, ids):
635+ if iwdi_brw.invoice_id.state != 'open':
636+ return False
637+ return True
638+
639+ _constraints = [
640+ (_check_invoice, 'Error! The invoice must be in Open State.', ['invoice_id']),
641+ ]
642+
643 def _get_concepts(self, cr, uid, ids, context=None):
644 """ Get a list of withholdable concepts (concept_id) from the invoice lines
645 """
646@@ -767,6 +808,7 @@
647 rate_tuple = self._get_rate(
648 cr, uid, concept_id, residence, nature, context=context)
649 base = 0
650+ wh_concept = 0.0
651
652 if iwdl_brw.invoice_id.type in ('in_invoice', 'in_refund'):
653 for line in iwdl_brw.xml_ids:
654@@ -775,7 +817,6 @@
655 wh = 0.0
656 subtract = apply and rate_tuple[3] or 0.0
657 subtract_write = 0.0
658- wh_concept = 0.0
659 sb_concept = subtract
660 for line in iwdl_brw.xml_ids:
661 if apply:
662@@ -907,13 +948,15 @@
663 invoice and boolean field that determines whether the buyer is
664 retention agent.
665 """
666- if invoice.type == 'in_invoice' or invoice.type == 'in_refund':
667- vendor = invoice.partner_id
668- buyer = invoice.company_id.partner_id
669- ret_code = invoice
670+ rp_obj = self.pool.get('res.partner')
671+ inv_part_id = rp_obj._find_accounting_partner(invoice.partner_id)
672+ comp_part_id = rp_obj._find_accounting_partner(invoice.company_id.partner_id)
673+ if invoice.type in ('in_invoice', 'in_refund'):
674+ vendor = inv_part_id
675+ buyer = comp_part_id
676 else:
677- buyer = invoice.partner_id
678- vendor = invoice.company_id.partner_id
679+ buyer = inv_part_id
680+ vendor = comp_part_id
681 return (vendor, buyer, buyer.islr_withholding_agent)
682
683 def _get_residence(self, cr, uid, vendor, buyer):
684@@ -935,12 +978,14 @@
685 """ It obtained the nature of the seller from VAT, returns
686 True if natural person, and False if is legal.
687 """
688- if not partner_id.vat:
689+ rp_obj = self.pool.get('res.partner')
690+ acc_part_id = rp_obj._find_accounting_partner(partner_id)
691+ if not acc_part_id.vat:
692 raise osv.except_osv(_('Invalid action !'), _(
693- "Impossible income withholding, because the partner '%s' has not vat associated!") % (partner_id.name))
694+ "Impossible income withholding, because the partner '%s' has not vat associated!") % (acc_part_id.name))
695 return False
696 else:
697- if partner_id.vat[2:3] in 'VvEe' or partner_id.spn:
698+ if acc_part_id.vat[2:3] in 'VvEe' or acc_part_id.spn:
699 return True
700 else:
701 return False
702@@ -972,17 +1017,21 @@
703 # DUE TO OPENER HAS CHANGED THE WAY PARTNER
704 # ARE USED FOR ACCOUNT_MOVE
705 context = context or {}
706- if not partner_id.country_id:
707+ rp_obj = self.pool.get('res.partner')
708+ acc_part_id = rp_obj._find_accounting_partner(partner_id)
709+ if not acc_part_id.country_id:
710 raise osv.except_osv(_('Invalid action !'), _(
711- "Impossible income withholding, because the partner '%s' country has not been defined in the address!") % (partner_id.name))
712+ "Impossible income withholding, because the partner '%s' country has not been defined in the address!") % (acc_part_id.name))
713 else:
714- return partner_id.country_id.id
715+ return acc_part_id.country_id.id
716
717 def _get_xml_lines(self, cr, uid, ail_brw, context=None):
718 """ Extract information from the document to generate xml lines
719 @param ail_brw: invoice of the document
720 """
721 context = context or {}
722+ rp_obj = self.pool.get('res.partner')
723+ acc_part_id = rp_obj._find_accounting_partner(ail_brw.invoice_id.partner_id)
724 vendor, buyer, wh_agent = self._get_partners(
725 cr, uid, ail_brw.invoice_id)
726 residence = self._get_residence(cr, uid, vendor, buyer)
727@@ -1001,7 +1050,7 @@
728 'period_id': False, # We review the definition because it is in NOT NULL
729 'invoice_number': ail_brw.invoice_id.supplier_invoice_number,
730 'rate_id': rate_id, # I get it too but from the rate
731- 'partner_id': ail_brw.invoice_id.partner_id.id, # Warning Depends if is a customer or supplier
732+ 'partner_id': acc_part_id.id, # Warning Depends if is a customer or supplier
733 'concept_id': ail_brw.concept_id.id,
734 'partner_vat': vendor.vat[2:12], # Warning Depends if is a customer or supplier
735 'porcent_rete': rate_wh_perc, # I get it too but from the rate
736
737=== modified file 'l10n_ve_withholding_islr/model/islr_xml_wh.py'
738--- l10n_ve_withholding_islr/model/islr_xml_wh.py 2013-12-05 21:44:49 +0000
739+++ l10n_ve_withholding_islr/model/islr_xml_wh.py 2014-01-08 15:40:54 +0000
740@@ -179,6 +179,7 @@
741 def _xml(self, cr,uid,ids):
742 """ Transform this document to XML format
743 """
744+ rp_obj = self.pool.get('res.partner')
745 root = ''
746 for id in ids:
747 wh_brw = self.browse(cr,uid,id)
748@@ -194,7 +195,7 @@
749 xml_lines=cr.fetchall()
750
751 root = Element("RelacionRetencionesISLR")
752- root.attrib['RifAgente'] = wh_brw.company_id.partner_id.vat[2:]
753+ root.attrib['RifAgente'] = rp_obj._find_accounting_partner(wh_brw.company_id.partner_id).vat[2:]
754 root.attrib['Periodo'] = period2
755 for line in xml_lines:
756 partner_vat,control_number,porcent_rete,concept_code,invoice_number,base,inv_id=line
757@@ -247,8 +248,9 @@
758 def onchange_partner_vat(self, cr, uid, ids, partner_id, context={}):
759 """ Changing the partner, the partner_vat field is updated.
760 """
761- partner_brw = self.pool.get('res.partner').browse(cr,uid,partner_id)
762- return {'value' : {'partner_vat':partner_brw.vat[2:]}}
763+ rp_obj = self.pool.get('res.partner')
764+ acc_part_brw = rp_obj._find_accounting_partner(rp_obj.browse(cr,uid,partner_id))
765+ return {'value' : {'partner_vat':acc_part_brw.vat[2:]}}
766
767
768 def onchange_code_perc(self, cr, uid, ids, rate_id, context={}):
769
770=== added file 'l10n_ve_withholding_islr/test/customer_wh_islr_doc.yml'
771--- l10n_ve_withholding_islr/test/customer_wh_islr_doc.yml 1970-01-01 00:00:00 +0000
772+++ l10n_ve_withholding_islr/test/customer_wh_islr_doc.yml 2014-01-08 15:40:54 +0000
773@@ -0,0 +1,300 @@
774+-
775+ 3. I check the customer income withholding documents (Sale).
776+-
777+ 3.1 I configure the test enviroment and check data and demo.
778+-
779+ I set the context for the purchase operations at this set of cases.
780+-
781+ !context
782+ 'type': 'out_invoice'
783+-
784+ I check that only one non-withholdable concept is define.
785+-
786+ !python {model: islr.wh.concept}: |
787+ iwc_ids = self.search(cr, uid, [( 'withholdable', '=', False )])
788+ assert len(iwc_ids) == 1, ( 'Only can be defined one non-withhodeable'
789+ ' concepts, but %s are defined.' % (len(iwc_ids), ))
790+-
791+ I check that all the withholdable concepts have accounts type 'other' associtated and also have mandatory income rates.
792+-
793+ !python {model: islr.wh.concept}: |
794+ iwc_ids = self.search(cr, uid, [( 'withholdable', '=', True )])
795+ for iwc_brw in self.browse(cr, uid, iwc_ids):
796+ assert iwc_brw.rate_ids, 'All the withholdable concepts need to have rates associated'
797+ assert iwc_brw.property_retencion_islr_payable, 'All the withholdable concepts need to have an income withholding purchase acc set.'
798+ assert iwc_brw.property_retencion_islr_payable.type == 'other', 'All the withholdable concepts need to have an income withholding purchase acc of type other.'
799+ assert iwc_brw.property_retencion_islr_receivable, 'All the withholdable concepts need to have an income withholding sale acc set.'
800+ assert iwc_brw.property_retencion_islr_receivable.type == 'other', 'All the withholdable concepts need to have an income withholding sale acc of type other.'
801+
802+-
803+ I check that the concept that will be use is withhodable.
804+-
805+ !assert {model: islr.wh.concept, id: islr_wh_concept_hprof_no_mercantiles, string: The income concept is not withholdable}:
806+ - withholdable
807+-
808+ I check that the product that will be use have a concept.
809+-
810+ !assert {model: product.product, id: product.product_product_4, string: Have not a concept.}:
811+ - concept_id.id == ref( 'islr_wh_concept_hprof_no_mercantiles' )
812+-
813+ I check that the customer that will be use is an income withholding agent and is at Venezuela.
814+-
815+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The customer is not correctly set for this test.}:
816+ - islr_withholding_agent
817+ - country_id.code == 'VE'
818+ - vat
819+-
820+ I check if the account that will be use is of receivable type.
821+-
822+ !assert {model: account.account, id: account.a_recv, string: The account is not of receivable type}:
823+ - type == 'receivable'
824+-
825+ 3.2 I check that an customer invoice confirmation will not automatic create a withholding document.
826+-
827+ I create a customer invoice with a withholdable concept (in the product).
828+-
829+ !record {model: account.invoice, id: islr_customer_invoice, view: account.invoice_form}: &customer_ai
830+ nro_ctrl: ISLR CUSTOMER INVOICE ()
831+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
832+ account_id: account.a_recv
833+ company_id: base.main_company
834+ currency_id: base.EUR
835+ invoice_line: &customer_ail
836+ - product_id: product.product_product_4
837+ quantity: 3
838+ uos_id: product.product_uom_unit
839+ price_unit: 1000
840+ account_id: account.a_recv
841+-
842+ I check that the invoices was correctly created.
843+-
844+ !assert {model: account.invoice, id: islr_customer_invoice, string: The invoices was no correctly created}:
845+ - state == 'draft'
846+ - type == 'out_invoice'
847+-
848+ I confirm the invoice.
849+-
850+ !workflow {model: account.invoice, action: invoice_open, ref: islr_customer_invoice}
851+-
852+ I check that the invoice is confirmed and not generate a withholding doc.
853+-
854+ !assert {model: account.invoice, id: islr_customer_invoice, string: The invoice was not correctly confirmed.}:
855+ - state == 'open'
856+ - not islr_wh_doc_id
857+-
858+ 3.3 I check that a withholding document can be created manually when the customer is a withholding agent.
859+-
860+ I create a withholding document manually.
861+-
862+ !record {model: islr.wh.doc, id: islr_customer_wh_doc, view: l10n_ve_withholding_islr.view_islr_form_customers}:
863+ name: ISLR WH DOC (CUSTOMER MANUALLY)
864+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
865+ account_id: account.a_recv
866+-
867+ I unlink the auto-loaded invoices.
868+-
869+ !python {model: islr.wh.doc}: |
870+ iwd_id = ref( 'islr_customer_wh_doc' )
871+ iwd_brw = self.browse(cr, uid, iwd_id)
872+ iwdi_ids = [inv_line.id
873+ for inv_line in iwd_brw.invoice_ids]
874+ iwdi_ids and self.pool.get( 'islr.wh.doc.invoices' ).unlink(cr, uid, iwdi_ids)
875+-
876+ I check that the withholding document is withhout invoices.
877+-
878+ !assert {model: islr.wh.doc, id: islr_customer_wh_doc, string: The withholding document should be without invoices}:
879+ - not invoice_ids
880+-
881+ I create a customer invoice.
882+-
883+ !record {model: account.invoice, id: islr_manual_wh_customer_invoice, view: account.invoice_form}:
884+ nro_ctrl: ISLR CUSTOMER INVOICE (MANUAL WH)
885+ <<: *customer_ai
886+-
887+ I confirm the invoice.
888+-
889+ !workflow {model: account.invoice, action: invoice_open, ref: islr_manual_wh_customer_invoice}
890+-
891+ I add the invoice to the withholding document.
892+-
893+ !record {model: islr.wh.doc, id: islr_customer_wh_doc, view: l10n_ve_withholding_islr.view_islr_form_customers}:
894+ invoice_ids:
895+ - invoice_id: islr_manual_wh_customer_invoice
896+-
897+ I compute the taxes manually with the button 'Compute Icome Withholding'.
898+-
899+ !function {model: islr.wh.doc, name: compute_amount_wh, id: islr_customer_wh_doc}:
900+ - model: islr.wh.doc
901+ eval: "[ref('islr_customer_wh_doc')]"
902+-
903+ I confirm the withholding document.
904+-
905+ !python {model: islr.wh.doc}: |
906+ iwd_id = ref( 'islr_customer_wh_doc' )
907+ import netsvc
908+ from openerp.osv import osv
909+ wf_service = netsvc.LocalService( 'workflow' )
910+ wf_service.trg_validate(uid, 'islr.wh.doc', iwd_id, 'act_confirm', cr)
911+-
912+ I check that the withholding document is confirmed.
913+-
914+ !assert {model: islr.wh.doc, id: islr_customer_wh_doc}:
915+ - state == 'confirmed'
916+-
917+ 3.4 I check that a manually created withholding document can not be confirmed if it is withhout withholding lines.
918+-
919+ I create a withholding document manually.
920+-
921+ !record {model: islr.wh.doc, id: islr_no_lines_customer_wh_doc}:
922+ name: ISLR WH DOC (NOT WH LINES)
923+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
924+ account_id: account.a_recv
925+-
926+ I unlink the auto-loaded invoices.
927+-
928+ !python {model: islr.wh.doc}: |
929+ iwd_id = ref( 'islr_no_lines_customer_wh_doc' )
930+ iwd_brw = self.browse(cr, uid, iwd_id)
931+ iwdi_ids = [inv_line.id
932+ for inv_line in iwd_brw.invoice_ids]
933+ iwdi_ids and self.pool.get( 'islr.wh.doc.invoices' ).unlink(cr, uid, iwdi_ids)
934+-
935+ I check that the withholding document is withhout invoices.
936+-
937+ !assert {model: islr.wh.doc, id: islr_no_lines_customer_wh_doc, string: The withholding document should be without invoices}:
938+ - invoice_ids == []
939+-
940+ I try to confirm the withholding document. It won't be confirm.
941+-
942+ !python {model: islr.wh.doc}: |
943+ iwd_id = ref( 'islr_no_lines_customer_wh_doc' )
944+ # the workflow is not used because the exception can be manage
945+ try:
946+ check_flag = self.check_income_wh(cr, uid, iwd_id)
947+ except Exception as e:
948+ check_flag = False
949+ assert not check_flag, 'The withholding can not be confirm.'
950+-
951+ 3.5 I check that only Open invoices can be add to a withholding document.
952+-
953+ I create a withholding document manually.
954+-
955+ !record {model: islr.wh.doc, id: islr_open_state_customer_wh_doc}:
956+ name: ISLR WH DOC (INVOICE OPEN STATE)
957+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
958+ account_id: account.a_recv
959+-
960+ I unlink the auto-loaded invoices.
961+-
962+ !python {model: islr.wh.doc}: |
963+ iwd_id = ref( 'islr_open_state_customer_wh_doc' )
964+ iwd_brw = self.browse(cr, uid, iwd_id)
965+ iwdi_ids = [inv_line.id
966+ for inv_line in iwd_brw.invoice_ids]
967+ iwdi_ids and self.pool.get( 'islr.wh.doc.invoices' ).unlink(cr, uid, iwdi_ids)
968+-
969+ I check that the withholding document is withhout invoices.
970+-
971+ !assert {model: islr.wh.doc, id: islr_open_state_customer_wh_doc, string: The withholding document should be without invoices}:
972+ - invoice_ids == []
973+-
974+ I create a customer invoice.
975+-
976+ !record {model: account.invoice, id: islr_open_state_customer_invoice, view: account.invoice_form}:
977+ nro_ctrl: ISLR CUSTOMER INVOICE (INVOICE OPEN STATE)
978+ <<: *customer_ai
979+-
980+ I check that the invoice was correctly created.
981+-
982+ !assert {model: account.invoice, id: islr_open_state_customer_invoice, string: The invoices was no correctly created}:
983+ - state == 'draft'
984+ - type == 'out_invoice'
985+-
986+ I try to add a draft invoice to the withholding document. It wont be added.
987+-
988+ !python {model: islr.wh.doc}: |
989+ from openerp.osv import orm
990+ iwd_id = ref( 'islr_open_state_customer_wh_doc')
991+ inv_id = ref( 'islr_open_state_customer_invoice' )
992+ flag = True
993+ values= { 'invoice_ids' : [( 0, 0, {'invoice_id': inv_id })] }
994+ try:
995+ cr.execute('SAVEPOINT islr_open_state_customer_wh_doc')
996+ self.write(cr, uid, iwd_id, values)
997+ cr.execute('RELEASE SAVEPOINT islr_open_state_customer_wh_doc')
998+ flag = False
999+ except orm.except_orm:
1000+ cr.execute('ROLLBACK TO SAVEPOINT islr_open_state_customer_wh_doc')
1001+ assert flag, 'This should not happen!!! It was expected an exception was raised'
1002+-
1003+ I check that the invoice was not added.
1004+-
1005+ !assert {model: islr.wh.doc, id: islr_open_state_customer_wh_doc, string: The draft invoice was added and it should not.}:
1006+ - invoice_ids == []
1007+-
1008+ I confirm the invoice.
1009+-
1010+ !workflow {model: account.invoice, action: invoice_open, ref: islr_open_state_customer_invoice}
1011+-
1012+ I check that the invoice is confirmed.
1013+-
1014+ !assert {model: account.invoice, id: islr_open_state_customer_invoice, string: The invoices was no correctly confirm.}:
1015+ - state == 'open'
1016+-
1017+ I add the invoice to the withholding document.
1018+-
1019+ !record {model: islr.wh.doc, id: islr_open_state_customer_wh_doc, view: l10n_ve_withholding_islr.view_islr_form_customers}:
1020+ invoice_ids:
1021+ - invoice_id: islr_open_state_customer_invoice
1022+-
1023+ I check that the invoice was added.
1024+-
1025+ !assert {model: islr.wh.doc, id: islr_open_state_customer_wh_doc, string: The open invoice was not added and it should.}:
1026+ - invoice_ids[0].invoice_id.id == ref( 'islr_open_state_customer_invoice' )
1027+-
1028+ 3.6 I check that a withholding document cannot be created manually for a customer that is not a withholding agent.
1029+-
1030+ I set the partner that will be use in this test like a not withholding partner.
1031+-
1032+ !python {model: res.partner}: |
1033+ partner_id = ref( 'l10n_ve_fiscal_requirements.f_req_partner_3')
1034+ partner_brw = self.browse(cr, uid, partner_id)
1035+ self.write(cr, uid, partner_id, {'islr_withholding_agent': False})
1036+-
1037+ I check if the partner i will use in this case is a not withholding partner and have no accounting partner that influencing it.
1038+-
1039+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_3, string: The partner is a withholding partner.}:
1040+ - not islr_withholding_agent
1041+ - not parent_id
1042+-
1043+ I try to create a withholding document manually. It won't be created.
1044+-
1045+ !python {model: islr.wh.doc}: |
1046+ values = {
1047+ 'name': 'ISLR WH DOC (NOT WH CUSTOMER)',
1048+ 'partner_id': ref( 'l10n_ve_fiscal_requirements.f_req_partner_3' ),
1049+ 'account_id': ref( 'account.a_recv' ),
1050+ 'type': 'out_invoice',
1051+ }
1052+ try:
1053+ create_flag = self.create(cr, uid, values)
1054+ except Exception as e:
1055+ create_flag = False
1056+ assert not create_flag, ' The withholding document can be created because the customer is not a withholding document'
1057+-
1058+ 3.7 I check that a withholding document with a income withholdable customer cannot be updated to a not income withholdable partner.
1059+-
1060+ !python {model: islr.wh.doc}: |
1061+ values = {
1062+ 'name': 'ISLR WH DOC (WH CUSTOMER TO A NOT WH CUSTOMER)',
1063+ 'partner_id': ref( 'l10n_ve_fiscal_requirements.f_req_partner_1' ),
1064+ 'account_id': ref( 'account.a_recv' ),
1065+ 'type': 'out_invoice',
1066+ }
1067+ iwd_id = self.create(cr, uid, values)
1068+ new_values = {'partner_id': ref( 'l10n_ve_fiscal_requirements.f_req_partner_3' )}
1069+ try:
1070+ write_flag = self.write(cr, uid, [iwd_id], new_values)
1071+ except Exception as e:
1072+ write_flag = False
1073+ assert not write_flag, ' The withholding document can be updated from a withholding partner to a non-withholding partner.'
1074
1075=== added file 'l10n_ve_withholding_islr/test/supplier_wh_islr_doc.yml'
1076--- l10n_ve_withholding_islr/test/supplier_wh_islr_doc.yml 1970-01-01 00:00:00 +0000
1077+++ l10n_ve_withholding_islr/test/supplier_wh_islr_doc.yml 2014-01-08 15:40:54 +0000
1078@@ -0,0 +1,914 @@
1079+-
1080+ 2. I check if the supplier income withholding documents are correctly created. Income Withholding document lines corresponds to the concepts and the amount totalization.
1081+-
1082+ 2.1 I configure the test enviroment and check data and demo.
1083+-
1084+ I set the context for the purchase operations at this set of cases.
1085+-
1086+ !context
1087+ 'type': 'in_invoice'
1088+-
1089+ I check that the company is a income withholding agent and is at Venezuela.
1090+-
1091+ !assert {model: res.partner, id: base.main_partner, string: The company is a non-withholdable agent}:
1092+ - islr_withholding_agent
1093+ - country_id.code == 'VE'
1094+ - not company_id.automatic_income_wh
1095+-
1096+ I check that only one non-withholdable concept is define.
1097+-
1098+ !python {model: islr.wh.concept}: |
1099+ iwc_ids = self.search(cr, uid, [( 'withholdable', '=', False )])
1100+ assert len(iwc_ids) == 1, ( 'Only can be defined one non-withhodeable'
1101+ ' concepts, but %s are defined.' % (len(iwc_ids), ))
1102+-
1103+ I check that all the withholdable concepts have accounts type 'other'
1104+ associtated and also have mandatory income rates.
1105+-
1106+ !python {model: islr.wh.concept}: |
1107+ iwc_ids = self.search(cr, uid, [( 'withholdable', '=', True )])
1108+ for iwc_brw in self.browse(cr, uid, iwc_ids):
1109+ assert iwc_brw.rate_ids, 'All the withholdable concepts need to have rates associated'
1110+ assert iwc_brw.property_retencion_islr_payable, 'All the withholdable concepts need to have an income withholding purchase acc set.'
1111+ assert iwc_brw.property_retencion_islr_payable.type == 'other', 'All the withholdable concepts need to have an income withholding purchase acc of type other.'
1112+ assert iwc_brw.property_retencion_islr_receivable, 'All the withholdable concepts need to have an income withholding sale acc set.'
1113+ assert iwc_brw.property_retencion_islr_receivable.type == 'other', 'All the withholdable concepts need to have an income withholding sale acc of type other.'
1114+-
1115+ I check that the supplier that will be use is income withholdable.
1116+-
1117+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier is not correctly set for this test.}:
1118+ - islr_withholding_agent
1119+ - country_id.code == 'VE'
1120+ - vat
1121+-
1122+ I check that the concept that will be use is withhodable.
1123+-
1124+ !assert {model: islr.wh.concept, id: islr_wh_concept_hprof_no_mercantiles, string: The income concept is not withholdable}:
1125+ - withholdable
1126+-
1127+ I check that the product that will be use have a concept.
1128+-
1129+ !assert {model: product.product, id: product.product_product_4, string: Have not a concept.}:
1130+ - concept_id
1131+-
1132+ 2.2 I check that one invoice only creates a single one withholding line.
1133+-
1134+ I create a supplier invoice with a withholdable concept.
1135+-
1136+ !record {model: account.invoice, id: islr_one_iwdi_supplier_invoice, view: account.invoice_supplier_form}: &islr_supplier_ai
1137+ nro_ctrl: ISLR SUPPLIER INVOICE (ONE IWDI)
1138+ supplier_invoice_number: ISLR SUPPLIER INVOICE (ONE IWDI)
1139+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
1140+ account_id: account.a_pay
1141+ company_id: base.main_company
1142+ currency_id: base.EUR
1143+ reference_type: none
1144+ invoice_line: &islr_supplier_wh_ail
1145+ - product_id: product.product_product_4
1146+ quantity: 3
1147+ uos_id: product.product_uom_unit
1148+ price_unit: 3000
1149+ account_id: account.a_pay
1150+ #concept_id: already in product.
1151+-
1152+ I check that the invoice was correctly created.
1153+-
1154+ !assert {model: account.invoice, id: islr_one_iwdi_supplier_invoice, string: The invoice was not correctly created}:
1155+ - state == 'draft'
1156+ - type == 'in_invoice'
1157+-
1158+ I confirm the invoice to generate the withholding document.
1159+-
1160+ !workflow {model: account.invoice, action: invoice_open, ref: islr_one_iwdi_supplier_invoice}
1161+-
1162+ I check that the invoice is confirmed and it generate a draft withholding with a single line.
1163+-
1164+ !assert {model: account.invoice, id: islr_one_iwdi_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1165+ - state == 'open'
1166+ - islr_wh_doc_id
1167+ - islr_wh_doc_id.state == 'draft'
1168+ - len(islr_wh_doc_id.invoice_ids) == 1
1169+-
1170+ 2.3 I check the withholding document invoices grouping by concept, one per concept.
1171+-
1172+ I create an invoice with two invoice lines with the same concept.
1173+-
1174+ !record {model: account.invoice, id: islr_iwdi_sum_supplier_invoice, view: account.invoice_supplier_form}:
1175+ nro_ctrl: ISLR SUPPLIER INVOICE (TWO LINES OF SAME CONCEPT)
1176+ supplier_invoice_number: ISLR SUPPLIER INVOICE (TWO LINES OF SAME CONCEPT)
1177+ invoice_line:
1178+ - price_unit: 3000
1179+ quantity: 1
1180+ <<: *islr_supplier_wh_ail
1181+ - price_unit: 1000
1182+ quantity: 2
1183+ <<: *islr_supplier_wh_ail
1184+ <<: *islr_supplier_ai
1185+-
1186+ I check that the invoice was correctly created.
1187+-
1188+ !assert {model: account.invoice, id: islr_iwdi_sum_supplier_invoice, string: The invoice was not correctly created}:
1189+ - state == 'draft'
1190+ - type == 'in_invoice'
1191+-
1192+ I confirm the invoice.
1193+-
1194+ !workflow {model: account.invoice, action: invoice_open, ref: islr_iwdi_sum_supplier_invoice}
1195+-
1196+ I check that the invoice is confirmed and it genarate a draft income withholding with one withholding document line that correctly takes the base amount and the withheld amount.
1197+-
1198+ !assert {model: account.invoice, id: islr_iwdi_sum_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1199+ - state == 'open'
1200+ - islr_wh_doc_id
1201+ - islr_wh_doc_id.state == 'draft'
1202+ - len(islr_wh_doc_id.invoice_ids) == 1
1203+ - islr_wh_doc_id.invoice_ids[0].base_ret == 5000.0
1204+ - islr_wh_doc_id.invoice_ids[0].amount_islr_ret == 250.0
1205+-
1206+ 2.4 I check that a withholding concept line is created per invoice concept.
1207+-
1208+ I create an invoice with two invoice lines of different withholdable concepts.
1209+-
1210+ !record {model: account.invoice, id: islr_wline_per_concept_supplier_invoice, view: account.invoice_supplier_form}:
1211+ nro_ctrl: ISLR SUPPLIER INVOICE (TWO DIFF CONCEPTS)
1212+ supplier_invoice_number: ISLR SUPPLIER INVOICE (TWO DIFF CONCEPTS)
1213+ invoice_line:
1214+ - price_unit: 1000
1215+ quantity: 2
1216+ <<: *islr_supplier_wh_ail
1217+ - &islr_supplier_wh_ail_2
1218+ name: line with another withholdable concept
1219+ quantity: 1
1220+ uos_id: product.product_uom_unit
1221+ price_unit: 500
1222+ account_id: account.a_pay
1223+ concept_id: islr_wh_concept_pago_contratistas
1224+ <<: *islr_supplier_ai
1225+-
1226+ I check that the invoice was correctly created.
1227+-
1228+ !assert {model: account.invoice, id: islr_wline_per_concept_supplier_invoice, string: The invoice was not correctly created}:
1229+ - state == 'draft'
1230+ - type == 'in_invoice'
1231+-
1232+ I confirm the invoice to generate the withholding document.
1233+-
1234+ !workflow {model: account.invoice, action: invoice_open, ref: islr_wline_per_concept_supplier_invoice}
1235+-
1236+ I check that the invoice is confirmed and it generate a draft withholding with one withholding line an two concept lines.
1237+-
1238+ !assert {model: account.invoice, id: islr_wline_per_concept_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1239+ - state == 'open'
1240+ - islr_wh_doc_id
1241+ - islr_wh_doc_id.state == 'draft'
1242+ - len(islr_wh_doc_id.invoice_ids) == 1
1243+ - len(islr_wh_doc_id.concept_ids) == 2
1244+-
1245+ 2.5 I check that the withholding line sums.
1246+-
1247+ I create an invoice with two invoice lines of different withholdable concepts.
1248+-
1249+ !record {model: account.invoice, id: islr_concept_sum_supplier_invoice, view: account.invoice_supplier_form}:
1250+ nro_ctrl: ISLR SUPPLIER INVOICE (CONCEPTS SUMS)
1251+ supplier_invoice_number: ISLR SUPPLIER INVOICE (CONCEPTS SUMS)
1252+ invoice_line:
1253+ - price_unit: 1000
1254+ quantity: 1
1255+ <<: *islr_supplier_wh_ail
1256+ - price_unit: 2000
1257+ quantity: 1
1258+ <<: *islr_supplier_wh_ail
1259+ - <<: *islr_supplier_wh_ail_2
1260+ - &islr_supplier_nwh_ail
1261+ name: line with no withhodeable concept.
1262+ quantity: 1
1263+ uos_id: product.product_uom_unit
1264+ price_unit: 300
1265+ account_id: account.a_pay
1266+ concept_id: islr_wh_concept_no_apply_withholding
1267+ <<: *islr_supplier_ai
1268+-
1269+ I check that the invoice was correctly created.
1270+-
1271+ !assert {model: account.invoice, id: islr_concept_sum_supplier_invoice, string: The invoice was not correctly created}:
1272+ - state == 'draft'
1273+ - type == 'in_invoice'
1274+-
1275+ I confirm the invoice to generate the withholding document.
1276+-
1277+ !workflow {model: account.invoice, action: invoice_open, ref: islr_concept_sum_supplier_invoice}
1278+-
1279+ I check that the invoice is confirmed and it generate a draft withholding with one withholding line with the correct sums an two concept lines.
1280+-
1281+ !assert {model: account.invoice, id: islr_concept_sum_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1282+ - state == 'open'
1283+ - islr_wh_doc_id
1284+ - islr_wh_doc_id.state == 'draft'
1285+ - len(islr_wh_doc_id.invoice_ids) == 1
1286+ - len(islr_wh_doc_id.concept_ids) == 2
1287+ - islr_wh_doc_id.invoice_ids[0].base_ret == 3500.0
1288+ - islr_wh_doc_id.invoice_ids[0].amount_islr_ret == 160.0
1289+-
1290+ I check that the withholding concepts lines sums are ok.
1291+-
1292+ !python {model: islr.wh.doc}: |
1293+ inv_id = ref( 'islr_concept_sum_supplier_invoice' )
1294+ islr_wh_doc_id = self.pool.get( 'account.invoice' ).browse(
1295+ cr, uid, inv_id).islr_wh_doc_id
1296+ for cline in islr_wh_doc_id.concept_ids:
1297+ assert (
1298+ (cline.concept_id.id == ref( 'islr_wh_concept_hprof_no_mercantiles' )
1299+ and cline.base_amount == 3000 and cline.amount == 150 ) or
1300+ (cline.concept_id.id == ref( 'islr_wh_concept_pago_contratistas' )
1301+ and cline.base_amount == 500 and cline.amount == 10 )
1302+ ), 'There was a concept line sum error.'
1303+-
1304+ 2.6 I check the accounting partner condition.
1305+-
1306+ I check that the accounting partner parent exist and have a child partner.
1307+-
1308+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_2, string: The accounting partner is wrong.}:
1309+ - name
1310+ - vat
1311+ - child_ids
1312+ - len(child_ids) == 1
1313+-
1314+ I check that my parent and child partner exist and that are correctly configure.
1315+-
1316+ !python {model: res.partner}: |
1317+ parent_id = ref( 'l10n_ve_fiscal_requirements.f_req_partner_2' )
1318+ assert parent_id, 'The parent partner does not exist.'
1319+ parent_brw = self.browse(cr, uid, parent_id)
1320+ assert parent_brw.islr_withholding_agent, 'the parent partner is not a income withholding agent.'
1321+ assert parent_brw.country_id.code == 'VE', 'the parent partner is not in Venezuela.'
1322+ assert parent_brw.vat, 'the parent partner does not have vat number.'
1323+
1324+ child_id = ref( 'l10n_ve_fiscal_requirements.f_req_partner_9' )
1325+ assert child_id, 'The child partner does not exist.'
1326+ child_brw = self.browse(cr, uid, child_id)
1327+ assert child_brw.islr_withholding_agent, 'the child partner is not a income withholding agent.'
1328+ assert child_brw.country_id.code == 'VE', 'the child partner is not in Venezuela.'
1329+ assert child_brw.vat, 'the child partner does not have vat number.'
1330+
1331+ assert child_brw.parent_id.id == parent_id, 'The partner tested is not child of parent partner'
1332+-
1333+ I create a invoice for the child partner.
1334+-
1335+ !record {model: account.invoice, id: islr_acctg_parnter_supplier_invoice, view: account.invoice_supplier_form}:
1336+ nro_ctrl: ISLR SUPPLIER INVOICE (ACCOUNTING PARTNER)
1337+ supplier_invoice_number: ISLR SUPPLIER INVOICE (ACCOUNTING PARTNER)
1338+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_9
1339+ <<: *islr_supplier_ai
1340+-
1341+ I check that the invoice was correctly created.
1342+-
1343+ !assert {model: account.invoice, id: islr_acctg_parnter_supplier_invoice, string: The invoice was not correctly created}:
1344+ - state == 'draft'
1345+ - type == 'in_invoice'
1346+-
1347+ I confirm the invoice to generate the withholding document.
1348+-
1349+ !workflow {model: account.invoice, action: invoice_open, ref: islr_acctg_parnter_supplier_invoice}
1350+-
1351+ I check that the withholding document is associated to the parent partner.
1352+-
1353+ !python {model: islr.wh.doc}: |
1354+ inv_id = ref( 'islr_acctg_parnter_supplier_invoice' )
1355+ inv_brw = self.pool.get( 'account.invoice' ).browse(cr, uid, inv_id)
1356+ iwd_brw = inv_brw.islr_wh_doc_id
1357+ assert iwd_brw.partner_id == inv_brw.partner_id.parent_id, 'The withholding document partner need to be the accouting parnter (the parent of the partner in the invoice).'
1358+-
1359+ I confirm the withholding document.
1360+-
1361+ !python {model: islr.wh.doc}: |
1362+ inv_id = ref( 'islr_acctg_parnter_supplier_invoice' )
1363+ iwd_id = self.pool.get( 'account.invoice' ).browse(
1364+ cr, uid, inv_id).islr_wh_doc_id.id
1365+ import netsvc
1366+ from openerp.osv import osv
1367+ wf_service = netsvc.LocalService( 'workflow' )
1368+ wf_service.trg_validate(uid, 'islr.wh.doc', iwd_id, 'act_confirm', cr)
1369+-
1370+ I check that the withholding document was confirmed and have no moves.
1371+-
1372+ !assert {model: account.invoice, id: islr_acctg_parnter_supplier_invoice, string: The invoice was not confirm}:
1373+ - islr_wh_doc_id.state == 'confirmed'
1374+ - not islr_wh_doc_id.invoice_ids[0].move_id
1375+-
1376+ I change the withholding document to done.
1377+-
1378+ !python {model: islr.wh.doc}: |
1379+ inv_id = ref( 'islr_acctg_parnter_supplier_invoice' )
1380+ iwd_id = self.pool.get( 'account.invoice' ).browse(
1381+ cr, uid, inv_id).islr_wh_doc_id.id
1382+ import netsvc
1383+ from openerp.osv import osv
1384+ wf_service = netsvc.LocalService( 'workflow' )
1385+ wf_service.trg_validate(uid, 'islr.wh.doc', iwd_id, 'act_done', cr)
1386+-
1387+ I check that the withholding document is done and it generate a move.
1388+-
1389+ !assert {model: account.invoice, id: islr_acctg_parnter_supplier_invoice, string: The invoice was not confirm}:
1390+ - islr_wh_doc_id.state == 'done'
1391+ - islr_wh_doc_id.invoice_ids[0].move_id
1392+-
1393+ I check that the moves generated by the withholding document are associated to the parent partner.
1394+-
1395+ !python {model: islr.wh.doc}: |
1396+ inv_id = ref( 'islr_acctg_parnter_supplier_invoice' )
1397+ inv_brw = self.pool.get( 'account.invoice' ).browse(cr, uid, inv_id)
1398+ iwd_brw = inv_brw.islr_wh_doc_id
1399+ for iline in iwd_brw.invoice_ids:
1400+ for mline in iline.move_id.line_id:
1401+ assert mline.partner_id.id == inv_brw.partner_id.parent_id.id, 'The move lines created are not associated to the accouting partner.'
1402+-
1403+ 2.7 I check that one islr xml line is generated by invoice line.
1404+-
1405+ I create an invoice with two invoice lines of same withholdable concept.
1406+-
1407+ !record {model: account.invoice, id: islr_xml_line_number_supplier_invoice, view: account.invoice_supplier_form}:
1408+ nro_ctrl: ISLR SUPPLIER INVOICE (XML LINE NUMBER)
1409+ supplier_invoice_number: ISLR SUPPLIER INVOICE (XML LINE NUMBER)
1410+ invoice_line:
1411+ - price_unit: 1000
1412+ quantity: 1
1413+ <<: *islr_supplier_wh_ail
1414+ - price_unit: 2000
1415+ quantity: 1
1416+ <<: *islr_supplier_wh_ail
1417+ <<: *islr_supplier_ai
1418+-
1419+ I check that the invoice was correctly created.
1420+-
1421+ !assert {model: account.invoice, id: islr_xml_line_number_supplier_invoice, string: The invoice was not correctly created}:
1422+ - state == 'draft'
1423+ - type == 'in_invoice'
1424+-
1425+ I confirm the invoice to generate the withholding document.
1426+-
1427+ !workflow {model: account.invoice, action: invoice_open, ref: islr_xml_line_number_supplier_invoice}
1428+-
1429+ I check that the invoice is confirmed and it generate a draft withholding with a single line.
1430+-
1431+ !assert {model: account.invoice, id: islr_xml_line_number_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1432+ - state == 'open'
1433+ - islr_wh_doc_id
1434+ - islr_wh_doc_id.state == 'draft'
1435+ - len(islr_wh_doc_id.invoice_ids[0].islr_xml_id) == len(invoice_line)
1436+-
1437+ 2.8 I check that when the subtotal of the invoice is not enough for withhold then a withholding document withheld amount is 0.0.
1438+-
1439+ I create a supplier invoice with a base less than the minimum of the islr rate.
1440+-
1441+ !record {model: account.invoice, id: islr_minimun_supplier_invoice, view: account.invoice_supplier_form}:
1442+ nro_ctrl: ISLR SUPPLIER INVOICE (MINIMUN WITHHOLDING)
1443+ supplier_invoice_number: ISLR SUPPLIER INVOICE (MINIMUN WITHHOLDING)
1444+ invoice_line:
1445+ - quantity: 1
1446+ price_unit: 30
1447+ <<: *islr_supplier_wh_ail
1448+ <<: *islr_supplier_ai
1449+-
1450+ I check that the invoice was correctly created.
1451+-
1452+ !assert {model: account.invoice, id: islr_minimun_supplier_invoice, string: The invoice was not correctly created}:
1453+ - state == 'draft'
1454+ - type == 'in_invoice'
1455+-
1456+ I confirm the invoice to generate the withholding document.
1457+-
1458+ !workflow {model: account.invoice, action: invoice_open, ref: islr_minimun_supplier_invoice}
1459+-
1460+ I check that the invoice is confirmed and it generate a draft withholding with withheld amount 0.0.
1461+-
1462+ !assert {model: account.invoice, id: islr_minimun_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1463+ - state == 'open'
1464+ - islr_wh_doc_id
1465+ - islr_wh_doc_id.state == 'draft'
1466+ - islr_wh_doc_id.amount_total_ret == 0.0
1467+-
1468+ 2.9 Taking the withholding document created in 2.8 I check that the rate taked is the correct one.
1469+-
1470+ !python {model: islr.wh.doc.invoices}: |
1471+ inv_id = ref( 'islr_minimun_supplier_invoice')
1472+ iwd_brw = self.pool.get( 'account.invoice' ).browse(
1473+ cr, uid, inv_id).islr_wh_doc_id
1474+ correct_rate_id = ref( 'islr_rates_004' )
1475+ assert iwd_brw.concept_ids[0].islr_rates_id.id == correct_rate_id
1476+-
1477+ 2.10 I check from a concept all is rates are taking correctly.
1478+-
1479+ !python {model: islr.wh.doc.invoices}: |
1480+ concept_id = ref( 'islr_wh_concept_cualquie_cosa_menos_sueldos' )
1481+ rates_xml = {
1482+ # (residence, nature)
1483+ ( 1, 1 ) : 'islr_rates_018',
1484+ ( 0, 1 ) : 'islr_rates_019',
1485+ ( 1, 0 ) : 'islr_rates_020',
1486+ ( 0, 0 ) : 'islr_021',
1487+ }
1488+ for conf_t, rate_xml in rates_xml.iteritems():
1489+ rate_tuple = self._get_rate(
1490+ cr, uid, concept_id, conf_t[0], conf_t[1], context=context)
1491+ rate_brw = self.pool.get( 'islr.rates' ).browse(
1492+ cr, uid, ref(rate_xml))
1493+ assert (rate_tuple[5] == rate_brw.id and
1494+ rate_tuple[4] == rate_brw.code and
1495+ rate_tuple[6] == rate_brw.name
1496+ ), 'There is an error, It is not taking the correct rate.'
1497+-
1498+ 2.11 I check that the withholding document is automatic set to Done when the automatic_income_wh attribute at the company is True.
1499+-
1500+ I set company to process the withholding automaticly.
1501+-
1502+ !record {model: res.company, id: base.main_company}:
1503+ automatic_income_wh: True
1504+-
1505+ I check that the company is correctly update.
1506+-
1507+ !assert {model: res.partner, id: base.main_partner, string: The company is not correctly set.}:
1508+ - company_id.automatic_income_wh
1509+-
1510+ I create an supplier invoice.
1511+-
1512+ !record {model: account.invoice, id: islr_auto_wh_supplier_invoice, view: account.invoice_supplier_form}:
1513+ nro_ctrl: ISLR SUPPLIER INVOICE (AUTOMATIC INCOME WH)
1514+ supplier_invoice_number: ISLR SUPPLIER INVOICE (AUTOMATIC INCOME WH)
1515+ <<: *islr_supplier_ai
1516+-
1517+ I check that the invoice was correctly created.
1518+-
1519+ !assert {model: account.invoice, id: islr_auto_wh_supplier_invoice, string: The invoice was not correctly created}:
1520+ - state == 'draft'
1521+ - type == 'in_invoice'
1522+-
1523+ I confirm the invoice to generate the withholding document.
1524+-
1525+ !workflow {model: account.invoice, action: invoice_open, ref: islr_auto_wh_supplier_invoice}
1526+-
1527+ I check that the invoice is confirmed and it generate a done withholding.
1528+-
1529+ !assert {model: account.invoice, id: islr_auto_wh_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1530+ - state == 'open'
1531+ - islr_wh_doc_id
1532+ - islr_wh_doc_id.state == 'done'
1533+-
1534+ I revert the changes in the company.
1535+-
1536+ !record {model: res.company, id: base.main_company}:
1537+ automatic_income_wh: False
1538+-
1539+ i check that the company is correctly update.
1540+-
1541+ !assert {model: res.partner, id: base.main_partner, string: the company is not correctly set.}:
1542+ - not company_id.automatic_income_wh
1543+-
1544+ 2.12 I check that when a not natural supplier is a society of natural persons it will be treat as a natural person.
1545+-
1546+ I set the supplier as a society of natural persons.
1547+-
1548+ !record {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1}:
1549+ spn: True
1550+-
1551+ I check that the supplier was correctly updated.
1552+-
1553+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier was not correctly updated }:
1554+ - spn
1555+-
1556+ I create an supplier invoice.
1557+-
1558+ !record {model: account.invoice, id: islr_snp_supplier_invoice, view: account.invoice_supplier_form}:
1559+ nro_ctrl: ISLR SUPPLIER INVOICE (SOCIETY OF NATURAL PERSONS)
1560+ supplier_invoice_number: ISLR SUPPLIER INVOICE (SOCIETY OF NATURAL PERSONS)
1561+ <<: *islr_supplier_ai
1562+-
1563+ I check that the invoice was correctly created.
1564+-
1565+ !assert {model: account.invoice, id: islr_snp_supplier_invoice, string: The invoice was not correctly created}:
1566+ - state == 'draft'
1567+ - type == 'in_invoice'
1568+-
1569+ I confirm the invoice to generate the withholding document.
1570+-
1571+ !workflow {model: account.invoice, action: invoice_open, ref: islr_snp_supplier_invoice}
1572+-
1573+ I check that the invoice is confirmed and it generate a draft withholding.
1574+-
1575+ !assert {model: account.invoice, id: islr_snp_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1576+ - state == 'open'
1577+ - islr_wh_doc_id
1578+ - islr_wh_doc_id.state == 'draft'
1579+-
1580+ I check that the rate used is the one for natural persons (in this case also is a resident person).
1581+-
1582+ !python {model: account.invoice}: |
1583+ inv_id = ref( 'islr_snp_supplier_invoice' )
1584+ iwd_brw = self.browse(cr, uid, inv_id).islr_wh_doc_id
1585+ correct_rate_id = ref ( 'islr_rates_002' )
1586+ assert iwd_brw.concept_ids[0].islr_rates_id.id == correct_rate_id
1587+-
1588+ I revert the changes on the supplier.
1589+-
1590+ !record {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1}:
1591+ spn: false
1592+-
1593+ I check that the supplier was correctly updated.
1594+-
1595+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier was not correctly updated }:
1596+ - not spn
1597+-
1598+ 2.13 I check that when the supplier is exempt it will create a withholding document with amount withheld 0.0 when the invoice base is greater that the withholding minimum.
1599+-
1600+ I set the supplier as an income exempt.
1601+-
1602+ !record {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1}:
1603+ islr_exempt: True
1604+-
1605+ I check that the supplier was correctly updated.
1606+-
1607+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier was not correctly updated }:
1608+ - islr_exempt
1609+-
1610+ I create a supplier invoice.
1611+-
1612+ !record {model: account.invoice, id: islr_exempt_supplier_invoice, view: account.invoice_supplier_form}:
1613+ nro_ctrl: ISLR SUPPLIER INVOICE (EXEMPT SUPPLIER)
1614+ supplier_invoice_number: ISLR SUPPLIER INVOICE (EXEMPT SUPPLIER)
1615+ <<: *islr_supplier_ai
1616+-
1617+ I check that the invoice was correctly created.
1618+-
1619+ !assert {model: account.invoice, id: islr_exempt_supplier_invoice, string: The invoice was not correctly created}:
1620+ - state == 'draft'
1621+ - type == 'in_invoice'
1622+-
1623+ I confirm the invoice to generate the withholding document.
1624+-
1625+ !workflow {model: account.invoice, action: invoice_open, ref: islr_exempt_supplier_invoice}
1626+-
1627+ I check that the invoice is confirmed and it generate a draft withholding document with 0.0 amount withheld.
1628+-
1629+ !assert {model: account.invoice, id: islr_exempt_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1630+ - state == 'open'
1631+ - islr_wh_doc_id
1632+ - islr_wh_doc_id.state == 'draft'
1633+ - islr_wh_doc_id.amount_total_ret == 0.0
1634+-
1635+ I revert the changes on the supplier.
1636+-
1637+ !record {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1}:
1638+ islr_exempt: False
1639+-
1640+ I check that the supplier was correctly updated.
1641+-
1642+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier was not correctly updated }:
1643+ - not islr_exempt
1644+-
1645+ 2.14 I check that when the supplier is exempt it will create a withholding document with amount withheld 0.0 when the invoice base is less than the withholding minimum.
1646+-
1647+ I set the supplier as an income exempt.
1648+-
1649+ !record {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1}:
1650+ islr_exempt: True
1651+-
1652+ I check that the supplier was correctly updated.
1653+-
1654+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier was not correctly updated }:
1655+ - islr_exempt
1656+-
1657+ I create a supplier invoice.
1658+-
1659+ !record {model: account.invoice, id: islr_min_exempt_supplier_invoice, view: account.invoice_supplier_form}:
1660+ nro_ctrl: ISLR SUPPLIER INVOICE (MINIMUN EXEMPT WITHHOLDING)
1661+ supplier_invoice_number: ISLR SUPPLIER INVOICE (MINIMUN EXEMPT WITHHOLDING)
1662+ invoice_line:
1663+ - quantity: 1
1664+ price_unit: 30
1665+ <<: *islr_supplier_wh_ail
1666+ <<: *islr_supplier_ai
1667+-
1668+ I check that the invoice was correctly created.
1669+-
1670+ !assert {model: account.invoice, id: islr_min_exempt_supplier_invoice, string: The invoice was not correctly created}:
1671+ - state == 'draft'
1672+ - type == 'in_invoice'
1673+-
1674+ I confirm the invoice to generate the withholding document.
1675+-
1676+ !workflow {model: account.invoice, action: invoice_open, ref: islr_min_exempt_supplier_invoice}
1677+-
1678+ I check that the invoice is confirmed and it generate a draft withholding document with 0.0 amount withheld.
1679+-
1680+ !assert {model: account.invoice, id: islr_min_exempt_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1681+ - state == 'open'
1682+ - islr_wh_doc_id
1683+ - islr_wh_doc_id.state == 'draft'
1684+ - islr_wh_doc_id.amount_total_ret == 0.0
1685+-
1686+ I check that the invoice base amount is less than the minimum withholding rate.
1687+-
1688+ !python {model: islr.wh.doc.invoices}: |
1689+ inv_id = ref( 'islr_min_exempt_supplier_invoice' )
1690+ inv_brw = self.pool.get( 'account.invoice' ).browse(cr, uid, inv_id)
1691+ iwd_brw = inv_brw.islr_wh_doc_id
1692+ concept_id = iwd_brw.concept_ids[0].concept_id.id
1693+ vendor, buyer, wh_agent = self._get_partners(
1694+ cr, uid, inv_brw)
1695+ residence = self._get_residence(cr, uid, vendor, buyer)
1696+ nature = self._get_nature(cr, uid, vendor)
1697+ rate_min = self._get_rate(
1698+ cr, uid, concept_id, residence, nature, context=context)[1]
1699+ assert rate_min > inv_brw.amount_untaxed, 'Its not correct.'
1700+-
1701+ I revert the changes on the supplier.
1702+-
1703+ !record {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1}:
1704+ islr_exempt: False
1705+-
1706+ I check that the supplier was correctly updated.
1707+-
1708+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier was not correctly updated }:
1709+ - not islr_exempt
1710+-
1711+ 2.15 I check when the company is not a income withholding agent then it should not generate a withholding document.
1712+-
1713+ I set the company as non-income withholding agent.
1714+-
1715+ !python {model: res.partner}: |
1716+ partner_id = ref( 'base.main_partner')
1717+ partner_brw = self.browse(cr, uid, partner_id)
1718+ self.write(cr, uid, partner_id, {'islr_withholding_agent': False})
1719+-
1720+ I check that the company is a non-income withholding agent.
1721+-
1722+ !assert {model: res.partner, id: base.main_partner, string: The company is a withholdable agent}:
1723+ - not islr_withholding_agent
1724+-
1725+ I create a supplier invoice.
1726+-
1727+ !record {model: account.invoice, id: islr_nwh_company_supplier_invoice, view: account.invoice_supplier_form}:
1728+ nro_ctrl: ISLR SUPPLIER INVOICE (NON-WH COMPANY)
1729+ supplier_invoice_number: ISLR SUPPLIER INVOICE ()
1730+ <<: *islr_supplier_ai
1731+-
1732+ I check that the invoice was correctly created.
1733+-
1734+ !assert {model: account.invoice, id: islr_nwh_company_supplier_invoice, string: The invoice was not correctly created}:
1735+ - state == 'draft'
1736+ - type == 'in_invoice'
1737+-
1738+ I confirm the invoice.
1739+-
1740+ !workflow {model: account.invoice, action: invoice_open, ref: islr_nwh_company_supplier_invoice}
1741+-
1742+ I check that the invoice is in open state and do not generate a withholding document.
1743+-
1744+ !assert {model: account.invoice, id: islr_nwh_company_supplier_invoice, string: The invoice is not correctly confirm.}:
1745+ - state == 'open'
1746+ - not islr_wh_doc_id
1747+-
1748+ 2.16 I check when the company is not a income withholding agent then it should not let generate a withholding document manually.
1749+-
1750+ I set the company as non-income withholding agent.
1751+-
1752+ !python {model: res.partner}: |
1753+ partner_id = ref( 'base.main_partner')
1754+ partner_brw = self.browse(cr, uid, partner_id)
1755+ self.write(cr, uid, partner_id, {'islr_withholding_agent': False})
1756+-
1757+ I check that the company is a non-income withholding agent.
1758+-
1759+ !assert {model: res.partner, id: base.main_partner, string: The company is a withholdable agent}:
1760+ - not islr_withholding_agent
1761+-
1762+ I try to create a supplier withholding document manually. It will not create the document.
1763+-
1764+ !python {model: islr.wh.doc}: |
1765+ values = {
1766+ 'name': 'ISLR MANUAL PURCHASE (NON-WH COMPANY)',
1767+ 'partner_id': ref( 'l10n_ve_fiscal_requirements.f_req_partner_1' ),
1768+ 'account_id': ref( 'account.a_pay' ),
1769+ 'company_id': ref( 'base.main_company' ),
1770+ 'currency_id': ref( 'base.EUR' ),
1771+ }
1772+ try:
1773+ create_flag = self.create(cr, uid, values)
1774+ except Exception as e:
1775+ create_flag = False
1776+ assert not create_flag, 'The supplier withholding document cant be created because the company is not a withholding agent.'
1777+-
1778+ I revert the changes
1779+-
1780+ !python {model: res.partner}: |
1781+ partner_id = ref( 'base.main_partner')
1782+ partner_brw = self.browse(cr, uid, partner_id)
1783+ self.write(cr, uid, partner_id, {'islr_withholding_agent': True})
1784+-
1785+ I check that the company is a income withholding agent.
1786+-
1787+ !assert {model: res.partner, id: base.main_partner, string: The company is not a withholdable agent}:
1788+ - islr_withholding_agent
1789+
1790+-
1791+ 2.17 I check that only Open invoices can be add to a withholding document created manually.
1792+-
1793+ I create a supplier withholding document manually.
1794+-
1795+ !record {model: islr.wh.doc, id: islr_open_state_supplier_wh_doc, view: l10n_ve_withholding_islr.view_wh_islr_form_suppliers}:
1796+ name: ISLR SUPPLIER WH DOC (INVOICE OPEN STATE)
1797+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
1798+ account_id: account.a_recv
1799+-
1800+ I unlink the auto-loaded invoices.
1801+-
1802+ !python {model: islr.wh.doc}: |
1803+ iwd_id = ref( 'islr_open_state_supplier_wh_doc' )
1804+ iwd_brw = self.browse(cr, uid, iwd_id)
1805+ iwdi_ids = [inv_line.id
1806+ for inv_line in iwd_brw.invoice_ids]
1807+ iwdi_ids and self.pool.get( 'islr.wh.doc.invoices' ).unlink(cr, uid, iwdi_ids)
1808+-
1809+ I check that the withholding document is withhout invoices.
1810+-
1811+ !assert {model: islr.wh.doc, id: islr_open_state_supplier_wh_doc, string: The withholding document should be without invoices.}:
1812+ - invoice_ids == []
1813+-
1814+ I create a supplier invoice.
1815+-
1816+ !record {model: account.invoice, id: islr_open_state_supplier_invoice, view: account.invoice_supplier_form}:
1817+ nro_ctrl: ISLR SUPPLIER INVOICE (INVOICE OPEN STATE)
1818+ supplier_invoice_number: ISLR SUPPLIER INVOICE (INVOICE OPEN STATE)
1819+ <<: *islr_supplier_ai
1820+-
1821+ I check that the invoice was correctly created.
1822+-
1823+ !assert {model: account.invoice, id: islr_open_state_supplier_invoice, string: The invoices was no correctly created}:
1824+ - state == 'draft'
1825+ - type == 'in_invoice'
1826+-
1827+ I try to add a draft invoice to the withholding document. It wont be added.
1828+-
1829+ !python {model: islr.wh.doc}: |
1830+ from openerp.osv import orm
1831+ iwd_id = ref( 'islr_open_state_supplier_wh_doc')
1832+ inv_id = ref( 'islr_open_state_supplier_invoice' )
1833+ flag = True
1834+ values= { 'invoice_ids' : [( 0, 0, {'invoice_id': inv_id })] }
1835+ try:
1836+ cr.execute('SAVEPOINT islr_open_state_supplier_wh_doc')
1837+ self.write(cr, uid, iwd_id, values)
1838+ cr.execute('RELEASE SAVEPOINT islr_open_state_supplier_wh_doc')
1839+ flag = False
1840+ except orm.except_orm:
1841+ cr.execute('ROLLBACK TO SAVEPOINT islr_open_state_supplier_wh_doc')
1842+ assert flag, 'This should not happen!!! It was expected an exception was raised'
1843+-
1844+ I check that the invoice was not added.
1845+-
1846+ !assert {model: islr.wh.doc, id: islr_open_state_supplier_wh_doc, string: The draft invoice was added and it should not.}:
1847+ - invoice_ids == []
1848+-
1849+ I confirm the invoice.
1850+-
1851+ !workflow {model: account.invoice, action: invoice_open, ref: islr_open_state_supplier_invoice}
1852+-
1853+ I check that the invoice is confirmed.
1854+-
1855+ !assert {model: account.invoice, id: islr_open_state_supplier_invoice, string: The invoices was no correctly confirm.}:
1856+ - state == 'open'
1857+-
1858+ I add the invoice to the withholding document.
1859+-
1860+ !record {model: islr.wh.doc, id: islr_open_state_supplier_wh_doc, view: l10n_ve_withholding_islr.view_wh_islr_form_suppliers}:
1861+ invoice_ids:
1862+ - invoice_id: islr_open_state_supplier_invoice
1863+-
1864+ I check that the invoice was added.
1865+-
1866+ !assert {model: islr.wh.doc, id: islr_open_state_supplier_wh_doc, string: The open invoice was not added and it should.}:
1867+ - invoice_ids[0].invoice_id.id == ref( 'islr_open_state_supplier_invoice' )
1868+-
1869+ 2.18 I check that a manually created withholding document can not be confirmed if it is withhout withholding lines.
1870+-
1871+ I create a withholding document manually.
1872+-
1873+ !record {model: islr.wh.doc, id: islr_no_lines_supplier_wh_doc}:
1874+ name: ISLR SUPPLIER WH DOC (NOT WH LINES)
1875+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
1876+ account_id: account.a_recv
1877+-
1878+ I unlink the auto-loaded invoices.
1879+-
1880+ !python {model: islr.wh.doc}: |
1881+ iwd_id = ref( 'islr_no_lines_supplier_wh_doc' )
1882+ iwd_brw = self.browse(cr, uid, iwd_id)
1883+ iwdi_ids = [inv_line.id
1884+ for inv_line in iwd_brw.invoice_ids]
1885+ iwdi_ids and self.pool.get( 'islr.wh.doc.invoices' ).unlink(cr, uid, iwdi_ids)
1886+-
1887+ I check that the withholding document is withhout invoices.
1888+-
1889+ !assert {model: islr.wh.doc, id: islr_no_lines_supplier_wh_doc, string: The withholding document should be without invoices}:
1890+ - invoice_ids == []
1891+-
1892+ I try to confirm the withholding document. It won't be confirm.
1893+-
1894+ !python {model: islr.wh.doc}: |
1895+ iwd_id = ref( 'islr_no_lines_supplier_wh_doc' )
1896+ # the workflow is not used because the exception can be manage
1897+ try:
1898+ check_flag = self.check_income_wh(cr, uid, iwd_id)
1899+ except Exception as e:
1900+ check_flag = False
1901+ assert not check_flag, 'The withholding can not be confirm'
1902+-
1903+ 2.19 I check that a manually supplier withholding document can be created and confirmed using the invoice release from another supplier withholding document.
1904+-
1905+ I create a supplier invoice
1906+-
1907+ !record {model: account.invoice, id: islr_manual_supplier_invoice, view: account.invoice_supplier_form}:
1908+ nro_ctrl: ISLR SUPPLIER INVOICE (MANUAL)
1909+ supplier_invoice_number: ISLR SUPPLIER INVOICE (MANUAL)
1910+ <<: *islr_supplier_ai
1911+-
1912+ I check that the invoice was correctly created.
1913+-
1914+ !assert {model: account.invoice, id: islr_manual_supplier_invoice, string: The invoices was no correctly created}:
1915+ - state == 'draft'
1916+ - type == 'in_invoice'
1917+-
1918+ I confirm the invoice to generate the withholding document.
1919+-
1920+ !workflow {model: account.invoice, action: invoice_open, ref: islr_manual_supplier_invoice}
1921+-
1922+ I check that the invoice is confirmed and it generate a draft withholding.
1923+-
1924+ !assert {model: account.invoice, id: islr_manual_supplier_invoice, string: The invoice was not confirmed or the withholding document was created wrong way.}:
1925+ - state == 'open'
1926+ - islr_wh_doc_id
1927+ - islr_wh_doc_id.state == 'draft'
1928+-
1929+ I cancel the automatic created withholding document.
1930+-
1931+ !python {model: account.invoice}: |
1932+ import netsvc
1933+ from openerp.osv import osv
1934+ inv_brw = self.browse(cr, uid, ref( 'islr_manual_supplier_invoice' ))
1935+ iwd_id = inv_brw.islr_wh_doc_id.id
1936+ wf_service = netsvc.LocalService( 'workflow' )
1937+ wf_service.trg_validate(uid, 'islr.wh.doc', iwd_id, 'act_cancel', cr)
1938+ iwd_obj = self.pool.get( 'islr.wh.doc' )
1939+ iwd_brw = iwd_obj.browse(cr, uid, iwd_id)
1940+ assert iwd_brw.state == 'cancel', 'It does not change the withholding state to cancel'
1941+-
1942+ I create a withholding document manually.
1943+-
1944+ !record {model: islr.wh.doc, id: islr_manual_supplier_wh_doc}:
1945+ name: ISLR SUPPLIER WH DOC (MANUAL)
1946+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
1947+ account_id: account.a_recv
1948+-
1949+ I unlink the auto-loaded invoices.
1950+-
1951+ !python {model: islr.wh.doc}: |
1952+ iwd_id = ref( 'islr_manual_supplier_wh_doc' )
1953+ iwd_brw = self.browse(cr, uid, iwd_id)
1954+ iwdi_ids = [inv_line.id
1955+ for inv_line in iwd_brw.invoice_ids]
1956+ iwdi_ids and self.pool.get( 'islr.wh.doc.invoices' ).unlink(cr, uid, iwdi_ids)
1957+-
1958+ I check that the withholding document is withhout invoices.
1959+-
1960+ !assert {model: islr.wh.doc, id: islr_manual_supplier_wh_doc, string: The withholding document should be without invoices}:
1961+ - invoice_ids == []
1962+-
1963+ I add the invoice to the withholding document.
1964+-
1965+ !record {model: islr.wh.doc, id: islr_manual_supplier_wh_doc, view: l10n_ve_withholding_islr.view_wh_islr_form_suppliers}:
1966+ invoice_ids:
1967+ - invoice_id: islr_manual_supplier_invoice
1968+-
1969+ I check that the invoices was correctly added.
1970+-
1971+ !assert {model: islr.wh.doc, id: islr_manual_supplier_wh_doc, string: The invoices was not correctly added.}:
1972+ - invoice_ids
1973+ - len(invoice_ids) == 1
1974+ - invoice_ids[0].invoice_id.id == ref( 'islr_manual_supplier_invoice' )
1975+-
1976+ I compute the taxes manually with the button 'Compute Icome Withholding'.
1977+-
1978+ !function {model: islr.wh.doc, name: compute_amount_wh, id: islr_manual_supplier_wh_doc}:
1979+ - model: islr.wh.doc
1980+ eval: "[ref('islr_manual_supplier_wh_doc')]"
1981+-
1982+ I confirm the withholding document.
1983+-
1984+ !python {model: islr.wh.doc}: |
1985+ iwd_id = ref( 'islr_manual_supplier_wh_doc' )
1986+ import netsvc
1987+ from openerp.osv import osv
1988+ wf_service = netsvc.LocalService( 'workflow' )
1989+ wf_service.trg_validate(uid, 'islr.wh.doc', iwd_id, 'act_confirm', cr)
1990+ iwd_obj = self.pool.get( 'islr.wh.doc' )
1991+ iwd_brw = iwd_obj.browse(cr, uid, iwd_id)
1992+ assert iwd_brw.state == 'confirmed', 'It does not change the withholding state to confirm. != %s' % (iwd_brw.state,)
1993
1994=== added file 'l10n_ve_withholding_islr/test/supplier_wh_islr_invoice.yml'
1995--- l10n_ve_withholding_islr/test/supplier_wh_islr_invoice.yml 1970-01-01 00:00:00 +0000
1996+++ l10n_ve_withholding_islr/test/supplier_wh_islr_invoice.yml 2014-01-08 15:40:54 +0000
1997@@ -0,0 +1,186 @@
1998+-
1999+ 1. I check the supplier income withholding when the company is a withholding agent. An invoice conditions will tell if or if not a withholding documenti will be created as the product of invoice confirmation. (Note. the supplier withhodable contidion do not matter in this test cases)
2000+-
2001+ 1.1 I configure the test enviroment and check data and demo.
2002+-
2003+ I set the context for the purchase operations at this set of cases.
2004+-
2005+ !context
2006+ 'type': 'in_invoice'
2007+-
2008+ I check that the company is a income withholding agent and is at Venezuela.
2009+-
2010+ !assert {model: res.partner, id: base.main_partner, string: The companu is a non-withholdable agent}:
2011+ - islr_withholding_agent
2012+ - country_id.code == 'VE'
2013+-
2014+ I check that only one non-withholdable concept is define.
2015+-
2016+ !python {model: islr.wh.concept}: |
2017+ iwc_ids = self.search(cr, uid, [( 'withholdable', '=', False )])
2018+ assert len(iwc_ids) == 1, ( 'Only can be defined one non-withhodeable'
2019+ ' concepts, but %s are defined.' % (len(iwc_ids), ))
2020+-
2021+ I check that all the withholdable concepts have accounts type 'other' associtated and also have mandatory income rates.
2022+-
2023+ !python {model: islr.wh.concept}: |
2024+ iwc_ids = self.search(cr, uid, [( 'withholdable', '=', True )])
2025+ for iwc_brw in self.browse(cr, uid, iwc_ids):
2026+ assert iwc_brw.rate_ids, 'All the withholdable concepts need to have rates associated'
2027+ assert iwc_brw.property_retencion_islr_payable, 'All the withholdable concepts need to have an income withholding purchase acc set.'
2028+ assert iwc_brw.property_retencion_islr_payable.type == 'other', 'All the withholdable concepts need to have an income withholding purchase acc of type other.'
2029+ assert iwc_brw.property_retencion_islr_receivable, 'All the withholdable concepts need to have an income withholding sale acc set.'
2030+ assert iwc_brw.property_retencion_islr_receivable.type == 'other', 'All the withholdable concepts need to have an income withholding sale acc of type other.'
2031+-
2032+ I check that the supplier that will be use exist and is correctly set for this test.
2033+-
2034+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier is not correctly set for this test.}:
2035+ - country_id.code == 'VE'
2036+ - vat
2037+-
2038+ I check that the concept that will be use is withhodable.
2039+-
2040+ !assert {model: islr.wh.concept, id: islr_wh_concept_hprof_no_mercantiles, string: The income concept is not withholdable}:
2041+ - withholdable
2042+-
2043+ I check that the product that will be use have the withholdable concept.
2044+-
2045+ !assert {model: product.product, id: product.product_product_4, string: Have not a concept.}:
2046+ - concept_id
2047+ - concept_id.id == ref( 'islr_wh_concept_hprof_no_mercantiles' )
2048+-
2049+ 1.2 I check that a withholding document is created when the invoice have a withholdable concept (at the invoice line product).
2050+-
2051+ I create a supplier invoice with a withholdable concept.
2052+-
2053+ !record {model: account.invoice, id: islr_withholdable_supplier_invoice, view: account.invoice_supplier_form}: &islr_supplier_ai
2054+ nro_ctrl: WITHHOLDABLE INCOME CONCEPT SUPPLIER INVOICE
2055+ supplier_invoice_number: WITHHOLDABLE INCOME CONCEPT SUPPLIER INVOICE
2056+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
2057+ account_id: account.a_pay
2058+ company_id: base.main_company
2059+ currency_id: base.EUR
2060+ reference_type: none
2061+ invoice_line: &islr_supplier_wh_ail
2062+ - product_id: product.product_product_4
2063+ quantity: 3
2064+ uos_id: product.product_uom_unit
2065+ price_unit: 30000
2066+ account_id: account.a_pay
2067+ #concept_id: already in product.
2068+-
2069+ I check that the invoice was correctly created.
2070+-
2071+ !assert {model: account.invoice, id: islr_withholdable_supplier_invoice, string: The invoice was not correctly created}:
2072+ - state == 'draft'
2073+ - type == 'in_invoice'
2074+ - len(invoice_line) == 1
2075+ - invoice_line[0].concept_id.id == ref( 'islr_wh_concept_hprof_no_mercantiles' )
2076+-
2077+ I confirm the invoice.
2078+-
2079+ !workflow {model: account.invoice, action: invoice_open, ref: islr_withholdable_supplier_invoice}
2080+-
2081+ I check that the invoice is confirmed and it genarate a draft income withholding.
2082+-
2083+ !assert {model: account.invoice, id: islr_withholdable_supplier_invoice, string: The invoice was not confirmed}:
2084+ - state == 'open'
2085+ - islr_wh_doc_id
2086+ - islr_wh_doc_id.state == 'draft'
2087+-
2088+ 1.3 I check that NOT withholding document will be created when the invoice have no concepts at all.
2089+-
2090+ I create a invoice with no income concepts lines.
2091+-
2092+ !record {model: account.invoice, id: islr_without_concepts_supplier_invoice, view: account.invoice_supplier_form}:
2093+ nro_ctrl: ISLR NON-WITHHOLDABLE SUPPLIER INVOICE
2094+ supplier_invoice_number: ISLR NON-WITHHOLDABLE SUPPLIER INVOICE
2095+ invoice_line: &islr_supplier_wowh_ail
2096+ - name: line without concepts.
2097+ quantity: 3
2098+ uos_id: product.product_uom_unit
2099+ price_unit: 30000
2100+ account_id: account.a_pay
2101+ <<: *islr_supplier_ai
2102+-
2103+ I check that the invoice was correctly created.
2104+-
2105+ !assert {model: account.invoice, id: islr_without_concepts_supplier_invoice, string: The invoice was not correctly created}:
2106+ - state == 'draft'
2107+ - type == 'in_invoice'
2108+ - not invoice_line[0].concept_id
2109+-
2110+ I confirm the invoice.
2111+-
2112+ !workflow {model: account.invoice, action: invoice_open, ref: islr_without_concepts_supplier_invoice}
2113+-
2114+ I check that the invoice is confirmed and it do not genarate a withholding document.
2115+-
2116+ !assert {model: account.invoice, id: islr_without_concepts_supplier_invoice, string: The invoice was not confirmed}:
2117+ - state == 'open'
2118+ - not islr_wh_doc_id
2119+-
2120+ 1.4 I check that NOT withholding document will be created when the invoice have non-withhodable concepts.
2121+-
2122+ I create an invoice.
2123+-
2124+ !record {model: account.invoice, id: islr_non_withholdable_concept_supplier_invoice, view: account.invoice_supplier_form}:
2125+ nro_ctrl: ISLR SUPPLIER INVOICE (NON_WITHHOLDABLE CONCEPT)
2126+ supplier_invoice_number: ISLR SUPPLIER INVOICE (NON_WITHHOLDABLE CONCEPT)
2127+ invoice_line: &islr_supplier_nwh_ail
2128+ - name: line with a non-withholdable concept.
2129+ quantity: 3
2130+ uos_id: product.product_uom_unit
2131+ price_unit: 30000
2132+ account_id: account.a_pay
2133+ concept_id: islr_wh_concept_no_apply_withholding
2134+ <<: *islr_supplier_ai
2135+-
2136+ I check that the invoice was correctly created.
2137+-
2138+ !assert {model: account.invoice, id: islr_non_withholdable_concept_supplier_invoice, string: The invoice was not correctly created}:
2139+ - state == 'draft'
2140+ - type == 'in_invoice'
2141+ - invoice_line[0].concept_id
2142+ - invoice_line[0].concept_id.withholdable == False
2143+-
2144+ I confirm the invoice.
2145+-
2146+ !workflow {model: account.invoice, action: invoice_open, ref: islr_non_withholdable_concept_supplier_invoice}
2147+-
2148+ I check that the invoice is confirmed and the income withholding was not generate.
2149+-
2150+ !assert {model: account.invoice, id: islr_non_withholdable_concept_supplier_invoice, string: The invoice was not correctly confirmed. It can not generate an income withholding document.}:
2151+ - state == 'open'
2152+ - not islr_wh_doc_id
2153+-
2154+ 1.5 I check that a withholding document is created when the invoice have at least one withholdable concept and the withholding line generated correspond to the withhodable concept.
2155+-
2156+ I create a supplier invoice with a withholdable concept and one not.
2157+-
2158+ !record {model: account.invoice, id: islr_hybrid_supplier_invoice, view: account.invoice_supplier_form}:
2159+ nro_ctrl: ISLR SUPPLIER INVOICE (WITHHOLDABLE AND ONE NOT WITHHOLDABLE)
2160+ supplier_invoice_number: ISLR SUPPLIER INVOICE (WITHHOLDABLE AND ONE NOT WITHHOLDABLE)
2161+ invoice_line:
2162+ - <<: *islr_supplier_wh_ail
2163+ - <<: *islr_supplier_nwh_ail
2164+ <<: *islr_supplier_ai
2165+-
2166+ I check that the invoice was correctly created.
2167+-
2168+ !assert {model: account.invoice, id: islr_hybrid_supplier_invoice, string: The invoice was not correctly created}:
2169+ - state == 'draft'
2170+ - type == 'in_invoice'
2171+-
2172+ I confirm the invoice.
2173+-
2174+ !workflow {model: account.invoice, action: invoice_open, ref: islr_hybrid_supplier_invoice}
2175+-
2176+ I check that the invoice is confirmed and it genarate a draft income withholding.
2177+-
2178+ !assert {model: account.invoice, id: islr_withholdable_supplier_invoice, string: The invoice was not confirmed}:
2179+ - state == 'open'
2180+ - islr_wh_doc_id
2181+ - islr_wh_doc_id.state == 'draft'
2182+ - len(islr_wh_doc_id.concept_ids) == 1
2183+ - islr_wh_doc_id.concept_ids[0].concept_id.id == ref( 'islr_wh_concept_hprof_no_mercantiles' )
2184
2185=== removed file 'l10n_ve_withholding_islr/test/test.yml'
2186--- l10n_ve_withholding_islr/test/test.yml 2013-03-01 17:47:29 +0000
2187+++ l10n_ve_withholding_islr/test/test.yml 1970-01-01 00:00:00 +0000
2188@@ -1,103 +0,0 @@
2189--
2190- 1. Test a purchase invoice
2191--
2192- 1.1 I update wh concept for adding journals
2193--
2194- !record {model: islr.wh.concept, id: islr_wh_concept_comisiones_venta_inmuebles}:
2195- property_retencion_islr_payable: islr_pay
2196- property_retencion_islr_receivable: islr_rec
2197--
2198- 1.2 I update company information so it become a wh agent
2199--
2200- !python {model: res.partner }: |
2201- vals = {
2202- 'islr_withholding_agent': True,
2203- 'vat':'VEJ346780983',
2204- 'type': "invoice",
2205- 'street': "Av Siempre Viva",
2206- 'phone': "(555) 5555555",
2207- 'fax': "(555) 1111111",
2208- 'email': "fakemail@example.com",
2209- 'country_id': 240
2210- }
2211- self.write(cr, uid, [ref('base.main_company')], vals)
2212--
2213- 1.3 I update partner
2214--
2215- !python {model: res.partner }: |
2216- vals = {
2217- 'supplier': True,
2218- 'customer': True,
2219- 'islr_withholding_agent': True,
2220- 'vat': 'VEJ783458904',
2221- }
2222- self.write(cr, uid, [ref('base.res_partner_23')], vals)
2223--
2224- 1.4 I create a purchase invoice
2225--
2226- !record {model: account.invoice, id: islr_inv01}:
2227- company_id: base.main_company
2228- currency_id: base.EUR
2229- date_invoice: !eval time.strftime('%Y-%m-%d')
2230- account_id: account.a_expense
2231- invoice_line:
2232- - product_id: product.product_product_3
2233- quantity: 5
2234- uos_id: product.product_uom_unit
2235- price_unit: 1000
2236- name: islrprod01
2237- account_id: account.a_expense
2238- concept_id: islr_wh_concept_demo2
2239- invoice_line_tax_id:
2240- - l10n_ve_fiscal_requirements.iva_purchase1
2241- - product_id: product.product_product_4
2242- quantity: 5
2243- uos_id: product.product_uom_unit
2244- price_unit: 2000
2245- name: islrprod02
2246- concept_id: islr_wh_concept_demo2
2247- account_id: account.a_expense
2248- invoice_line_tax_id:
2249- - l10n_ve_fiscal_requirements.iva_purchase1
2250- journal_id: account.expenses_journal
2251- partner_id: base.res_partner_23
2252- nro_ctrl: islr123
2253- reference: isrlref123
2254- type: in_invoice
2255--
2256- 1.5 I click on Calculate taxes button
2257--
2258- !python {model: account.invoice}: |
2259- acc_brw=self.browse(cr, uid, ref("islr_inv01"))
2260- self.button_reset_taxes(cr, uid, [ref("islr_inv01")])
2261--
2262- 1.6 I update check total before validating the invoice
2263--
2264- !record {model: account.invoice, id: islr_inv01}:
2265- check_total: 16800.0
2266--
2267- 1.7 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
2268--
2269- !workflow {model: account.invoice, action: invoice_proforma2, ref: islr_inv01}
2270--
2271- 1.8 I check that the invoice is in proforma2 state
2272--
2273- !assert {model: account.invoice, id: islr_inv01}:
2274- - state == "proforma2"
2275--
2276- 1.9 I create invoice by clicking on Create button
2277--
2278- !workflow {model: account.invoice, action: invoice_open, ref: islr_inv01}
2279--
2280- 1.10 I check that the invoice has any wh doc (must have)
2281--
2282- !assert {model: account.invoice, id: islr_inv01}:
2283- - islr_wh_doc_id.id
2284--
2285- 1.11 Search for the wh lines
2286--
2287- !python {model: account.invoice}: |
2288- from openerp import netsvc
2289- import time
2290- ai_brw = self.browse(cr, uid, ref("islr_inv01"))
2291- assert ai_brw.islr_wh_doc_id.amount_total_ret == 750.0, "Bad value for retention amount"
2292
2293=== removed file 'l10n_ve_withholding_islr/test/test_duplicate.yml'
2294--- l10n_ve_withholding_islr/test/test_duplicate.yml 2013-05-10 18:29:29 +0000
2295+++ l10n_ve_withholding_islr/test/test_duplicate.yml 1970-01-01 00:00:00 +0000
2296@@ -1,70 +0,0 @@
2297--
2298- 3 . Test duplacate invoice with withholding
2299--
2300- 3.1 Check if invoice was created in previous tests and has a wh document
2301--
2302- !assert {model: account.invoice, id: islr_inv01}:
2303- - id
2304- - islr_wh_doc_id.id
2305--
2306- 3.2 Duplicate the invoice from an open invoice
2307--
2308- !python {model: account.invoice}: |
2309- from openerp import netsvc
2310- default = {'islr_wh_doc_id': 0}
2311- context = {'lang': 'en_US',
2312- 'tz': False,
2313- 'uid': uid,
2314- 'journal_type': 'sale',
2315- 'default_type': 'out_invoice',
2316- 'type': 'out_invoice'}
2317- invoice_id = self.copy(cr, uid, ref("islr_inv01"), default=None, context=None)
2318- assert invoice_id, "Invoice was not duplicated (should)"
2319- self.write(cr, uid, [invoice_id],
2320- {'journal_id': ref("account.expenses_journal"),
2321- 'nro_ctrl':'DUPLINV00',
2322- 'supplier_invoice_number':'110011'})
2323- acc_brw=self.browse(cr, uid, invoice_id)
2324- self.button_reset_taxes(cr, uid, [invoice_id])
2325- # update check total
2326- self.write(cr, uid, [invoice_id],
2327- {'check_total': 16800.0})
2328- wf = netsvc.LocalService("workflow")
2329- wf.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr)
2330--
2331- 3 . Test duplacate invoice w/o taxes asociated
2332--
2333- 3.1 Check if invoice was created in previous tests and has a wh document
2334--
2335- !assert {model: account.invoice, id: islr_inv03}:
2336- - id
2337- - islr_wh_doc_id.id
2338--
2339- 3.2 Duplicate the invoice from an open invoice
2340--
2341- !python {model: account.invoice}: |
2342- from openerp import netsvc
2343- default = {'islr_wh_doc_id': 0}
2344- context = {'lang': 'en_US',
2345- 'tz': False,
2346- 'uid': uid,
2347- 'journal_type': 'purchase',
2348- 'default_type': 'out_invoice',
2349- 'type': 'out_invoice'}
2350- invoice_id = self.copy(cr, uid, ref("islr_inv03"), default=None, context=None)
2351- assert invoice_id, "Invoice was not duplicated (should)"
2352- self.write(cr, uid, [invoice_id],
2353- {'journal_id': ref("account.expenses_journal"),
2354- 'nro_ctrl':'DUPLINV00NOTAX',
2355- 'supplier_invoice_number':'110011NOTAX'})
2356- acc_brw=self.browse(cr, uid, invoice_id)
2357- self.button_reset_taxes(cr, uid, [invoice_id])
2358- # update check total
2359- self.write(cr, uid, [invoice_id],
2360- {'check_total': 16800.0})
2361- wf = netsvc.LocalService("workflow")
2362- wf.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr)
2363-
2364-
2365-
2366-
2367
2368=== removed file 'l10n_ve_withholding_islr/test/test_notax.yml'
2369--- l10n_ve_withholding_islr/test/test_notax.yml 2013-03-01 17:47:29 +0000
2370+++ l10n_ve_withholding_islr/test/test_notax.yml 1970-01-01 00:00:00 +0000
2371@@ -1,62 +0,0 @@
2372--
2373- 4. Test a purchase invoice w/o taxes in invoice lines
2374--
2375- 4.1 I create a purchase invoice
2376--
2377- !record {model: account.invoice, id: islr_inv03}:
2378- company_id: base.main_company
2379- currency_id: base.EUR
2380- date_invoice: !eval time.strftime('%Y-%m-%d')
2381- account_id: account.a_expense
2382- invoice_line:
2383- - product_id: product.product_product_3
2384- quantity: 5
2385- uos_id: product.product_uom_unit
2386- price_unit: 1000
2387- name: islrprod01_notax
2388- account_id: account.a_expense
2389- concept_id: islr_wh_concept_demo2
2390- - product_id: product.product_product_4
2391- quantity: 5
2392- uos_id: product.product_uom_unit
2393- price_unit: 2000
2394- name: islrprod02_notax
2395- concept_id: islr_wh_concept_demo2
2396- account_id: account.a_expense
2397- journal_id: account.expenses_journal
2398- partner_id: l10n_ve_fiscal_requirements.f_req_partner_10
2399- nro_ctrl: islr123NOTAX
2400- reference: isrlref123NOTAX
2401- type: in_invoice
2402--
2403- 4.2 I click on Calculate taxes button
2404--
2405- !python {model: account.invoice}: |
2406- acc_brw=self.browse(cr, uid, ref("islr_inv03"))
2407- self.button_reset_taxes(cr, uid, [ref("islr_inv03")])
2408--
2409- 4.3 I update check total before validating the invoice
2410--
2411- !record {model: account.invoice, id: islr_inv03}:
2412- check_total: 16800.0
2413--
2414- 4.4 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
2415--
2416- !workflow {model: account.invoice, action: invoice_proforma2, ref: islr_inv03}
2417--
2418- 4.5 I create invoice by clicking on Create button
2419--
2420- !workflow {model: account.invoice, action: invoice_open, ref: islr_inv03}
2421--
2422- 4.6 I check that the invoice has any wh doc (must have)
2423--
2424- !assert {model: account.invoice, id: islr_inv03}:
2425- - islr_wh_doc_id.id
2426--
2427- 4.7 Search for the wh lines
2428--
2429- !python {model: account.invoice}: |
2430- from openerp import netsvc
2431- import time
2432- ai_brw = self.browse(cr, uid, ref("islr_inv03"))
2433- assert ai_brw.islr_wh_doc_id.amount_total_ret == 222.3, "Bad value for retention amount"
2434
2435=== removed file 'l10n_ve_withholding_islr/test/test_sale.yml'
2436--- l10n_ve_withholding_islr/test/test_sale.yml 2013-03-01 17:47:29 +0000
2437+++ l10n_ve_withholding_islr/test/test_sale.yml 1970-01-01 00:00:00 +0000
2438@@ -1,89 +0,0 @@
2439--
2440- 2. Test a sale invoice
2441--
2442- 2.1 I create a sale invoice
2443--
2444- !record {model: account.invoice, id: islr_inv02}:
2445- company_id: base.main_company
2446- currency_id: base.EUR
2447- date_invoice: !eval time.strftime('%Y-%m-%d')
2448- account_id: account.a_recv
2449- invoice_line:
2450- - product_id: product.product_product_3
2451- quantity: 5
2452- uos_id: product.product_uom_unit
2453- price_unit: 1000
2454- name: islrprod01
2455- account_id: account.a_sale
2456- concept_id: islr_wh_concept_demo2
2457- invoice_line_tax_id:
2458- - l10n_ve_fiscal_requirements.iva_sale1
2459- - product_id: product.product_product_4
2460- quantity: 5
2461- uos_id: product.product_uom_unit
2462- price_unit: 2000
2463- name: islrprod02
2464- concept_id: islr_wh_concept_demo2
2465- account_id: account.a_sale
2466- invoice_line_tax_id:
2467- - l10n_ve_fiscal_requirements.iva_sale1
2468- journal_id: account.sales_journal
2469- partner_id: base.res_partner_23
2470- nro_ctrl: islr456
2471- reference: isrlref456
2472- type: out_invoice
2473--
2474- 2.2 I click on Calculate taxes button
2475--
2476- !python {model: account.invoice}: |
2477- acc_brw=self.browse(cr, uid, ref("islr_inv02"))
2478- self.button_reset_taxes(cr, uid, [ref("islr_inv02")])
2479--
2480- 2.3 I update check total before validating the invoice
2481--
2482- !record {model: account.invoice, id: islr_inv02}:
2483- check_total: 16800.0
2484--
2485- 2.4 I create invoice by clicking on Create button
2486--
2487- !workflow {model: account.invoice, action: invoice_open, ref: islr_inv02}
2488--
2489- 2.5 I create wh document
2490--
2491- !python {model: islr.wh.doc}: |
2492- vals = self.onchange_partner_id(cr, uid, [], 'out_invoice', ref('base.res_partner_23'))
2493- vals.update(
2494- { 'journal_id': ref('withholding_sale_journal'),
2495- 'name': 'test islr sale',
2496- 'currency_id': 1,
2497- 'company_id': ref('base.main_company'),
2498- 'account_id':ref('withholding_sale_journal'),
2499- 'user_id':1,
2500- 'partner_id': ref('base.res_partner_23'),
2501- 'type': 'out_invoice',
2502- })
2503- res = self.create(cr, uid, vals)
2504- assert res, "Wh documents was not created"
2505- ai_obj = self.pool.get('account.invoice')
2506- ai_obj.write(cr, uid, [ref('islr_inv02')], {'islr_wh_doc_id': res})
2507--
2508- 2.6 check if wh document was asociated wth the invoice (it must be))
2509--
2510- !assert {model: account.invoice, id: islr_inv02}:
2511- - islr_wh_doc_id.id
2512--
2513- 2.7 I create validate wh document clicking the Progress button
2514--
2515- !python {model: account.invoice}: |
2516- from openerp import netsvc
2517- ai_brw = self.browse(cr, uid, ref('islr_inv02'))
2518- wf = netsvc.LocalService("workflow")
2519- wf.trg_validate(uid, 'islr.wh.doc', ai_brw.islr_wh_doc_id.id, 'act_progress', cr)
2520--
2521- 2.8 Search for the wh lines
2522--
2523- !python {model: account.invoice}: |
2524- from openerp import netsvc
2525- import time
2526- ai_brw = self.browse(cr, uid, ref("islr_inv02"))
2527- assert ai_brw.islr_wh_doc_id.amount_total_ret == 750.0, "Bad value for retention amount"
2528
2529=== modified file 'l10n_ve_withholding_islr/view/islr_wh_doc_view.xml'
2530--- l10n_ve_withholding_islr/view/islr_wh_doc_view.xml 2013-12-18 21:31:14 +0000
2531+++ l10n_ve_withholding_islr/view/islr_wh_doc_view.xml 2014-01-08 15:40:54 +0000
2532@@ -110,7 +110,10 @@
2533 <field name="journal_id" domain="[('type','=','islr_sale')]"/>
2534 <field name="type"/>
2535 <field name="code"/>
2536- <field name="partner_id" on_change="onchange_partner_id(type,partner_id)" domain="[('islr_withholding_agent','=',True), ('customer','=',True)]"/>
2537+ <field
2538+ name="partner_id"
2539+ on_change="onchange_partner_id(type,partner_id)"
2540+ domain="[('islr_withholding_agent','=',True),('customer','=',True),('parent_id','=',False)]"/>
2541 <field name="currency_id" readonly="1"/>
2542 <field name="date_ret"/>
2543 <field name="account_id" domain="[('type','=', type in ('in_invoice','in_refund') and 'payable' or 'receivable'), ('company_id', '=', company_id)]"/>
2544@@ -239,7 +242,10 @@
2545 <field name="journal_id" domain="[('type','=','islr_purchase')]"/>
2546 <field name="type"/>
2547 <field name="code"/>
2548- <field name="partner_id" on_change="onchange_partner_id(type,partner_id)" domain="[('supplier','=',True)]"/>
2549+ <field
2550+ name="partner_id"
2551+ on_change="onchange_partner_id(type,partner_id)"
2552+ domain="[('supplier','=',True),('parent_id','=',False)]"/>
2553 <field name="currency_id" readonly="1"/>
2554 <field name="date_ret"/>
2555 <field name="account_id" domain="[('type','=', type in ('in_invoice','in_refund') and 'payable' or 'receivable'), ('company_id', '=', company_id)]"/>
2556@@ -283,7 +289,12 @@
2557 </field>
2558 </page>
2559 <page string="Invoices" invisible="1">
2560- <field domain="[('partner_id','=',partner_id),('status','=','no_pro'),('state','in',['open','paid']),('type','in',['in_invoice','in_refund'])]" colspan="6" name="islr_wh_doc_id" nolabel="1" widget="many2many"/>
2561+ <field
2562+ name="islr_wh_doc_id"
2563+ domain="[('partner_id','=',partner_id),('status','=','no_pro'),('state','in',['open','paid']),('type','in',['in_invoice','in_refund'])]"
2564+ colspan="6"
2565+ nolabel="1"
2566+ widget="many2many"/>
2567 </page>
2568 <page string="Income Withholding Concepts">
2569 <field colspan="6" name="concept_ids" nolabel="1" readonly="1">
2570
2571=== modified file 'l10n_ve_withholding_islr/view/islr_xml_wh.xml'
2572--- l10n_ve_withholding_islr/view/islr_xml_wh.xml 2013-05-23 04:34:03 +0000
2573+++ l10n_ve_withholding_islr/view/islr_xml_wh.xml 2014-01-08 15:40:54 +0000
2574@@ -17,7 +17,11 @@
2575 <separator string="Supplier to Withhold" colspan="6"/>
2576 <newline/>
2577 <group col="4" colspan="4">
2578- <field name="partner_id" colspan="4" on_change="onchange_partner_vat(partner_id)"/>
2579+ <field
2580+ name="partner_id"
2581+ domain="[('parent_id','=',False)]"
2582+ colspan="4"
2583+ on_change="onchange_partner_vat(partner_id)"/>
2584 <field name="partner_vat"/>
2585 </group>
2586 <newline/>
2587@@ -74,7 +78,7 @@
2588 <field name="xml_ids" nolabel="1" colspan="4" widget="many2many" domain="[('period_id','=',period_id), ('islr_xml_wh_doc','=',False)]">
2589 <tree string="Detail of the XML">
2590 <field name="partner_vat"/>
2591- <field name="partner_id"/>
2592+ <field name="partner_id" domain="[('parent_id','=',False)]"/>
2593 <field name="invoice_number"/>
2594 <field name="concept_code"/>
2595 <field name="base"/>
2596@@ -153,4 +157,4 @@
2597 <menuitem name="Generate file XML" id="menu_action_xml_islr" parent="l10n_ve_fiscal_requirements.menu_venezuela_reporting" action="action_xml_islr"/>
2598
2599 </data>
2600-</openerp>
2601\ No newline at end of file
2602+</openerp>
2603
2604=== modified file 'l10n_ve_withholding_iva/__openerp__.py'
2605--- l10n_ve_withholding_iva/__openerp__.py 2013-12-06 15:57:10 +0000
2606+++ l10n_ve_withholding_iva/__openerp__.py 2014-01-08 15:40:54 +0000
2607@@ -73,26 +73,13 @@
2608 ],
2609
2610 'test': [
2611-# 'test/iva_purchase.yml',
2612-# 'test/iva_purchase_wh.yml',
2613-# 'test/iva_purchase_nret1.yml',
2614-# 'test/iva_purchase_nret2.yml',
2615-# 'test/iva_purchase_nret3.yml',
2616-# 'test/iva_sale.yml',
2617-# 'test/iva_sale_wh.yml',
2618-# 'test/iva_test_invoice.yml',
2619-# 'test/iva_test_wh.yml',
2620-# 'test/iva_test_wh_2.yml',
2621-# 'test/iva_test_wh_3.yml',
2622-# 'test/iva_test_wh_4.yml',
2623-
2624-
2625 'test/purchase_invoice_wh_iva.yml',
2626 'test/sale_invoice_wh_iva.yml',
2627 'test/sale_wh_iva.yml',
2628 'test/purchase_wh_iva.yml',
2629 'test/purchase_wh_iva_sequence.yml',
2630- 'test/sale_wh_iva_sequence.yml'
2631+ 'test/sale_wh_iva_sequence.yml',
2632+ 'test/purchase_wh_iva_txt.yml',
2633 ],
2634 'installable': True,
2635 'active': False,
2636
2637=== modified file 'l10n_ve_withholding_iva/model/generate_txt.py'
2638--- l10n_ve_withholding_iva/model/generate_txt.py 2013-12-09 20:58:35 +0000
2639+++ l10n_ve_withholding_iva/model/generate_txt.py 2014-01-08 15:40:54 +0000
2640@@ -142,6 +142,7 @@
2641 """ Current lines are cleaned and rebuilt
2642 """
2643 context = context or {}
2644+ rp_obj = self.pool.get('res.partner')
2645 voucher_obj = self.pool.get('account.wh.iva')
2646 txt_iva_obj = self.pool.get('txt.iva.line')
2647 voucher_ids=''
2648@@ -156,14 +157,14 @@
2649 voucher_ids = voucher_obj.search(cr,uid,[('date_ret','>=',txt_brw.date_start),('date_ret','<=',txt_brw.date_end),('period_id','=',txt_brw.period_id.id),('state','=','done'),('type','in',['out_invoice','out_refund'])])
2650
2651 for voucher in voucher_obj.browse(cr,uid,voucher_ids):
2652-
2653+ acc_part_id = rp_obj._find_accounting_partner(voucher.partner_id)
2654 for voucher_lines in voucher.wh_lines:
2655
2656 if voucher_lines.invoice_id.state not in ['open','paid']:
2657 continue
2658 for voucher_tax_line in voucher_lines.tax_line:
2659 txt_iva_obj.create(cr,uid,
2660- {'partner_id':voucher.partner_id.id,
2661+ {'partner_id':acc_part_id.id,
2662 'voucher_id':voucher.id,
2663 'invoice_id':voucher_lines.invoice_id.id,
2664 'txt_id': txt_brw.id,
2665@@ -258,12 +259,15 @@
2666 @param txt: current txt document
2667 @param txt_line: One line of the current txt document
2668 """
2669+ rp_obj = self.pool.get('res.partner')
2670+ vat_company = rp_obj._find_accounting_partner(txt.company_id.partner_id).vat[2:]
2671+ vat_partner = rp_obj._find_accounting_partner(txt_line.partner_id).vat[2:]
2672 if txt_line.invoice_id.type in ['out_invoice','out_refund']:
2673- vendor = txt.company_id.partner_id.vat[2:]
2674- buyer = txt_line.partner_id.vat[2:]
2675+ vendor = vat_company
2676+ buyer = vat_partner
2677 else:
2678- buyer = txt.company_id.partner_id.vat[2:]
2679- vendor = txt_line.partner_id.vat[2:]
2680+ buyer = vat_company
2681+ vendor = vat_partner
2682 return (vendor,buyer)
2683
2684 def get_max_aliquot(self, cr, uid, txt_line):
2685@@ -294,8 +298,9 @@
2686 """
2687 context = context or {}
2688 txt_string = ''
2689+ rp_obj = self.pool.get('res.partner')
2690 for txt in self.browse(cr,uid,ids,context):
2691- vat = txt.company_id.partner_id.vat[2:]
2692+ vat = rp_obj._find_accounting_partner(txt.company_id.partner_id).vat[2:]
2693 for txt_line in txt.txt_ids:
2694
2695 vendor,buyer=self.get_buyer_vendor(cr,uid,txt,txt_line)
2696
2697=== modified file 'l10n_ve_withholding_iva/model/invoice.py'
2698--- l10n_ve_withholding_iva/model/invoice.py 2013-12-06 22:36:33 +0000
2699+++ l10n_ve_withholding_iva/model/invoice.py 2014-01-08 15:40:54 +0000
2700@@ -166,18 +166,16 @@
2701 """
2702 context = context or {}
2703 wil_obj = self.pool.get('account.wh.iva.line')
2704+ rp_obj = self.pool.get('res.partner')
2705 inv_brw = self.browse(cr, uid, ids, context=context)
2706 wh_iva_rate = inv_brw.type in ('in_invoice', 'in_refund') \
2707- and inv_brw.partner_id.wh_iva_rate \
2708- or inv_brw.type in ('out_invoice', 'out_refund') \
2709- and inv_brw.company_id.partner_id.wh_iva_rate
2710+ and rp_obj._find_accounting_partner(inv_brw.partner_id).wh_iva_rate \
2711+ or rp_obj._find_accounting_partner(inv_brw.company_id.partner_id).wh_iva_rate
2712 values = {'name': inv_brw.name or inv_brw.number,
2713 'invoice_id': inv_brw.id,
2714 'wh_iva_rate': wh_iva_rate }
2715 return wil_obj.create(cr, uid, values, context=context)
2716
2717-
2718-
2719 def action_wh_iva_supervisor(self, cr, uid, ids, context=None):
2720 """ Validate the currencys are equal
2721 """
2722@@ -195,7 +193,6 @@
2723 raise osv.except_osv('Invalid Action !', _('The currency of the invoice does not match with the currency of the company. Check this please'))
2724 return True
2725
2726-
2727 def action_wh_iva_create(self, cr, uid, ids, context=None):
2728 """ Create withholding objects """
2729 context = context or {}
2730@@ -242,14 +239,17 @@
2731 ids = isinstance(ids, (int, long)) and [ids] or ids
2732 wh_iva_obj = self.pool.get('account.wh.iva')
2733 per_obj = self.pool.get('account.period')
2734+ rp_obj = self.pool.get('res.partner')
2735 for inv_brw in self.browse(cr, uid, ids, context=context):
2736+ acc_part_id = rp_obj._find_accounting_partner(inv_brw.partner_id)
2737 inv_period, inv_fortnight = per_obj.find_fortnight(
2738 cr, uid, inv_brw.date_invoice, context=context)
2739 ttype = inv_brw.type in ["out_invoice", "out_refund"] \
2740 and "out_invoice" or "in_invoice"
2741 acc_wh_ids = wh_iva_obj.search(
2742- cr, uid, [('state', '=', 'draft'), ('type', '=', ttype),
2743- ('partner_id', '=', inv_brw.partner_id.id),
2744+ cr, uid, [('state', '=', 'draft'), ('type', '=', ttype), '|',
2745+ ('partner_id', '=', acc_part_id.id),
2746+ ('partner_id', 'child_of', acc_part_id.id),
2747 ('period_id', '=', inv_period),
2748 ('fortnight','=', str(inv_fortnight))], context=context)
2749 res.append(acc_wh_ids)
2750@@ -262,14 +262,16 @@
2751 context = context or {}
2752 wh_iva_obj = self.pool.get('account.wh.iva')
2753 per_obj = self.pool.get('account.period')
2754+ rp_obj = self.pool.get('res.partner')
2755 ids = isinstance(ids, (int, long)) and [ids] or ids
2756 res = list()
2757 for inv_brw in self.browse(cr, uid, ids, context=context):
2758+ acc_part_id = rp_obj._find_accounting_partner(inv_brw.partner_id)
2759 if inv_brw.type in ('out_invoice', 'out_refund'):
2760- acc_id = inv_brw.partner_id.property_account_receivable.id
2761+ acc_id = acc_part_id.property_account_receivable.id
2762 wh_type = 'out_invoice'
2763 else:
2764- acc_id = inv_brw.partner_id.property_account_payable.id
2765+ acc_id = acc_part_id.property_account_payable.id
2766 wh_type = 'in_invoice'
2767 if not acc_id:
2768 raise osv.except_osv('Invalid Action !',\
2769@@ -279,7 +281,7 @@
2770 'name':_('ORIGIN %s'%(inv_brw.number)),
2771 'type': wh_type,
2772 'account_id': acc_id,
2773- 'partner_id': inv_brw.partner_id.id,
2774+ 'partner_id': acc_part_id.id,
2775 'period_id': inv_brw.period_id.id,
2776 'wh_lines': [(4, ret_line_id)],
2777 'fortnight': str(per_obj.find_fortnight(
2778@@ -319,10 +321,9 @@
2779 if context is None:
2780 context={}
2781 obj = self.browse(cr, uid, ids[0],context=context)
2782- #No create withholding vat for customer invoice
2783-# if obj.type in ('out_invoice', 'out_refund') and obj.partner_id.wh_iva_agent:
2784-# return True
2785- if obj.type in ('in_invoice', 'in_refund') and obj.company_id.partner_id.wh_iva_agent:
2786+ #No VAT withholding Documents are created for customer invoice & refunds
2787+ if obj.type in ('in_invoice', 'in_refund') and \
2788+ self.pool.get('res.partner')._find_accounting_partner(obj.company_id.partner_id).wh_iva_agent:
2789 return True
2790 return False
2791
2792@@ -389,6 +390,7 @@
2793 name, context=context)
2794 if context.get('vat_wh',False):
2795 invoice = self.browse(cr, uid, ids[0])
2796+ acc_part_id = self.pool.get('res.partner')._find_accounting_partner(invoice.partner_id)
2797
2798 types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
2799 direction = types[invoice.type]
2800@@ -404,7 +406,7 @@
2801 'debit': direction * tax_brw.amount_ret<0 and - direction * tax_brw.amount_ret,
2802 'credit': direction * tax_brw.amount_ret>0 and direction * tax_brw.amount_ret,
2803 'account_id': acc,
2804- 'partner_id': invoice.partner_id.id,
2805+ 'partner_id': acc_part_id.id,
2806 'ref':invoice.number,
2807 'date': date,
2808 'currency_id': False,
2809@@ -464,13 +466,15 @@
2810 context = context or {}
2811 res = {}
2812 inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context)
2813+ rp_obj = self.pool.get('res.partner')
2814+ acc_part_id = inv.type in ['out_invoice', "out_refund"] and \
2815+ rp_obj._find_accounting_partner(inv.company_id.partner_id) or \
2816+ rp_obj._find_accounting_partner(inv.partner_id)
2817+ wh_iva_rate = acc_part_id.wh_iva_rate
2818
2819 for ait in inv.tax_line:
2820 amount_ret = 0.0
2821 if ait.tax_id.ret:
2822- wh_iva_rate = inv.type in ['out_invoice', "out_reunf"] \
2823- and inv.company_id.partner_id.wh_iva_rate \
2824- or inv.partner_id.wh_iva_rate
2825 amount_ret = wh_iva_rate and ait.tax_amount*wh_iva_rate/100.0 or 0.00
2826 res[ait.id] = {'amount_ret': amount_ret, 'base_ret': ait.base_amount}
2827 return res
2828
2829=== modified file 'l10n_ve_withholding_iva/model/wh_iva.py'
2830--- l10n_ve_withholding_iva/model/wh_iva.py 2013-12-17 16:40:51 +0000
2831+++ l10n_ve_withholding_iva/model/wh_iva.py 2014-01-08 15:40:54 +0000
2832@@ -92,6 +92,8 @@
2833 @param tax_id_brw: tax object
2834 """
2835 if context is None: context = {}
2836+ rp_obj = self.pool.get('res.partner')
2837+ acc_part_id = rp_obj._find_accounting_partner(tax_id_brw.invoice_id.partner_id)
2838 return {
2839 'inv_tax_id':tax_id_brw.id,
2840 'tax_id':tax_id_brw.tax_id.id,
2841@@ -99,7 +101,7 @@
2842 'base':tax_id_brw.base,
2843 'amount':tax_id_brw.amount,
2844 'company_id':tax_id_brw.company_id.id,
2845- 'wh_iva_rate':tax_id_brw.invoice_id.partner_id.wh_iva_rate
2846+ 'wh_iva_rate':acc_part_id.wh_iva_rate
2847 }
2848
2849 def load_taxes(self, cr, uid, ids, context=None):
2850@@ -107,13 +109,14 @@
2851 """
2852 if context is None: context = {}
2853 awilt_obj = self.pool.get('account.wh.iva.line.tax')
2854+ rp_obj = self.pool.get('res.partner')
2855
2856 for ret_line in self.browse(cr, uid, ids, context):
2857 lines = []
2858 if ret_line.invoice_id:
2859- rate = \
2860- ret_line.retention_id.type == 'out_invoice' and ret_line.invoice_id.company_id.partner_id.wh_iva_rate or \
2861- ret_line.retention_id.type == 'in_invoice' and ret_line.invoice_id.partner_id.wh_iva_rate
2862+ rate = ret_line.retention_id.type == 'out_invoice' \
2863+ and rp_obj._find_accounting_partner(ret_line.invoice_id.company_id.partner_id).wh_iva_rate \
2864+ or rp_obj._find_accounting_partner(ret_line.invoice_id.partner_id).wh_iva_rate
2865 self.write(cr, uid, ret_line.id, {'wh_iva_rate': rate})
2866 tax_lines = awilt_obj.search(cr, uid, [('wh_vat_line_id', '=', ret_line.id)])
2867 if tax_lines:
2868@@ -411,13 +414,12 @@
2869 def _check_partner(self, cr, uid, ids, context={}):
2870 """ Determine if a given partner is a VAT Withholding Agent
2871 """
2872- agt = False
2873 obj = self.browse(cr, uid, ids[0])
2874- if obj.type in ('out_invoice', 'out_refund') and obj.partner_id.wh_iva_agent:
2875- agt = True
2876- if obj.type in ('in_invoice', 'in_refund') and obj.company_id.partner_id.wh_iva_agent:
2877- agt = True
2878- return agt
2879+ rp_obj = self.pool.get('res.partner')
2880+ if obj.type in ('out_invoice', 'out_refund'):
2881+ return rp_obj._find_accounting_partner(obj.partner_id).wh_iva_agent
2882+ else:
2883+ return rp_obj._find_accounting_partner(obj.company_id.partner_id).wh_iva_agent
2884
2885 _constraints = [
2886 (_check_partner, 'Error ! The partner must be withholding vat agent .', ['partner_id']),
2887@@ -572,27 +574,34 @@
2888
2889 acc_id = False
2890 res = {}
2891+ rp_obj = self.pool.get('res.partner')
2892 inv_obj = self.pool.get('account.invoice')
2893
2894 if partner_id:
2895- p = self.pool.get('res.partner').browse(cr, uid, partner_id)
2896+ acc_part_id = rp_obj._find_accounting_partner(rp_obj.browse(cr, uid, partner_id))
2897 if type in ('out_invoice', 'out_refund'):
2898- acc_id = p.property_account_receivable and p.property_account_receivable.id or False
2899+ acc_id = acc_part_id.property_account_receivable and acc_part_id.property_account_receivable.id or False
2900 else:
2901- acc_id = p.property_account_payable and p.property_account_payable.id or False
2902+ acc_id = acc_part_id.property_account_payable and acc_part_id.property_account_payable.id or False
2903
2904 wh_line_obj = self.pool.get('account.wh.iva.line')
2905 wh_lines = ids and wh_line_obj.search(cr, uid, [('retention_id', '=', ids[0])]) or False
2906 res_wh_lines = []
2907 if wh_lines:
2908 wh_line_obj.unlink(cr, uid, wh_lines)
2909+
2910+ if not partner_id:
2911+ return {'value': res}
2912
2913 ttype = type in ['out_invoice'] and ['out_invoice', 'out_refund'] \
2914 or ['in_invoice', 'in_refund']
2915 inv_ids = inv_obj.search(cr,uid,[('state', '=', 'open'),
2916 ('wh_iva', '=', False),
2917 ('type', 'in', ttype),
2918- ('partner_id','=',partner_id)],context=context)
2919+ '|',
2920+ ('partner_id', '=', acc_part_id.id),
2921+ ('partner_id', 'child_of', acc_part_id.id),
2922+ ],context=context)
2923
2924 if inv_ids:
2925 #~ Get only the invoices which are not in a document yet
2926@@ -603,7 +612,7 @@
2927 res_wh_lines = [{
2928 'invoice_id': inv_brw.id,
2929 'name': inv_brw.name or _('N/A'),
2930- 'wh_iva_rate': inv_brw.partner_id.wh_iva_rate,
2931+ 'wh_iva_rate': rp_obj._find_accounting_partner(inv_brw.partner_id).wh_iva_rate,
2932 } for inv_brw in inv_obj.browse(cr,uid,inv_ids,context=context)]
2933
2934 res = {'value': {
2935@@ -642,21 +651,21 @@
2936 @param period_id: period_id at current view
2937 @param fortnight: fortnight at current view
2938 """
2939- #~ print '\n\n\n\n', 'onchange_lines_filter(', type, partner_id or 'no partner', period_id or 'no period', (isinstance(fortnight, (str)) and fortnight == 'False' and '1ra Fn' or '2da Fn') or 'EMPTY', ')'
2940 context = context or {}
2941 ai_obj = self.pool.get('account.invoice')
2942 per_obj = self.pool.get('account.period')
2943+ rp_obj = self.pool.get('res.partner')
2944 values_data = dict()
2945 res_wh_lines = []
2946 acc_id = False
2947
2948 #~ pull account info
2949 if partner_id:
2950- p = self.pool.get('res.partner').browse(cr, uid, partner_id)
2951+ acc_part_id = rp_obj._find_accounting_partner(rp_obj.browse(cr, uid, partner_id))
2952 if type in ('out_invoice', 'out_refund'):
2953- acc_id = p.property_account_receivable and p.property_account_receivable.id or False
2954+ acc_id = acc_part_id.property_account_receivable and acc_part_id.property_account_receivable.id or False
2955 else:
2956- acc_id = p.property_account_payable and p.property_account_payable.id or False
2957+ acc_id = acc_part_id.property_account_payable and acc_part_id.property_account_payable.id or False
2958 values_data['account_id'] = acc_id
2959
2960 #~ clear lines
2961@@ -672,7 +681,10 @@
2962 ai_ids = ai_obj.search(cr, uid, [
2963 ('state', '=', 'open'), ('wh_iva', '=', False),
2964 ('wh_iva_id', '=', False), ('type', 'in', ttype),
2965- ('partner_id', '=', partner_id), ('period_id', '=', period_id)],
2966+ '|',
2967+ ('partner_id', '=', acc_part_id.id),
2968+ ('partner_id', 'child_of', acc_part_id.id),
2969+ ('period_id', '=', period_id)],
2970 context=context)
2971 ai_ids = [ai_brw.id
2972 for ai_brw in ai_obj.browse(cr, uid, ai_ids, context=context)
2973@@ -684,7 +696,7 @@
2974 values_data['wh_lines'] = \
2975 [{'invoice_id': inv_brw.id,
2976 'name': inv_brw.name or _('N/A'),
2977- 'wh_iva_rate': inv_brw.partner_id.wh_iva_rate}
2978+ 'wh_iva_rate': rp_obj._find_accounting_partner(inv_brw.partner_id).wh_iva_rate}
2979 for inv_brw in ai_obj.browse(cr, uid, ai_ids, context=context)
2980 ]
2981 return {'value': values_data}
2982@@ -695,15 +707,16 @@
2983 """
2984 context = context or {}
2985 ids = isinstance(ids, (int, long)) and [ids] or ids
2986+ rp_obj = self.pool.get('res.partner')
2987
2988 for id in ids:
2989 inv_str = ''
2990 awi_brw = self.browse(cr, uid, id, context=context)
2991 for awil_brw in awi_brw.wh_lines:
2992- if awil_brw.invoice_id and awil_brw.invoice_id.partner_id.id !=\
2993- awi_brw.partner_id.id:
2994- inv_str+= '%s'% '\n'+(awil_brw.invoice_id.name or
2995- awil_brw.invoice_id.number or '')
2996+ acc_part_id = rp_obj._find_accounting_partner(awil_brw.invoice_id.partner_id)
2997+ if acc_part_id.id != awi_brw.partner_id.id:
2998+ inv_str+= '%s'% '\n'+(awil_brw.invoice_id.name or
2999+ awil_brw.invoice_id.number or '')
3000
3001 if inv_str:
3002 raise osv.except_osv('Incorrect Invoices !',"The following invoices are not from the selected partner: %s " % (inv_str,))
3003
3004=== modified file 'l10n_ve_withholding_iva/report/withholding_vat.py'
3005--- l10n_ve_withholding_iva/report/withholding_vat.py 2013-05-10 18:32:20 +0000
3006+++ l10n_ve_withholding_iva/report/withholding_vat.py 2014-01-08 15:40:54 +0000
3007@@ -109,6 +109,7 @@
3008 tot_iva_ret = {}
3009
3010 comp_obj = self.pool.get('account.wh.iva')
3011+ rp_obj = self.pool.get('res.partner')
3012 comp = comp_obj.browse(self.cr,self.uid, comp_id)
3013 res = {}
3014 ttal = {}
3015@@ -154,7 +155,7 @@
3016 'nro_ctrl': rl.invoice_id.nro_ctrl,
3017 'nro_ncre': rl.invoice_id.supplier_invoice_number,
3018 'nro_ndeb': rl.invoice_id.supplier_invoice_number,
3019- 'porcenta': rl.invoice_id.partner_id.wh_iva_rate,
3020+ 'porcenta': rp_obj._find_accounting_partner(rl.invoice_id.partner_id).wh_iva_rate,
3021 'tip_tran': self._get_tipo_doc(rl.invoice_id.type),
3022 'nro_fafe': no_fac_afe,
3023 'tot_civa': not sdcf and k*(txl.base+txl.amount) or 0.0,
3024@@ -195,7 +196,7 @@
3025 'nro_ctrl': rl.invoice_id.nro_ctrl,
3026 'nro_ncre': rl.invoice_id.supplier_invoice_number,
3027 'nro_ndeb': rl.invoice_id.supplier_invoice_number,
3028- 'porcenta': rl.invoice_id.partner_id.wh_iva_rate,
3029+ 'porcenta': rp_obj._find_accounting_partner(rl.invoice_id.partner_id).wh_iva_rate,
3030 'tip_tran': self._get_tipo_doc(rl.invoice_id.type),
3031 'nro_fafe': no_fac_afe,
3032 'tot_civa': not sdcf and k*(txl.base+txl.amount) or 0.0,
3033
3034=== removed file 'l10n_ve_withholding_iva/test/iva_invoice.yml'
3035--- l10n_ve_withholding_iva/test/iva_invoice.yml 2013-04-17 21:42:13 +0000
3036+++ l10n_ve_withholding_iva/test/iva_invoice.yml 1970-01-01 00:00:00 +0000
3037@@ -1,41 +0,0 @@
3038--
3039- In order to test Confirm Draft Invoice wizard I create an invoice and confirm it with this wizard
3040--
3041- !record {model: account.invoice, id: account_invoice_state}:
3042- account_id: account.a_recv
3043- company_id: base.main_company
3044- currency_id: base.VEB
3045- invoice_line:
3046- - product_id: product.product_product_3
3047- account_id: account.a_sale
3048- product_qty: 3
3049- uos_id: product.product_uom_unit
3050- price_unit: 10
3051- name: PC3
3052- taxes_id:
3053- - iva0
3054- journal_id: account.bank_journal
3055- partner_id: base.res_partner_desertic_hispafuentes
3056- reference_type: none
3057--
3058- I check that Initially customer invoice state is "Draft"
3059--
3060- !assert {model: account.invoice, id: account_invoice_state}:
3061- - state == 'draft'
3062--
3063- I called the "Confirm Draft Invoices" wizard
3064--
3065- !record {model: account.invoice.confirm, id: account_invoice_confirm_0}:
3066- {}
3067--
3068- I clicked on Confirm Invoices Button
3069--
3070- !python {model: account.invoice.confirm}: |
3071- self.invoice_confirm(cr, uid, [ref("account_invoice_confirm_0")], {"lang": 'en_US',
3072- "tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_state")],
3073- "type": "out_invoice", "active_id": ref("account_invoice_state"), })
3074--
3075- I check that customer invoice state is "Open"
3076--
3077- !assert {model: account.invoice, id: account_invoice_state}:
3078- - state == 'open'
3079
3080=== removed file 'l10n_ve_withholding_iva/test/iva_purchase.yml'
3081--- l10n_ve_withholding_iva/test/iva_purchase.yml 2013-01-15 14:31:52 +0000
3082+++ l10n_ve_withholding_iva/test/iva_purchase.yml 1970-01-01 00:00:00 +0000
3083@@ -1,58 +0,0 @@
3084--
3085- 1. Iva purchase test
3086--
3087- 1.1 I create IVA tax
3088--
3089- !record {model: account.tax, id: iva_purchase0}:
3090- name: 'IVA - Purchase'
3091- amount: 0.12
3092- type_tax_use: purchase
3093- applicable_type: 'true'
3094- company_id: base.main_company
3095- ret: False
3096--
3097- 1.2 Test if tax was properly created
3098--
3099- !assert {model: account.tax, id: iva_purchase0}:
3100- - name
3101--
3102- 1.3 I update partner information
3103--
3104- !record {model: res.partner, id: base.res_partner_23}:
3105- wh_iva_agent: True
3106- wh_iva_rate: 75
3107- vat_subjected: True
3108--
3109- 1.4 Test if information was updated properly
3110--
3111- !assert {model: res.partner, id: base.res_partner_23}:
3112- - wh_iva_agent
3113- - wh_iva_rate == 75
3114- - vat_subjected
3115--
3116- 1.5 I update company information
3117--
3118- !python {model: res.partner }: |
3119- vals = {
3120- 'wh_iva_agent': True,
3121- 'wh_iva_rate': 75,
3122- 'vat_subjected': True
3123- }
3124- self.write(cr, uid, [ref("base.main_company")], vals)
3125--
3126- 1.6 Test if company information was updated properly
3127--
3128- !assert {model: res.partner, id: base.main_company}:
3129- - wh_iva_agent
3130- - wh_iva_rate == 75
3131- - vat_subjected
3132--
3133- 1.7 I update IVA tax (withholdable)
3134--
3135- !python {model: account.tax }: |
3136- vals = {
3137- 'ret': True,
3138- 'wh_vat_collected_account_id': ref("account.ova"),
3139- 'wh_vat_paid_account_id': ref("account.ova")
3140- }
3141- self.write(cr, uid, [ref("l10n_ve_fiscal_requirements.iva_purchase1")], vals)
3142
3143=== removed file 'l10n_ve_withholding_iva/test/iva_purchase_nret1.yml'
3144--- l10n_ve_withholding_iva/test/iva_purchase_nret1.yml 2013-11-15 15:02:56 +0000
3145+++ l10n_ve_withholding_iva/test/iva_purchase_nret1.yml 1970-01-01 00:00:00 +0000
3146@@ -1,87 +0,0 @@
3147--
3148- 3. Iva tests purchase wh, wh should not be validated (test fails conditions)
3149--
3150- 3.1 Check conditions for creating the document, first main company configuration
3151--
3152- !assert {model: res.partner, id: base.main_company}:
3153- - wh_iva_agent
3154- - wh_iva_rate
3155- - vat_subjected
3156--
3157- 3.2 Check partner configuration
3158--
3159- !assert {model: res.partner, id: base.res_partner_23}:
3160- - wh_iva_agent
3161- - wh_iva_rate
3162- - vat_subjected
3163--
3164- 3.3 Check IVA configuration
3165--
3166- !assert {model: account.tax, id: iva_purchase0}:
3167- - amount
3168- - type_tax_use == 'purchase'
3169- - ret == False
3170- - not wh_vat_collected_account_id
3171- - not wh_vat_paid_account_id
3172--
3173- 3.4 I create a purchase invoice
3174--
3175- !record {model: account.invoice, id: test_purchase_iva_nret01}:
3176- type: out_invoice
3177- company_id: base.main_company
3178- date_invoice: !eval time.strftime('%Y-%m-%d')
3179- partner_id: base.res_partner_23
3180- reference_type: none
3181- journal_id: account.expenses_journal
3182- wh_iva: True
3183- invoice_line:
3184- - product_id: product.product_product_3
3185- quantity: 3
3186- uos_id: product.product_uom_unit
3187- price_unit: 10
3188- name: PC3
3189- invoice_line_tax_id:
3190- - l10n_ve_fiscal_requirements.iva_purchase1
3191- - product_id: product.product_product_4
3192- quantity: 5
3193- uos_id: product.product_uom_unit
3194- price_unit: 20
3195- name: PC2
3196- invoice_line_tax_id:
3197- - l10n_ve_fiscal_requirements.iva_purchase1
3198--
3199- 3.5 I check that Initially customer invoice is in the "Draft" state
3200--
3201- !assert {model: account.invoice, id: test_purchase_iva_nret01}:
3202- - state == 'draft'
3203--
3204- 3.6 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
3205--
3206- !workflow {model: account.invoice, action: invoice_proforma2, ref: test_purchase_iva_nret01}
3207--
3208- 3.7 I check that the invoice state is now "Proforma2"
3209--
3210- !assert {model: account.invoice, id: test_purchase_iva_nret01}:
3211- - state == 'proforma2'
3212--
3213- 3.8 I create invoice by clicking on Create button
3214--
3215- !workflow {model: account.invoice, action: invoice_open, ref: test_purchase_iva_nret01}
3216--
3217- 3.9 I check that the invoice state is "Open"
3218--
3219- !assert {model: account.invoice, id: test_purchase_iva_nret01, string: Invoice is not in open state}:
3220- - state == 'open'
3221--
3222- 3.10 Set control number for the invoice
3223--
3224- !python {model: account.invoice}: |
3225- self.write(cr, uid, [ref("test_purchase_iva_nret01")], {'nro_ctrl':'iva002', 'journal_id':ref("account.expenses_journal")})
3226- ai_brw = self.browse(cr, uid, ref("test_purchase_iva_nret01"))
3227- assert ai_brw.nro_ctrl=='iva002' and ai_brw.journal_id.id == ref("account.expenses_journal"), 'Invoice wasn\'t updated properly'
3228--
3229- 3.11 Check if withhold document was not created
3230--
3231- !python {model: account.invoice}: |
3232- po = self.browse(cr, uid, ref("test_purchase_iva_nret01"))
3233- assert not po.wh_iva_id, 'Withholding document shouldn\'t be created'
3234
3235=== removed file 'l10n_ve_withholding_iva/test/iva_purchase_nret2.yml'
3236--- l10n_ve_withholding_iva/test/iva_purchase_nret2.yml 2013-11-15 15:02:56 +0000
3237+++ l10n_ve_withholding_iva/test/iva_purchase_nret2.yml 1970-01-01 00:00:00 +0000
3238@@ -1,97 +0,0 @@
3239--
3240- 4. Iva tests purchase wh, wh should not be validated (test fails conditions)
3241--
3242- 4.1 I update company information (not wh partner)
3243--
3244- !python {model: res.partner}: |
3245- vals = {
3246- 'wh_iva_agent' : False,
3247- 'wh_iva_rate' : 0,
3248- 'vat_subjected' : False
3249- }
3250- self.write(cr, uid, ref("base.main_company"), vals)
3251--
3252- 4.2 Check conditions for creating the document, first main company configuration
3253--
3254- !assert {model: res.partner, id: base.main_company}:
3255- - not wh_iva_agent
3256- - wh_iva_rate == 0
3257- - not vat_subjected
3258--
3259- 4.3 Check partner configuration
3260--
3261- !assert {model: res.partner, id: base.res_partner_23}:
3262- - wh_iva_agent
3263- - wh_iva_rate
3264- - vat_subjected
3265--
3266- 4.4 Check IVA configuration
3267--
3268- !assert {model: account.tax, id: l10n_ve_fiscal_requirements.iva_purchase1}:
3269- - amount
3270- - type_tax_use == 'purchase'
3271- - ret
3272- - wh_vat_collected_account_id
3273- - wh_vat_paid_account_id
3274--
3275- 4.5 I create a purchase invoice
3276--
3277- !record {model: account.invoice, id: test_purchase_iva_nret02}:
3278- type: out_invoice
3279- company_id: base.main_company
3280- date_invoice: !eval time.strftime('%Y-%m-%d')
3281- partner_id: base.res_partner_23
3282- reference_type: none
3283- journal_id: account.expenses_journal
3284- wh_iva: True
3285- invoice_line:
3286- - product_id: product.product_product_3
3287- quantity: 3
3288- uos_id: product.product_uom_unit
3289- price_unit: 10
3290- name: PC3
3291- invoice_line_tax_id:
3292- - l10n_ve_fiscal_requirements.iva_purchase1
3293- - product_id: product.product_product_4
3294- quantity: 5
3295- uos_id: product.product_uom_unit
3296- price_unit: 20
3297- name: PC2
3298- invoice_line_tax_id:
3299- - l10n_ve_fiscal_requirements.iva_purchase1
3300--
3301- 4.6 I check that Initially customer invoice is in the "Draft" state
3302--
3303- !assert {model: account.invoice, id: test_purchase_iva_nret02}:
3304- - state == 'draft'
3305--
3306- 4.7 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
3307--
3308- !workflow {model: account.invoice, action: invoice_proforma2, ref: test_purchase_iva_nret02}
3309--
3310- 4.8 I check that the invoice state is now "Proforma2"
3311--
3312- !assert {model: account.invoice, id: test_purchase_iva_nret02}:
3313- - state == 'proforma2'
3314--
3315- 4.8 I create invoice by clicking on Create button
3316--
3317- !workflow {model: account.invoice, action: invoice_open, ref: test_purchase_iva_nret02}
3318--
3319- 4.10 I check that the invoice state is "Open"
3320--
3321- !assert {model: account.invoice, id: test_purchase_iva_nret02, string: Invoice is not in open state}:
3322- - state == 'open'
3323--
3324- 4.11 Set control number for the invoice
3325--
3326- !python {model: account.invoice}: |
3327- self.write(cr, uid, [ref("test_purchase_iva_nret02")], {'nro_ctrl':'iva003', 'journal_id':ref("account.expenses_journal")})
3328- ai_brw = self.browse(cr, uid, ref("test_purchase_iva_nret02"))
3329- assert ai_brw.nro_ctrl=='iva003' and ai_brw.journal_id.id == ref("account.expenses_journal"), 'Invoice wasn\'t updated properly'
3330--
3331- 4.12 Check if withhold document was not created
3332--
3333- !python {model: account.invoice}: |
3334- po = self.browse(cr, uid, ref("test_purchase_iva_nret02"))
3335- assert not po.wh_iva_id, 'Withholding document shouldn\'t be created'
3336
3337=== removed file 'l10n_ve_withholding_iva/test/iva_purchase_nret3.yml'
3338--- l10n_ve_withholding_iva/test/iva_purchase_nret3.yml 2013-11-15 15:02:56 +0000
3339+++ l10n_ve_withholding_iva/test/iva_purchase_nret3.yml 1970-01-01 00:00:00 +0000
3340@@ -1,107 +0,0 @@
3341--
3342- 5. Iva tests purchase wh, wh should not be validated (test fails conditions)
3343--
3344- 5.1 I update company information
3345--
3346- !python {model: res.partner}: |
3347- vals = {
3348- 'wh_iva_agent' : True,
3349- 'wh_iva_rate' : 75,
3350- 'vat_subjected' : True
3351- }
3352- self.write(cr, uid, ref("base.main_company"), vals)
3353--
3354- 5.2 Check conditions for creating the document, first main company configuration
3355--
3356- !assert {model: res.partner, id: base.main_company}:
3357- - wh_iva_agent
3358- - wh_iva_rate
3359- - vat_subjected
3360--
3361- 5.3 I update partner information
3362--
3363- !python {model: res.partner}: |
3364- vals = {
3365- 'wh_iva_agent' : False,
3366- 'wh_iva_rate' : 0,
3367- 'vat_subjected' : False
3368- }
3369- self.write(cr, uid, ref("base.res_partner_23"), vals)
3370--
3371- 5.4 Check partner configuration
3372--
3373- !assert {model: res.partner, id: base.res_partner_23}:
3374- - not wh_iva_agent
3375- - wh_iva_rate == 0
3376- - not vat_subjected
3377--
3378- 5.5 Check IVA configuration
3379--
3380- !assert {model: account.tax, id: l10n_ve_fiscal_requirements.iva_purchase1}:
3381- - amount
3382- - type_tax_use == 'purchase'
3383- - ret
3384- - wh_vat_collected_account_id
3385- - wh_vat_paid_account_id
3386--
3387- 5.6 I create a purchase invoice
3388--
3389- !record {model: account.invoice, id: test_purchase_iva_nret03}:
3390- type: out_invoice
3391- company_id: base.main_company
3392- date_invoice: !eval time.strftime('%Y-%m-%d')
3393- partner_id: base.res_partner_23
3394- reference_type: none
3395- journal_id: account.expenses_journal
3396- wh_iva: True
3397- invoice_line:
3398- - product_id: product.product_product_3
3399- quantity: 3
3400- uos_id: product.product_uom_unit
3401- price_unit: 10
3402- name: PC3
3403- invoice_line_tax_id:
3404- - l10n_ve_fiscal_requirements.iva_purchase1
3405- - product_id: product.product_product_4
3406- quantity: 5
3407- uos_id: product.product_uom_unit
3408- price_unit: 20
3409- name: PC2
3410- invoice_line_tax_id:
3411- - l10n_ve_fiscal_requirements.iva_purchase1
3412--
3413- 5.7 I check that Initially customer invoice is in the "Draft" state
3414--
3415- !assert {model: account.invoice, id: test_purchase_iva_nret03}:
3416- - state == 'draft'
3417--
3418- 5.8 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
3419--
3420- !workflow {model: account.invoice, action: invoice_proforma2, ref: test_purchase_iva_nret03}
3421--
3422- 5.9 I check that the invoice state is now "Proforma2"
3423--
3424- !assert {model: account.invoice, id: test_purchase_iva_nret03}:
3425- - state == 'proforma2'
3426--
3427- 5.10 I create invoice by clicking on Create button
3428--
3429- !workflow {model: account.invoice, action: invoice_open, ref: test_purchase_iva_nret03}
3430--
3431- 5.11 I check that the invoice state is "Open"
3432--
3433- !assert {model: account.invoice, id: test_purchase_iva_nret03, string: Invoice is not in open state}:
3434- - state == 'open'
3435--
3436- 5.12 Set control number for the invoice
3437--
3438- !python {model: account.invoice}: |
3439- self.write(cr, uid, [ref("test_purchase_iva_nret03")], {'nro_ctrl':'iva004', 'journal_id':ref("account.expenses_journal")})
3440- ai_brw = self.browse(cr, uid, ref("test_purchase_iva_nret03"))
3441- assert ai_brw.nro_ctrl=='iva004' and ai_brw.journal_id.id == ref("account.expenses_journal"), 'Invoice wasn\'t updated properly'
3442--
3443- 5.13 Check if withhold document was not created
3444--
3445- !python {model: account.invoice}: |
3446- po = self.browse(cr, uid, ref("test_purchase_iva_nret03"))
3447- assert not po.wh_iva_id, 'Withholding document shouldn\'t be created'
3448
3449=== removed file 'l10n_ve_withholding_iva/test/iva_purchase_wh.yml'
3450--- l10n_ve_withholding_iva/test/iva_purchase_wh.yml 2013-11-15 15:02:56 +0000
3451+++ l10n_ve_withholding_iva/test/iva_purchase_wh.yml 1970-01-01 00:00:00 +0000
3452@@ -1,92 +0,0 @@
3453--
3454- 2. Tests for iva purchase wh
3455--
3456- 2.1 Check conditions for creating the document, first main company configuration
3457--
3458- !assert {model: res.partner, id: base.main_company}:
3459- - wh_iva_agent
3460- - wh_iva_rate
3461- - vat_subjected
3462--
3463- 2.2 Check partner configuration
3464--
3465- !assert {model: res.partner, id: base.res_partner_23}:
3466- - wh_iva_agent
3467- - wh_iva_rate
3468- - vat_subjected
3469--
3470- 2.3 Check IVA configuration
3471--
3472- !assert {model: account.tax, id: l10n_ve_fiscal_requirements.iva_purchase1}:
3473- - amount
3474- - type_tax_use == 'purchase'
3475- - ret
3476- - wh_vat_collected_account_id
3477- - wh_vat_paid_account_id
3478--
3479- 2.4 I create a purchase invoice
3480--
3481- !record {model: account.invoice, id: test_purchase_iva02, view: account.invoice_supplier_form, context:{'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'}}:
3482- type: in_invoice
3483- state: draft
3484- company_id: base.main_company
3485- date_invoice: !eval time.strftime('%Y-%m-%d')
3486- partner_id: base.res_partner_23
3487- reference_type: none
3488- journal_id:
3489- wh_iva: True
3490- invoice_line:
3491- - product_id: product.product_product_3
3492- quantity: 3
3493- uos_id: product.product_uom_unit
3494- price_unit: 10
3495- name: PC3
3496- invoice_line_tax_id:
3497- - l10n_ve_fiscal_requirements.iva_purchase1
3498- - product_id: product.product_product_4
3499- quantity: 5
3500- uos_id: product.product_uom_unit
3501- price_unit: 20
3502- name: PC2
3503- invoice_line_tax_id:
3504- - l10n_ve_fiscal_requirements.iva_purchase1
3505--
3506- 2.5 I check that Initially supplier invoice is in the "Draft" state
3507--
3508- !python {model: account.invoice}: |
3509- ap_obj=self.pool.get('account.period')
3510- import time
3511- period = ap_obj.find(cr, uid, time.strftime('%Y/%m/%d'), context={'company_id':ref("base.main_company")})
3512- assert period, 'There aren\'t periods for this date'
3513- ap_obj.write(cr, uid, period, {'special':False})
3514- self.write(cr,uid,ref('test_purchase_iva02'),{'journal_id':ref('account.expenses_journal'),'type':'in_invoice'})
3515- ai_brw = self.browse(cr,uid,ref('test_purchase_iva02'))
3516- assert ai_brw.type == 'in_invoice', "Not the intended type. It should be 'in_invoice' not '%s'"%ai_brw.type
3517- assert ai_brw.state == 'draft', "Not the intended state. It should be 'draft' not '%s'"%ai_brw.state
3518- assert ai_brw.journal_id.id == ref('account.expenses_journal'), "Not the intended Journal. It should be 'Expenses Journal - (test)' not '%s'"%ai_brw.journal_id.name
3519--
3520- 2.6 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
3521--
3522- !workflow {model: account.invoice, action: invoice_proforma2, ref: test_purchase_iva02}
3523--
3524- 2.7 I check that the invoice state is now "Proforma2"
3525--
3526- !assert {model: account.invoice, id: test_purchase_iva02}:
3527- - state == 'proforma2'
3528--
3529- 2.8 I create invoice by clicking on Create button
3530--
3531- !workflow {model: account.invoice, action: invoice_open, ref: test_purchase_iva02}
3532--
3533- 2.9 I check that the invoice state is "Open"
3534--
3535- !assert {model: account.invoice, id: test_purchase_iva02, string: Invoice is not in open state}:
3536- - state == 'open'
3537--
3538- 2.10 Set control number for the invoice
3539--
3540- !python {model: account.invoice}: |
3541- self.write(cr, uid, [ref("test_purchase_iva02")], {'nro_ctrl':'iva002'})
3542- ai_brw = self.browse(cr, uid, ref("test_purchase_iva02"))
3543- assert ai_brw.nro_ctrl=='iva002', "Not the intended Control Number. It should be 'iva002' not '%s'"%ai_brw.nro_ctrl
3544- assert ai_brw.journal_id.id == ref('account.expenses_journal'), "Not the intended Journal. It should be 'Expenses Journal - (test)' not '%s'"%ai_brw.journal_id.name
3545
3546=== removed file 'l10n_ve_withholding_iva/test/iva_sale.yml'
3547--- l10n_ve_withholding_iva/test/iva_sale.yml 2013-01-15 14:31:52 +0000
3548+++ l10n_ve_withholding_iva/test/iva_sale.yml 1970-01-01 00:00:00 +0000
3549@@ -1,68 +0,0 @@
3550--
3551- 6. Iva tests sale wh
3552--
3553- 6.1 I create IVA sale tax
3554--
3555- !record {model: account.tax, id: iva_sale0}:
3556- name: 'IVA - Sale'
3557- amount: 0.12
3558- type_tax_use: sale
3559- applicable_type: 'true'
3560- company_id: base.main_company
3561- ret: False
3562--
3563- 6.2 Test if sale tax was properly created
3564--
3565- !assert {model: account.tax, id: iva_purchase0}:
3566- - name
3567--
3568- 6.3 I update partner information
3569--
3570- !python {model: res.partner}: |
3571- vals = {
3572- 'wh_iva_agent': True,
3573- 'wh_iva_rate': 75,
3574- 'vat_subjected': True
3575- }
3576- self.write(cr, uid, ref('base.res_partner_23'), vals)
3577--
3578- 6.4 Test if information was updated properly
3579--
3580- !assert {model: res.partner, id: base.res_partner_23}:
3581- - wh_iva_agent
3582- - wh_iva_rate == 75
3583- - vat_subjected
3584--
3585- 6.5 I update company information
3586--
3587- !python {model: res.partner}: |
3588- vals = {
3589- 'wh_iva_agent': True,
3590- 'wh_iva_rate': 75,
3591- 'vat_subjected': True
3592- }
3593- self.write(cr, uid, ref('base.main_company'), vals )
3594--
3595- 6.6 Test if company information was updated properly
3596--
3597- !assert {model: res.partner, id: base.main_company}:
3598- - wh_iva_agent
3599- - wh_iva_rate == 75
3600- - vat_subjected
3601--
3602- 6.7 I create IVA sale tax (withholdable)
3603--
3604- !record {model: account.tax, id: iva_sale1}:
3605- name: 'IVA - Sale (withholdable) 1'
3606- amount: 0.12
3607- type_tax_use: sale
3608- applicable_type: 'true'
3609- company_id: base.main_company
3610- ret: True
3611- wh_vat_collected_account_id: account.ova
3612- wh_vat_paid_account_id: account.ova
3613--
3614- 6.8 Test if tax was properly created
3615--
3616- !assert {model: account.tax, id: iva_sale1}:
3617- - name
3618
3619=== removed file 'l10n_ve_withholding_iva/test/iva_sale_2.yml'
3620--- l10n_ve_withholding_iva/test/iva_sale_2.yml 2012-05-10 20:09:06 +0000
3621+++ l10n_ve_withholding_iva/test/iva_sale_2.yml 1970-01-01 00:00:00 +0000
3622@@ -1,58 +0,0 @@
3623--
3624- I create IVA sale tax with wrong values amount > 1 for type = percent
3625--
3626- !python {model: account.tax}: |
3627- vals = {
3628- 'name': 'Iva sale a',
3629- 'amount': 10.12,
3630- 'type_tax_use': 'sale',
3631- 'applicable_type': 'true',
3632- 'company_id': ref("base.main_company"),
3633- 'ret': False,
3634- 'type': 'percent'
3635- }
3636- try:
3637- at_id = self.create(cr, uid, vals)
3638- except Exception as e:
3639- at_id = -1
3640- pass
3641- assert at_id == -1 or not at_id, 'Tax must not be saved because amount > 1 and type = percent'
3642--
3643- I create IVA sale tax with wrong values amount < 0 for type = percent
3644--
3645- !python {model: account.tax}: |
3646- vals = {
3647- 'name': 'Iva sale B',
3648- 'amount': -10.12,
3649- 'type_tax_use': 'sale',
3650- 'applicable_type': 'true',
3651- 'company_id': ref("base.main_company"),
3652- 'ret': False,
3653- 'type': 'percent'
3654- }
3655- try:
3656- at_id = self.create(cr, uid, vals)
3657- except Exception as e:
3658- at_id = -1
3659- pass
3660- assert at_id == -1 or not at_id, 'Tax must not be saved because amount < 0 and type = percent'
3661--
3662- I create IVA sale tax with wrong values Withholdeable but not tax accounts
3663--
3664- !python {model: account.tax}: |
3665- vals = {
3666- 'name': 'Iva sale C',
3667- 'amount': 0.12,
3668- 'type_tax_use': 'sale',
3669- 'applicable_type': 'true',
3670- 'company_id': ref("base.main_company"),
3671- 'ret': True,
3672- 'type': 'percent'
3673- }
3674- at_id = -1
3675- try:
3676- at_id = self.create(cr, uid, vals)
3677- except Exception as e:
3678- at_id = -1
3679- pass
3680- assert at_id == -1 or not at_id, 'Tax must not be saved because has not accounts'
3681
3682=== removed file 'l10n_ve_withholding_iva/test/iva_sale_wh.yml'
3683--- l10n_ve_withholding_iva/test/iva_sale_wh.yml 2013-11-15 15:02:56 +0000
3684+++ l10n_ve_withholding_iva/test/iva_sale_wh.yml 1970-01-01 00:00:00 +0000
3685@@ -1,205 +0,0 @@
3686--
3687- 7. Iva tests sale wh
3688--
3689- 7.1 In order to test account invoice I create a new customer invoice
3690--
3691- !record {model: account.invoice, id: test_sale_iva_ret01}:
3692- company_id: base.main_company
3693- currency_id: base.EUR
3694- date_invoice: !eval time.strftime('%Y-%m-%d')
3695- account_id: account.a_recv
3696- invoice_line:
3697- - product_id: product.product_product_3
3698- quantity: 3
3699- uos_id: product.product_uom_unit
3700- price_unit: 10
3701- name: PC3
3702- account_id: account.a_sale
3703- invoice_line_tax_id:
3704- - iva_sale1
3705- - product_id: product.product_product_4
3706- quantity: 5
3707- uos_id: product.product_uom_unit
3708- price_unit: 20
3709- name: PC2
3710- account_id: account.a_sale
3711- invoice_line_tax_id:
3712- - iva_sale1
3713- journal_id: account.sales_journal
3714- partner_id: base.res_partner_23
3715- reference_type: none
3716--
3717- 7.2 I check that Initially customer invoice is in the "Draft" state
3718--
3719- !assert {model: account.invoice, id: test_sale_iva_ret01}:
3720- - state == 'draft'
3721--
3722- 7.3 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
3723--
3724- !workflow {model: account.invoice, action: invoice_proforma2, ref: test_sale_iva_ret01}
3725--
3726- 7.4 I check that the invoice state is now "Proforma2"
3727--
3728- !assert {model: account.invoice, id: test_sale_iva_ret01}:
3729- - state == 'proforma2'
3730--
3731- 7.5 I check that there is no move attached to the invoice
3732--
3733- !python {model: account.invoice}: |
3734- acc_id=self.browse(cr, uid, ref("test_sale_iva_ret01"))
3735- assert (not acc_id.move_id), "Move falsely created at pro-forma"
3736--
3737- 7.6 I create invoice by clicking on Create button
3738--
3739- !workflow {model: account.invoice, action: invoice_open, ref: test_sale_iva_ret01}
3740--
3741- 7.7 I check that the invoice state is "Open"
3742--
3743- !assert {model: account.invoice, id: test_sale_iva_ret01}:
3744- - state == 'open'
3745--
3746- 7.8 I check that now there is a move attached to the invoice
3747--
3748- !python {model: account.invoice}: |
3749- acc_id=self.browse(cr, uid, ref("test_sale_iva_ret01"))
3750- assert acc_id.move_id, "Move not created for open invoice"
3751--
3752- 7.9 I check journal entries for the invoice
3753--
3754- !python {model: account.invoice}: |
3755- am_obj=self.pool.get('account.move')
3756- ai = self.browse(cr, uid, ref("test_sale_iva_ret01"))
3757- am_ids = am_obj.search(cr, uid, [('name', '=', ai.number)])
3758- assert am_ids, 'Not found account move for the document'
3759- am_brw = am_obj.browse(cr, uid, am_ids[0])
3760- d = c = 0
3761- for l in am_brw.line_id:
3762- if l.account_id.id == ref("account.a_recv"):
3763- d += l.debit
3764- else:
3765- c += l.credit
3766- if l.tax_amount > 0:
3767- assert l.tax_amount == 15.6, 'Tax is wrong'
3768- assert c==d, 'Totals must match'
3769--
3770- 7.10 I generate a withholding vat customer
3771--
3772- !record {model: account.wh.iva, id: wh_iva_sale01}:
3773- journal_id: wh_sales_journal
3774- partner_id: base.res_partner_23
3775- number: 111222333
3776- account_id: account.a_recv
3777- name: 'IVA wh vat customer'
3778- type: out_invoice
3779--
3780- 7.11 I check withholding vat customer
3781--
3782- !assert {model: account.wh.iva, id: wh_iva_sale01}:
3783- - state == 'draft'
3784--
3785- 7.12 I click on Calculate taxes button
3786--
3787- !python {model: account.invoice}: |
3788- self.button_reset_taxes(cr, uid, [ref("test_sale_iva_ret01")])
3789--
3790- 7.13 Before validating let's add the period
3791--
3792- !python {model: account.wh.iva}: |
3793- import time
3794- ap_obj=self.pool.get('account.period')
3795- period = ap_obj.find(cr, uid, time.strftime('%Y/%m/%d'), context={'company_id':ref("base.main_company")})
3796- assert period, 'There aren\'t periods for this date'
3797- ap_obj.write(cr, uid, period, {'special':False})
3798- ap_brw = ap_obj.browse(cr, uid, period[0])
3799- if ap_brw.state == 'done':
3800- ap.action_draft(cr, uid, period)
3801- ap_brw = ap.browse(cr, uid, period[0])
3802- assert ap_brw.state == 'draft', 'Period is not open as it should be'
3803- assert ap_brw.special == False, 'Period is special. It should be'
3804-
3805- self.write(cr, uid, ref("wh_iva_sale01"), {'period_id':period[0]})
3806--
3807- 7.14 I check period was modificated
3808--
3809- !assert {model: account.wh.iva, id: wh_iva_sale01}:
3810- - period_id
3811--
3812- 7.15 Check partner invoices
3813--
3814- !python {model: account.wh.iva}: |
3815- wil_obj=self.pool.get('account.wh.iva.line')
3816- res = self.onchange_partner_id(cr, uid, [1], 'out_invoice', ref("base.res_partner_23"))
3817- ind_id = res['value']['wh_lines'][0]['invoice_id']
3818- res['value']['wh_lines'][0].update({'retention_id': ref("wh_iva_sale01")})
3819- wil_id = wil_obj.create(cr, uid, res['value']['wh_lines'][0])
3820- wil_obj.load_taxes(cr, uid, [wil_id])
3821-#~ -
3822- #~ 7.16 I try to confirm the withholding vat customer (This test raise an exception - is ok - but its commented to pursue next steps in the test)
3823-#~ -
3824- #~ !workflow {model: account.wh.iva, action: wh_iva_confirmed, ref: wh_iva_sale01}
3825--
3826- 7.17 I check withholding vat not is confirmed because invoice has not control number
3827--
3828- !assert {model: account.wh.iva, id: wh_iva_sale01, string: Vat document cannot be in confirmed state}:
3829- - state != 'confirmed'
3830--
3831- 7.18 Create wizard for adding control number
3832--
3833- !record {model: wiz.nroctrl, id: wizard_nro_ctrl}:
3834- name: '31010101'
3835- sure: True
3836--
3837- 7.19 Execute wizard for control number
3838--
3839- !python {model: wiz.nroctrl}: |
3840- import time
3841- ctx={}
3842- ctx.update({'lang': u'en_US', 'active_model': 'ir.ui.menu', 'tz': False, 'active_ids': [ref("test_sale_iva_ret01"),], 'active_id': ref("test_sale_iva_ret01")})
3843- data_dict = {'name':time.strftime('%m/%Y'), 'sure': True, 'model': 'wh_p'}
3844- self.set_noctrl(cr, uid, [ref("wizard_nro_ctrl")], ctx)
3845--
3846- 7.20 Check if control number was properly updated
3847--
3848- !assert {model: account.invoice, id: test_sale_iva_ret01, string: Control number was not propely updated}:
3849- - nro_ctrl
3850--
3851- 7.21 I confirm the withholding vat customer after updater control number
3852--
3853- !workflow {model: account.wh.iva, action: wh_iva_confirmed, ref: wh_iva_sale01}
3854--
3855- 7.22 I check withholding vat is confirmed
3856--
3857- !assert {model: account.wh.iva, id: wh_iva_sale01, string: Wh documment eas not properly validated}:
3858- - state == 'confirmed'
3859--
3860- 7.23 I mark it as done
3861--
3862- !workflow {model: account.wh.iva, action: wh_iva_done, ref: wh_iva_sale01}
3863--
3864- 7.24 I check withholding vat is done
3865--
3866- !assert {model: account.wh.iva, id: wh_iva_sale01}:
3867- - state == 'done'
3868--
3869- 7.25 I check that the invoice has the wh document
3870--
3871- !assert {model: account.invoice, id: test_sale_iva_ret01}:
3872- - wh_iva_id
3873--
3874- 7.26 I check IVA sale journal entries
3875--
3876- !python {model: account.wh.iva}: |
3877- am_obj=self.pool.get('account.move')
3878- ai_obj=self.pool.get('account.invoice')
3879- acc_id=ai_obj.browse(cr, uid, ref("test_sale_iva_ret01"))
3880- am_ids = am_obj.search(cr, uid, [('ref', '=', acc_id.number)])
3881- assert am_ids, 'Not found account move for the document'
3882- am_brw = am_obj.browse(cr, uid, am_ids[0])
3883- assert len(am_brw.line_id) == 2, 'Must be 2 entries for this journal entry'
3884- d = c = 0
3885- for l in am_brw.line_id:
3886- if l.account_id.id == ref("account.ova"):
3887- c += l.debit
3888- else:
3889- d += l.credit
3890- assert c==d, 'Totals must match'
3891
3892=== removed file 'l10n_ve_withholding_iva/test/iva_sale_withholding.yml'
3893--- l10n_ve_withholding_iva/test/iva_sale_withholding.yml 2012-05-10 16:39:12 +0000
3894+++ l10n_ve_withholding_iva/test/iva_sale_withholding.yml 1970-01-01 00:00:00 +0000
3895@@ -1,58 +0,0 @@
3896--
3897- I create IVA sale tax with wrong values amount > 1 for type = percent
3898--
3899- !python {model: account.tax}: |
3900- vals = {
3901- 'name': 'Iva sale a',
3902- 'amount': 10.12,
3903- 'type_tax_use': 'sale',
3904- 'applicable_type': 'true',
3905- 'company_id': ref("base.main_company"),
3906- 'ret': False,
3907- 'type': 'percent'
3908- }
3909- try:
3910- at_id = self.create(cr, uid, vals)
3911- except Exception as e:
3912- at_id = -1
3913- pass
3914- assert at_id == -1 or not at_id, 'Tax must not be saved because amount > 1 and type = percent'
3915--
3916- I create IVA sale tax with wrong values amount < 0 for type = percent
3917--
3918- !python {model: account.tax}: |
3919- vals = {
3920- 'name': 'Iva sale B',
3921- 'amount': -10.12,
3922- 'type_tax_use': 'sale',
3923- 'applicable_type': 'true',
3924- 'company_id': ref("base.main_company"),
3925- 'ret': False,
3926- 'type': 'percent'
3927- }
3928- try:
3929- at_id = self.create(cr, uid, vals)
3930- except Exception as e:
3931- at_id = -1
3932- pass
3933- assert at_id == -1 or not at_id, 'Tax must not be saved because amount < 0 and type = percent'
3934--
3935- I create IVA sale tax with wrong values Withholdeable but not tax accounts
3936--
3937- !python {model: account.tax}: |
3938- vals = {
3939- 'name': 'Iva sale C',
3940- 'amount': 0.12,
3941- 'type_tax_use': 'sale',
3942- 'applicable_type': 'true',
3943- 'company_id': ref("base.main_company"),
3944- 'ret': True,
3945- 'type': 'percent'
3946- }
3947- at_id = -1
3948- try:
3949- at_id = self.create(cr, uid, vals)
3950- except Exception as e:
3951- at_id = -1
3952- pass
3953- assert at_id == -1 or not at_id, 'Tax must not be saved because has not accounts'
3954
3955=== removed file 'l10n_ve_withholding_iva/test/iva_test_invoice.yml'
3956--- l10n_ve_withholding_iva/test/iva_test_invoice.yml 2013-01-18 18:48:46 +0000
3957+++ l10n_ve_withholding_iva/test/iva_test_invoice.yml 1970-01-01 00:00:00 +0000
3958@@ -1,67 +0,0 @@
3959--
3960- 8. Test iva sale
3961--
3962- 8.1 In order to test account invoice I create a new sale invoice with purchase tax
3963--
3964- !record {model: account.invoice, id: test_iva01}:
3965- company_id: base.main_company
3966- currency_id: base.EUR
3967- date_invoice: !eval time.strftime('%Y-%m-%d')
3968- account_id: account.a_recv
3969- invoice_line:
3970- - product_id: product.product_product_3
3971- quantity: 3
3972- uos_id: product.product_uom_unit
3973- price_unit: 10
3974- name: PC3
3975- account_id: account.a_sale
3976- invoice_line_tax_id:
3977- - iva_purchase0
3978- - product_id: product.product_product_4
3979- quantity: 5
3980- uos_id: product.product_uom_unit
3981- price_unit: 20
3982- name: PC2
3983- account_id: account.a_sale
3984- invoice_line_tax_id:
3985- - iva_purchase0
3986- journal_id: account.sales_journal
3987- partner_id: base.res_partner_23
3988- reference_type: none
3989- nro_ctrl: 56778211
3990--
3991- 8.2 I check that Initially customer invoice is in the "Draft" state
3992--
3993- !assert {model: account.invoice, id: test_iva01}:
3994- - state == 'draft'
3995--
3996- 8.3 I click on Calculate taxes button
3997--
3998- !python {model: account.invoice}: |
3999- acc_brw=self.browse(cr, uid, ref("test_iva01"))
4000- self.button_reset_taxes(cr, uid, [ref("test_iva01")])
4001--
4002- 8.4 I change the state of invoice to "Proforma2" by clicking PRO-FORMA button
4003--
4004- !workflow {model: account.invoice, action: invoice_proforma2, ref: test_iva01}
4005--
4006- 8.5 I check that the invoice state is now "Proforma2"
4007--
4008- !assert {model: account.invoice, id: test_iva01}:
4009- - state == 'proforma2'
4010--
4011- 8.6 I check that there is no move attached to the invoice
4012--
4013- !python {model: account.invoice}: |
4014- acc_id=self.browse(cr, uid, ref("test_iva01"))
4015- assert (not acc_id.move_id), "Move falsely created at pro-forma"
4016--
4017- 8.7 I try to create an invoice by clicking on Create button
4018--
4019- !workflow {model: account.invoice, action: invoice_open, ref: test_iva01}
4020-#~ -
4021- #~ 8.8 I check that the invoice state is not "Open"
4022- # This test is failing. Is supposed to that "test_iva01" invoice remains in the proforma2 state, however it changes to open state
4023-#~ -
4024- #~ !assert {model: account.invoice, id: test_iva01, string: Sale invoice has purchase tax. The invoice cannot be in open state}:
4025- #~ - state != 'open'
4026
4027=== removed file 'l10n_ve_withholding_iva/test/iva_test_wh.yml'
4028--- l10n_ve_withholding_iva/test/iva_test_wh.yml 2013-01-18 19:11:56 +0000
4029+++ l10n_ve_withholding_iva/test/iva_test_wh.yml 1970-01-01 00:00:00 +0000
4030@@ -1,57 +0,0 @@
4031--
4032- 9. Test withholdeable iva
4033--
4034- 9.1 I update partner information
4035--
4036- !record {model: res.partner, id: base.res_partner_23}:
4037- wh_iva_agent: True
4038- wh_iva_rate: 75
4039- vat_subjected: True
4040--
4041- 9.2 I generate a withholding vat customer
4042--
4043- !record {model: account.wh.iva, id: wh_iva_test01}:
4044- journal_id: wh_sales_journal
4045- partner_id: base.res_partner_23
4046- number: 55668811
4047- account_id: account.a_recv
4048- name: 'IVA wh vat customer Vauxoo test'
4049- type: out_invoice
4050--
4051- 9.3 I check withholding vat customer
4052--
4053- !assert {model: account.wh.iva, id: wh_iva_test01, string: Wh was not saved}:
4054- - state == 'draft'
4055--
4056- 9.4 Before validating let's add the period
4057--
4058- !python {model: account.wh.iva}: |
4059- import time
4060- ap_obj=self.pool.get('account.period')
4061- period = ap_obj.find(cr, uid, time.strftime('%Y/%m/%d'), {'company_id':ref('base.main_company')})
4062- assert period, 'There aren\'t periods for this date'
4063- self.write(cr, uid, ref("wh_iva_test01"), {'period_id':period[0]})
4064--
4065- 9.5 I check period was updated
4066--
4067- !assert {model: account.wh.iva, id: wh_iva_test01, string: Period was not updated}:
4068- - period_id
4069-#~ -
4070- #~ 9.6 I confirm the withholding vat customer
4071- #~ # This test case is commented because it raise the exception 'Invoices with Missing Withheld Taxes!' and interrupts the continuity of the other test cases
4072-#~ -
4073- #~ !workflow {model: account.wh.iva, action: wh_iva_confirmed, ref: wh_iva_test01}
4074--
4075- 9.7 I check withholding vat is not confirmed
4076--
4077- !assert {model: account.wh.iva, id: wh_iva_test01, string: Could not confirm the wh}:
4078- - state != 'confirmed'
4079--
4080- 9.8 I try to mark it as done
4081--
4082- !workflow {model: account.wh.iva, action: wh_iva_done, ref: wh_iva_test01}
4083--
4084- 9.9 I check withholding vat is not done
4085--
4086- !assert {model: account.wh.iva, id: wh_iva_test01, string: Wh cannot be in done state}:
4087- - state != 'done'
4088
4089=== removed file 'l10n_ve_withholding_iva/test/iva_test_wh_2.yml'
4090--- l10n_ve_withholding_iva/test/iva_test_wh_2.yml 2013-11-15 15:02:56 +0000
4091+++ l10n_ve_withholding_iva/test/iva_test_wh_2.yml 1970-01-01 00:00:00 +0000
4092@@ -1,70 +0,0 @@
4093--
4094- 10. Test not withholdeable iva
4095--
4096- 10.1 I update partner information
4097--
4098- !record {model: res.partner, id: base.res_partner_23}:
4099- wh_iva_agent: True
4100- wh_iva_rate: 75
4101- vat_subjected: True
4102--
4103- 10.2 I generate a withholding vat customer
4104--
4105- !record {model: account.wh.iva, id: wh_iva_test02, view: view_wh_iva_form_customer, context: {'type':'out_invoice'}}:
4106- journal_id: wh_sales_journal
4107- partner_id: base.res_partner_23
4108- number: 222444333000
4109- account_id: account.a_recv
4110- name: 'IVA wh vat customer Vauxoo test 2'
4111- type: out_invoice
4112- state: draft
4113--
4114- 10.3 I check withholding vat customer
4115--
4116- !python {model: account.wh.iva}: |
4117- values = {}
4118- rp_obj = self.pool.get('res.partner')
4119- rp_brw = rp_obj.browse(cr,uid,ref("base.res_partner_23"))
4120- res = self.onchange_partner_id(cr, uid, [ref('wh_iva_test02')], 'out_invoice', rp_brw.id)
4121- values['wh_lines'] = [(0,0,{'invoice_id':ref('test_iva01'), 'name':'N/A', 'wh_iva_rate':rp_brw.wh_iva_rate})]
4122- values['account_id'] = res['value']['account_id']
4123- values['type'] = 'out_invoice'
4124- self.write(cr,uid,ref('wh_iva_test02'),values)
4125- awi_brw = self.browse(cr,uid,ref('wh_iva_test02'))
4126- assert awi_brw.type == 'out_invoice', "Not the intended type. It should be 'out_invoice' not '%s'"%awi_brw.type
4127- assert awi_brw.state == 'draft', "Not the intended state. It should be 'draft' not '%s'"%awi_brw.state
4128- assert awi_brw.wh_lines, "There are no lines to withhold"
4129- self.compute_amount_wh(cr,uid,[ref('wh_iva_test02')])
4130--
4131- 10.4 I confirm the withholding vat customer
4132--
4133- !python {model: account.wh.iva}: |
4134- import netsvc
4135- from openerp.osv import osv
4136- wf_service = netsvc.LocalService("workflow")
4137- try:
4138- self.check_wh_lines_fortnights(cr, uid, [ref('wh_iva_test02')])
4139- self.check_invoice_nro_ctrl(cr, uid, [ref('wh_iva_test02')])
4140- self.check_vat_wh(cr, uid, [ref('wh_iva_test02')])
4141- self.check_wh_taxes(cr, uid, [ref('wh_iva_test02')])
4142- self.check_wh_taxes(cr, uid, [ref('wh_iva_test02')])
4143- assert False, "An exception should have been raised, unwithholdable taxes are not allowed to reach here!"
4144- except osv.except_osv:
4145- # exception was raised as expected
4146- pass
4147--
4148- 10.5 I check withholding vat is not confirmed
4149- # TODO: Check this test case, it fails. It means that something in the wh_iva_confirmed action is wrong.
4150--
4151- !python {model: account.wh.iva}: |
4152- awi_brw = self.browse(cr,uid,ref('wh_iva_test02'))
4153- assert awi_brw.state == 'draft', "Not the intended state. It should be 'draft' not '%s'"%awi_brw.state
4154--
4155- 10.6 I try to mark it as done
4156--
4157- !workflow {model: account.wh.iva, action: wh_iva_done, ref: wh_iva_test01}
4158--
4159- 10.7 I check withholding vat is not done
4160--
4161- !assert {model: account.wh.iva, id: wh_iva_test01, string: Wh cannot be in done state}:
4162- - state != 'done'
4163
4164=== removed file 'l10n_ve_withholding_iva/test/iva_test_wh_3.yml'
4165--- l10n_ve_withholding_iva/test/iva_test_wh_3.yml 2013-11-15 15:02:56 +0000
4166+++ l10n_ve_withholding_iva/test/iva_test_wh_3.yml 1970-01-01 00:00:00 +0000
4167@@ -1,62 +0,0 @@
4168--
4169- 11. Test not withholdeable iva
4170--
4171- 11.1 I update partner information
4172--
4173- !record {model: res.partner, id: base.res_partner_23}:
4174- wh_iva_agent: True
4175- wh_iva_rate: 75
4176- vat_subjected: True
4177--
4178- 11.2 I generate a withholding vat customer
4179--
4180- !record {model: account.wh.iva, id: wh_iva_test03}:
4181- journal_id: wh_sales_journal
4182- partner_id: base.res_partner_23
4183- account_id: account.a_recv
4184- name: 'IVA wh vat customer Vauxoo test 3'
4185- type: out_invoice
4186- state: draft
4187--
4188- 11.3 I check withholding vat customer
4189--
4190- !python {model: account.wh.iva}: |
4191- self.write(cr,uid,ref('wh_iva_test03'),{'type':'out_invoice'})
4192- awi_brw = self.browse(cr,uid,ref('wh_iva_test03'))
4193- assert awi_brw.type == 'out_invoice', "Not the intended type. It should be 'out_invoice' not '%s'"%awi_brw.type
4194- assert awi_brw.state == 'draft', "Not the intended state. It should be 'draft' not '%s'"%awi_brw.state
4195--
4196- 11.4 Before validating let's add the period
4197--
4198- !python {model: account.wh.iva}: |
4199- import time
4200- ap_obj=self.pool.get('account.period')
4201- period = ap_obj.find(cr, uid, time.strftime('%Y/%m/%d'), {'company_id':ref('base.main_company')})
4202- assert period, 'There aren\'t periods for this date'
4203- self.write(cr, uid, ref("wh_iva_test03"), {'period_id':period[0]})
4204--
4205- 11.5 I check period was updated
4206--
4207- !assert {model: account.wh.iva, id: wh_iva_test01, string: Period was not updated}:
4208- - period_id
4209--
4210- 11.6 I confirm the withholding vat customer
4211--
4212- !workflow {model: account.wh.iva, action: wh_iva_confirmed, ref: wh_iva_test03}
4213--
4214- 11.7 I check withholding vat is not confirmed
4215- # TODO: Check this test case, it fails. It means that something in the wh_iva_confirmed action is wrong.
4216--
4217- !python {model: account.wh.iva}: |
4218- awi_brw = self.browse(cr,uid,ref('wh_iva_test03'))
4219- assert awi_brw.state == 'draft', "Not the intended state. It should be 'draft' not '%s'"%awi_brw.state
4220--
4221- 11.8 I try to mark it as done
4222--
4223- !workflow {model: account.wh.iva, action: wh_iva_done, ref: wh_iva_test01}
4224--
4225- 11.9 I check withholding vat is not done
4226--
4227- !python {model: account.wh.iva}: |
4228- awi_brw = self.browse(cr,uid,ref('wh_iva_test03'))
4229- assert awi_brw.state == 'draft', "Not the intended state. It should be 'draft' not '%s'"%awi_brw.state
4230
4231=== removed file 'l10n_ve_withholding_iva/test/iva_test_wh_4.yml'
4232--- l10n_ve_withholding_iva/test/iva_test_wh_4.yml 2013-11-15 15:02:56 +0000
4233+++ l10n_ve_withholding_iva/test/iva_test_wh_4.yml 1970-01-01 00:00:00 +0000
4234@@ -1,60 +0,0 @@
4235--
4236- 12. Test not withholdeable iva
4237--
4238- 12.1 I update partner information
4239--
4240- !record {model: res.partner, id: base.res_partner_23}:
4241- wh_iva_agent: True
4242- wh_iva_rate: 75
4243- vat_subjected: True
4244--
4245- 12.2 I generate a withholding vat customer
4246--
4247- !record {model: account.wh.iva, id: wh_iva_test04}:
4248- journal_id: wh_sales_journal
4249- partner_id: base.res_partner_23
4250- account_id: account.a_recv
4251- name: 'IVA wh vat customer Vauxoo test 3'
4252- type: out_invoice
4253- state: draft
4254--
4255- 12.3 I check withholding vat customer
4256--
4257- !python {model: account.wh.iva}: |
4258- self.write(cr,uid,ref('wh_iva_test04'),{'type':'out_invoice'})
4259- awi_brw = self.browse(cr,uid,ref('wh_iva_test04'))
4260- assert awi_brw.type == 'out_invoice', "Not the intended type. It should be 'out_invoice' not '%s'"%awi_brw.type
4261- assert awi_brw.state == 'draft', "Not the intended state. It should be 'draft' not '%s'"%awi_brw.state
4262--
4263- 12.4 Before validating let's add the period
4264--
4265- !python {model: account.wh.iva}: |
4266- import time
4267- ap_obj=self.pool.get('account.period')
4268- period = ap_obj.find(cr, uid, time.strftime('%Y/%m/%d'), {'company_id':ref('base.main_company')})
4269- assert period, 'There aren\'t periods for this date'
4270- self.write(cr, uid, ref("wh_iva_test04"), {'period_id':period[0], 'date':'2014/02/02'})
4271--
4272- 12.5 I check period was updated
4273--
4274- !assert {model: account.wh.iva, id: wh_iva_test01, string: Period was not updated}:
4275- - period_id
4276--
4277- 12.6 I confirm the withholding vat customer
4278--
4279- !workflow {model: account.wh.iva, action: wh_iva_confirmed, ref: wh_iva_test04}
4280--
4281- 12.7 I check withholding vat is not confirmed
4282- # TODO: Check this test case, it fails. It means that something in the wh_iva_confirmed action is wrong.
4283--
4284- !assert {model: account.wh.iva, id: wh_iva_test04, string: Could not confirm the wh}:
4285- - state != 'confirmed'
4286--
4287- 12.8 I try to mark it as done
4288--
4289- !workflow {model: account.wh.iva, action: wh_iva_done, ref: wh_iva_test01}
4290--
4291- 12.9 I check withholding vat is not done
4292--
4293- !assert {model: account.wh.iva, id: wh_iva_test01, string: Wh cannot be in done state}:
4294- - state != 'done'
4295
4296=== modified file 'l10n_ve_withholding_iva/test/purchase_invoice_wh_iva.yml'
4297--- l10n_ve_withholding_iva/test/purchase_invoice_wh_iva.yml 2013-12-04 13:24:44 +0000
4298+++ l10n_ve_withholding_iva/test/purchase_invoice_wh_iva.yml 2014-01-08 15:40:54 +0000
4299@@ -39,6 +39,7 @@
4300 -
4301 !record {model: account.invoice, id: purchase_invoice_ret_tax, view: account.invoice_supplier_form}:
4302 nro_ctrl: IVA RET AND NOT RET TAXES
4303+ supplier_invoice_number: IVA RET AND NOT RET TAXES
4304 partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
4305 account_id: account.a_pay
4306 company_id: base.main_company
4307@@ -107,6 +108,7 @@
4308 -
4309 !record {model: account.invoice, id: purchase_invoice_111, view: account.invoice_supplier_form}: &invoice
4310 nro_ctrl: 111-IVA
4311+ supplier_invoice_number: 111-IVA
4312 partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
4313 account_id: account.a_pay
4314 company_id: base.main_company
4315@@ -143,6 +145,7 @@
4316 -
4317 !record {model: account.invoice, id: purchase_invoice_110, view: account.invoice_supplier_form}:
4318 nro_ctrl: 110-IVA
4319+ supplier_invoice_number: 110-IVA
4320 invoice_line:
4321 - invoice_line_tax_id:
4322 - l10n_ve_fiscal_requirements.iva_purchase3
4323@@ -170,6 +173,7 @@
4324 -
4325 !record {model: account.invoice, id: purchase_invoice_011, view: account.invoice_supplier_form}:
4326 nro_ctrl: 011-IVA
4327+ supplier_invoice_number: 011-IVA
4328 partner_id: l10n_ve_fiscal_requirements.f_req_partner_7
4329 <<: *invoice
4330 -
4331@@ -194,6 +198,7 @@
4332 -
4333 !record {model: account.invoice, id: purchase_invoice_010, view: account.invoice_supplier_form}:
4334 nro_ctrl: 010-IVA
4335+ supplier_invoice_number: 010-IVA
4336 partner_id: l10n_ve_fiscal_requirements.f_req_partner_7
4337 invoice_line:
4338 - invoice_line_tax_id:
4339@@ -234,6 +239,7 @@
4340 -
4341 !record {model: account.invoice, id: purchase_invoice_101, view: account.invoice_supplier_form}:
4342 nro_ctrl: 101-IVA
4343+ supplier_invoice_number: 101-IVA
4344 <<: *invoice
4345 -
4346 I change invoice to Open state.
4347@@ -257,6 +263,7 @@
4348 -
4349 !record {model: account.invoice, id: purchase_invoice_100, view: account.invoice_supplier_form}:
4350 nro_ctrl: 100-IVA
4351+ supplier_invoice_number: 100-IVA
4352 invoice_line:
4353 - invoice_line_tax_id:
4354 - l10n_ve_fiscal_requirements.iva_purchase3
4355@@ -284,6 +291,7 @@
4356 -
4357 !record {model: account.invoice, id: purchase_invoice_001, view: account.invoice_supplier_form}:
4358 nro_ctrl: 001-IVA
4359+ supplier_invoice_number: 001-IVA
4360 partner_id: l10n_ve_fiscal_requirements.f_req_partner_7
4361 <<: *invoice
4362 -
4363@@ -308,6 +316,7 @@
4364 -
4365 !record {model: account.invoice, id: purchase_invoice_000, view: account.invoice_supplier_form}:
4366 nro_ctrl: 000-IVA
4367+ supplier_invoice_number: 000-IVA
4368 partner_id: l10n_ve_fiscal_requirements.f_req_partner_7
4369 invoice_line:
4370 - invoice_line_tax_id:
4371@@ -336,6 +345,7 @@
4372 -
4373 !record {model: account.invoice, id: purchase_invoice_00N, view: account.invoice_supplier_form}:
4374 nro_ctrl: 00N-IVA
4375+ supplier_invoice_number: 00N-IVA
4376 partner_id: l10n_ve_fiscal_requirements.f_req_partner_7
4377 invoice_line:
4378 - product_id: product.product_product_4
4379@@ -366,6 +376,7 @@
4380 -
4381 !record {model: account.invoice, id: purchase_invoice_01N, view: account.invoice_supplier_form}:
4382 nro_ctrl: 01N-IVA
4383+ supplier_invoice_number: 01N-IVA
4384 partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
4385 invoice_line:
4386 - product_id: product.product_product_4
4387
4388=== modified file 'l10n_ve_withholding_iva/test/purchase_wh_iva.yml'
4389--- l10n_ve_withholding_iva/test/purchase_wh_iva.yml 2013-12-05 17:33:58 +0000
4390+++ l10n_ve_withholding_iva/test/purchase_wh_iva.yml 2014-01-08 15:40:54 +0000
4391@@ -34,6 +34,7 @@
4392 -
4393 !record {model: account.invoice, id: wh_manual_purchase_awi_invoice}: &manual_purchase_awi_invoice
4394 nro_ctrl: AWI MANUAL PURCHASE INVOICE (WH COMPANY)
4395+ supplier_invoice_number: AWI MANUAL PURCHASE INVOICE (WH COMPANY)
4396 partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
4397 date_invoice: !eval time.strftime('%Y-%m-%d')
4398 company_id: base.main_company
4399@@ -160,7 +161,56 @@
4400 awi_brw = self.browse(cr, uid, awi_id)
4401 assert awi_brw.state == 'confirmed', 'The withholding document is not in confirmed state'
4402 -
4403- 4.3 When the Company is not a withholding agent.
4404+ 4.3 When the withholding document have not withholding lines then it cannot
4405+ be confirm.
4406+-
4407+ I create a supplier withholding document manually.
4408+-
4409+ !record {model: account.wh.iva, id: supplier_no_lines_awi}:
4410+ name: AWI MANUAL NO WH LINES
4411+ <<: *whc_awi_manual_purchase
4412+-
4413+ I check that the withholding document was correctly created.
4414+-
4415+ !assert {model: account.wh.iva, id: supplier_no_lines_awi, string: The withholding document should be of purchase type (in_invoice) and should be in draft state.}:
4416+ - type == 'in_invoice'
4417+ - state == 'draft'
4418+-
4419+ I search the current period and add it to the withholding doc.
4420+-
4421+ !python {model: account.wh.iva}: |
4422+ import time
4423+ awi_id = ref( 'supplier_no_lines_awi' )
4424+ company_id = ref('base.main_company')
4425+ period_obj = self.pool.get('account.period')
4426+ period = period_obj.find(
4427+ cr, uid, time.strftime('%Y/%m/%d'), {'company_id': company_id})
4428+ assert period, 'There aren\'t periods for this date'
4429+ self.write(cr, uid, awi_id, {'period_id':period[0]})
4430+-
4431+ I compute the taxes manually with the button 'Compute Withholding Vat'.
4432+-
4433+ !function {model: account.wh.iva, name: compute_amount_wh, id: supplier_no_lines_awi}:
4434+ - model: account.wh.iva
4435+ eval: "[ref('supplier_no_lines_awi')]"
4436+-
4437+ I try to confirm the supplier withholding document.
4438+-
4439+ !python {model: account.wh.iva}: |
4440+ awi_id = ref('supplier_no_lines_awi')
4441+ # Note: not use of workflow because it can not manage the exception.
4442+ try:
4443+ self.confirm_check(cr, uid, awi_id)
4444+ assert False, 'The withholding document can not be confirmed because has not wh lines associated.'
4445+ except Exception as e:
4446+ pass
4447+-
4448+ I check that the withholding document remains in draft.
4449+-
4450+ !assert {model: account.wh.iva, id: supplier_no_lines_awi, string: The withholding document can not be confirm because it haf no wh lines}:
4451+ - state == 'draft'
4452+-
4453+ 4.4 When the Company is not a withholding agent.
4454 -
4455 I set company as a non-withholding agent.
4456 -
4457@@ -176,6 +226,7 @@
4458 -
4459 !record {model: account.invoice, id: nwh_manual_purchase_awi_invoice}:
4460 nro_ctrl: AWI MANUAL PURCHASE INVOICE (NON-WH COMPANY)
4461+ supplier_invoice_number: AWI MANUAL PURCHASE INVOICE (NON-WH COMPANY)
4462 <<: *manual_purchase_awi_invoice
4463 -
4464 I check that the invoice is of purchase type (in_invoice).
4465
4466=== modified file 'l10n_ve_withholding_iva/test/purchase_wh_iva_sequence.yml'
4467--- l10n_ve_withholding_iva/test/purchase_wh_iva_sequence.yml 2013-12-05 18:30:14 +0000
4468+++ l10n_ve_withholding_iva/test/purchase_wh_iva_sequence.yml 2014-01-08 15:40:54 +0000
4469@@ -41,7 +41,7 @@
4470 -
4471 I check that the supplier that will be use exist.
4472 -
4473- !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The partner used in this test exist}:
4474+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier used in this test exist}:
4475 - id
4476 -
4477 I check that tax the that will be use is a withholding tax.
4478@@ -51,7 +51,7 @@
4479 -
4480 I check that the account that will be use is of payable type.
4481 -
4482- !assert {model: account.account, id: account.a_pay, string: The account is not of receivable type}:
4483+ !assert {model: account.account, id: account.a_pay, string: The account is not of payable type}:
4484 - type == 'payable'
4485 -
4486 5.2 Check that the sequence is set only when the supplier withholding is set to done.
4487@@ -60,6 +60,7 @@
4488 -
4489 !record {model: account.invoice, id: supplier_seq_invoice_1, view: account.invoice_supplier_form}: &supplier_seq_invoice
4490 nro_ctrl: PURCHASE-IVA-SEQ-INVOICE-0001
4491+ supplier_invoice_number: PURCHASE-IVA-SEQ-INVOICE-0001
4492 partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
4493 account_id: account.a_pay
4494 company_id: base.main_company
4495@@ -145,6 +146,7 @@
4496 -
4497 !record {model: account.invoice, id: supplier_seq_invoice_2, view: account.invoice_supplier_form}:
4498 nro_ctrl: PURCHASE-IVA-SEQ-INVOICE-0002
4499+ supplier_invoice_number: PURCHASE-IVA-SEQ-INVOICE-0002
4500 << : *supplier_seq_invoice
4501 -
4502 I check the invoice type, state and have not wh doc.
4503@@ -187,7 +189,7 @@
4504 - wh_iva_id.state == 'confirmed'
4505 - not wh_iva_id.number
4506 -
4507- I set the withholding to done state.
4508+ I change the withholding to done state.
4509 -
4510 !python {model: account.invoice}: |
4511 inv_id = ref( 'supplier_seq_invoice_2' )
4512@@ -211,3 +213,207 @@
4513 awi_brw = self.browse(cr, uid, inv_id).wh_iva_id
4514 assert 'PURCHASE_TEST' in awi_brw.number, 'There was not used the supplier withholding sequence of the demo data. The sequence by type of withholding document is badly used.'
4515 assert '00001000' in awi_brw.number, 'The withholding documents are no creating consecutively'
4516+-
4517+ 5.5 Using the supplier withholding generated in 5.4 I check if I cancel it
4518+ and then I re-used, the withholding number must remains and the sequence too.
4519+ I use two invoices.
4520+-
4521+ I check that the last withholding sequence number was '0001000'
4522+-
4523+ !python {model: account.invoice}: |
4524+ inv_id = ref( 'supplier_seq_invoice_2' )
4525+ awi_brw = self.browse(cr, uid, inv_id).wh_iva_id
4526+ assert '00001000' in awi_brw.number, 'The initial mark for this test is not correctly set, so it can continue'
4527+-
4528+ I update the invoice and withholding journals to be able to cancel entries.
4529+-
4530+ !python {model: account.invoice}: |
4531+ inv_id = ref( 'supplier_seq_invoice_2' )
4532+ journal_obj = self.pool.get( 'account.journal' )
4533+ inv_brw = self.browse(cr, uid, inv_id)
4534+ inv_journal_id = inv_brw.journal_id.id
4535+ wh_journal_id = inv_brw.wh_iva_id.journal_id.id
4536+ journal_obj.write(
4537+ cr, uid, [inv_journal_id, wh_journal_id], {'update_posted': True})
4538+-
4539+ I create a supplier invoice.
4540+-
4541+ !record {model: account.invoice, id: supplier_seq_invoice_3, view: account.invoice_supplier_form}:
4542+ nro_ctrl: PURCHASE-IVA-SEQ-INVOICE-0003
4543+ supplier_invoice_number: PURCHASE-IVA-SEQ-INVOICE-0003
4544+ <<: *supplier_seq_invoice
4545+-
4546+ I check the invoice type, state and have not wh doc.
4547+-
4548+ !assert {model: account.invoice, id: supplier_seq_invoice_3, string: The invoice was not correctly created. It need to be set in draft state, a supplier invoice type (in_invoice) and have not withholding document associaded.}:
4549+ - state == 'draft'
4550+ - type == 'in_invoice'
4551+ - not wh_iva_id
4552+-
4553+ I confirm the invoice to create the withholding document.
4554+-
4555+ !workflow {model: account.invoice, action: invoice_open, ref: supplier_seq_invoice_3}
4556+-
4557+ I check that the invoice is confirmed and it generate a withholding doc.
4558+-
4559+ !assert {model: account.invoice, id: supplier_seq_invoice_3, string: The invoice was not correctly confirm. It need to change to open state (confirmed) and also generate and link a withholding document}:
4560+ - state == 'open'
4561+ - wh_iva_id
4562+-
4563+ I confirm the withholding document
4564+-
4565+ !python {model: account.invoice}: |
4566+ inv_id = ref( 'supplier_seq_invoice_3' )
4567+ inv_brw = self.browse(cr, uid, inv_id)
4568+ awi_id = inv_brw.wh_iva_id.id
4569+ import netsvc
4570+ from openerp.osv import osv
4571+ wf_service = netsvc.LocalService( 'workflow' )
4572+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'wh_iva_confirmed', cr)
4573+-
4574+ I check the withholding is confirm and that the wh number is not set.
4575+-
4576+ !assert {model: account.invoice, id: supplier_seq_invoice_3, string: The withholding was not correctly confirm.}:
4577+ - wh_iva_id.state == 'confirmed'
4578+ - not wh_iva_id.number
4579+-
4580+ I set the withholding to done state.
4581+-
4582+ !python {model: account.invoice}: |
4583+ inv_id = ref( 'supplier_seq_invoice_3' )
4584+ inv_brw = self.browse(cr, uid, inv_id)
4585+ awi_id = inv_brw.wh_iva_id.id
4586+ import netsvc
4587+ from openerp.osv import osv
4588+ wf_service = netsvc.LocalService( 'workflow' )
4589+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'wh_iva_done', cr)
4590+-
4591+ I check the withholding is done and that the wh number is set.
4592+-
4593+ !assert {model: account.invoice, id: supplier_seq_invoice_3, string: The withholding was not correctly done.}:
4594+ - wh_iva_id.state == 'done'
4595+ - wh_iva_id.number
4596+-
4597+ I check if the withholding number use the sequence the consecutive number
4598+ 00001001.
4599+-
4600+ !python {model: account.invoice}: |
4601+ inv_id = ref( 'supplier_seq_invoice_3' )
4602+ awi_brw = self.browse(cr, uid, inv_id).wh_iva_id
4603+ assert '00001001' in awi_brw.number, 'The withholding documents are no creating consecutively ' + awi_brw.number
4604+-
4605+ I cancel the withholding document with sequence 00001001.
4606+-
4607+ !python {model: account.invoice}: |
4608+ inv_id = ref( 'supplier_seq_invoice_3')
4609+ inv_brw = self.browse(cr, uid, inv_id)
4610+ awi_id = inv_brw.wh_iva_id.id
4611+ import netsvc
4612+ from openerp.osv import osv
4613+ wf_service = netsvc.LocalService( 'workflow' )
4614+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'cancel', cr)
4615+ awi_obj = self.pool.get('account.wh.iva')
4616+ awi_brw = awi_obj.browse(cr, uid, awi_id)
4617+ assert awi_brw.state == 'cancel', 'It does not change the withholding state to cancel'
4618+-
4619+ I cancel the withholding document with sequence 00001000, I set it to draft
4620+ and add two invoices.
4621+-
4622+ !python {model: account.wh.iva}: |
4623+ import netsvc
4624+ from openerp.osv import osv
4625+ wf_service = netsvc.LocalService( 'workflow' )
4626+
4627+ invoice_ids = [ref( 'supplier_seq_invoice_2'), ref( 'supplier_seq_invoice_3' )]
4628+ awi_id = self.pool.get( 'account.invoice' ).browse(
4629+ cr, uid, invoice_ids[0]).wh_iva_id.id
4630+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'cancel', cr)
4631+
4632+ awi_brw = self.browse(cr, uid, awi_id)
4633+ assert awi_brw.state == 'cancel', 'It does not change the withholding state to cancel'
4634+ assert not awi_brw.wh_lines, 'when a withholding document have been cancel then all its lines are clean'
4635+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'set_to_draft', cr)
4636+
4637+ awi_brw = self.browse(cr, uid, awi_id)
4638+ assert awi_brw.state == 'draft', 'The withholding document was not reset to draft %s' % (awi_brw.state, )
4639+
4640+ values = {'wh_lines': []}
4641+ for invoice_id in invoice_ids:
4642+ res = self.onchange_partner_id(
4643+ cr, uid, [awi_id], 'out_invoice', awi_brw.partner_id.id)
4644+ values['wh_lines'] += [
4645+ (0, 0, {'invoice_id': invoice_id,
4646+ 'name':'N/A',
4647+ 'wh_iva_rate': awi_brw.partner_id.wh_iva_rate})]
4648+ values['account_id'] = res['value']['account_id']
4649+ self.write(cr, uid, awi_id, values)
4650+-
4651+ I check that the withholding document sequence '00001000' state is draft and
4652+ that the two invoices was added, and also that the withholding number
4653+ remains.
4654+-
4655+ !assert {model: account.invoice, id: supplier_seq_invoice_2, string: )}:
4656+ - wh_iva_id.state == 'draft'
4657+ - wh_iva_id.wh_lines
4658+ - wh_iva_id.number
4659+-
4660+ I check that the re used withholding sequence number remains '0001000'.
4661+-
4662+ !python {model: account.invoice}: |
4663+ inv_id = ref( 'supplier_seq_invoice_2' )
4664+ awi_brw = self.browse(cr, uid, inv_id).wh_iva_id
4665+ assert '00001000' in awi_brw.number, 'The initial mark for this test is not correctly set, so it can continue'
4666+-
4667+ I compute the taxes manually with the button 'Compute Withholding Vat'.
4668+-
4669+ !function {model: account.wh.iva, name: compute_amount_wh}:
4670+ - model: account.invoice
4671+ eval: "[obj(ref('supplier_seq_invoice_2')).wh_iva_id.id]"
4672+-
4673+ I confirm the withholding document
4674+-
4675+ !python {model: account.invoice}: |
4676+ inv_id = ref( 'supplier_seq_invoice_2' )
4677+ inv_brw = self.browse(cr, uid, inv_id)
4678+ awi_id = inv_brw.wh_iva_id.id
4679+ import netsvc
4680+ from openerp.osv import osv
4681+ wf_service = netsvc.LocalService( 'workflow' )
4682+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'wh_iva_confirmed', cr)
4683+-
4684+ I check the withholding is confirm and that the wh number is set.
4685+-
4686+ !assert {model: account.invoice, id: supplier_seq_invoice_2, string: The withholding was not correctly confirm.}:
4687+ - wh_iva_id.state == 'confirmed'
4688+ - wh_iva_id.number
4689+-
4690+ I check that the re used withholding sequence number remains '0001000'.
4691+-
4692+ !python {model: account.invoice}: |
4693+ inv_id = ref( 'supplier_seq_invoice_2' )
4694+ awi_brw = self.browse(cr, uid, inv_id).wh_iva_id
4695+ assert '00001000' in awi_brw.number, 'The initial mark for this test is not correctly set, so it can continue'
4696+-
4697+ I set the withholding to done state.
4698+-
4699+ !python {model: account.invoice}: |
4700+ inv_id = ref( 'supplier_seq_invoice_2' )
4701+ inv_brw = self.browse(cr, uid, inv_id)
4702+ awi_id = inv_brw.wh_iva_id.id
4703+ import netsvc
4704+ from openerp.osv import osv
4705+ wf_service = netsvc.LocalService( 'workflow' )
4706+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'wh_iva_done', cr)
4707+-
4708+ I check the withholding is done and that the wh number is set.
4709+-
4710+ !assert {model: account.invoice, id: supplier_seq_invoice_2, string: The withholding was not correctly done.}:
4711+ - wh_iva_id.state == 'done'
4712+ - wh_iva_id.number
4713+-
4714+ I check that the re used withholding sequence number remains '0001000'.
4715+-
4716+ !python {model: account.invoice}: |
4717+ inv_id = ref( 'supplier_seq_invoice_2' )
4718+ awi_brw = self.browse(cr, uid, inv_id).wh_iva_id
4719+ assert '00001000' in awi_brw.number, 'The initial mark for this test is not correctly set, so it can continue'
4720
4721=== added file 'l10n_ve_withholding_iva/test/purchase_wh_iva_txt.yml'
4722--- l10n_ve_withholding_iva/test/purchase_wh_iva_txt.yml 1970-01-01 00:00:00 +0000
4723+++ l10n_ve_withholding_iva/test/purchase_wh_iva_txt.yml 2014-01-08 15:40:54 +0000
4724@@ -0,0 +1,300 @@
4725+-
4726+ 7. I make test over the txt docuemnts in purchase operations.
4727+-
4728+ 7.1 I configure the enviroment.
4729+-
4730+ I configure the context for purchase operations.
4731+-
4732+ !context
4733+ 'type': 'in_invoice'
4734+-
4735+ I set the company as a withholding agent (because is the only I can create a supplier withholdings).
4736+-
4737+ !record {model: res.partner, id: base.main_partner}:
4738+ wh_iva_agent: True
4739+-
4740+ I check that the company is withholding agent.
4741+-
4742+ !assert {model: res.partner, id: base.main_partner, string: The Company is not a withholding agent}:
4743+ - wh_iva_agent
4744+-
4745+ I check that the supplier that will be use exist.
4746+-
4747+ !assert {model: res.partner, id: l10n_ve_fiscal_requirements.f_req_partner_1, string: The supplier used in this test exist}:
4748+ - id
4749+-
4750+ I check that the tax that will be use is withholdeable.
4751+-
4752+ !assert {model: account.tax, id: l10n_ve_fiscal_requirements.iva_purchase1, string: The tax is not withholdeable}:
4753+ - ret
4754+-
4755+ I check that the account that will be use is payable type.
4756+-
4757+ !assert {model: account.account, id: account.a_pay, string: The account is not of payable type}:
4758+ - type == 'payable'
4759+-
4760+ 7.2 I check that txt document with no txt lines can not be confirm.
4761+-
4762+ I create a txt document.
4763+-
4764+ !record {model: txt.iva, id: supplier_txt_iva_1}:
4765+ #name: auto fll generic
4766+ #period: current.
4767+ date_start: !eval time.strftime('%Y-%m-%d')
4768+ date_end: !eval time.strftime('%Y-%m-%d')
4769+-
4770+ I check that the txt document is in draft state with no txt lines.
4771+-
4772+ !assert {model: txt.iva, id: supplier_txt_iva_1, string: the txt document was not correctly created}:
4773+ - state == 'draft'
4774+ - not txt_ids
4775+-
4776+ I try to confirm the txt document with empty txt lines.
4777+-
4778+ !python {model: txt.iva}: |
4779+ txt_id = ref( 'supplier_txt_iva_1' )
4780+ try:
4781+ self.action_confirm(cr, uid, txt_id)
4782+ assert False, 'The txt document can be confirm when have empty txt lines.'
4783+ except Exception as e:
4784+ pass
4785+-
4786+ I check that the txt document remains in draft state.
4787+-
4788+ !assert {model: txt.iva, id: supplier_txt_iva_1, string: the txt document can not pass to confirm state}:
4789+ - state == 'draft'
4790+-
4791+ 7.3 Using the txt document in 7.2 I check that only done withholding
4792+ documents can be add to a txt document.
4793+-
4794+ I create a supplier invoice.
4795+-
4796+ !record {model: account.invoice, id: supplier_txt_invoice_1, view: account.invoice_supplier_form}: &supplier_txt_invoice
4797+ nro_ctrl: PURCHASE-IVA-TXT-INVOICE-0001
4798+ supplier_invoice_number: PURCHASE-IVA-TXT-INVOICE-0001
4799+ partner_id: l10n_ve_fiscal_requirements.f_req_partner_1
4800+ account_id: account.a_pay
4801+ company_id: base.main_company
4802+ currency_id: base.EUR
4803+ reference_type: none
4804+ invoice_line:
4805+ - product_id: product.product_product_4
4806+ quantity: 3
4807+ uos_id: product.product_uom_unit
4808+ price_unit: 3
4809+ account_id: account.a_pay
4810+ invoice_line_tax_id:
4811+ - l10n_ve_fiscal_requirements.iva_purchase1
4812+-
4813+ I check the invoice type, state and have not wh doc.
4814+-
4815+ !assert {model: account.invoice, id: supplier_txt_invoice_1, string: The invoice was not correctly created. It need to be set in draft state, a supplier invoice type (in_invoice) and have not withholding document associaded.}:
4816+ - state == 'draft'
4817+ - type == 'in_invoice'
4818+ - not wh_iva_id
4819+-
4820+ I confirm the invoice to create the withholding document.
4821+-
4822+ !workflow {model: account.invoice, action: invoice_open, ref: supplier_txt_invoice_1}
4823+-
4824+ I check that the invoice is confirmed and it generate a withholding doc.
4825+-
4826+ !assert {model: account.invoice, id: supplier_txt_invoice_1, string: The invoice was not correctly confirm. It need to change to open state (confirmed) and also generate and link a withholding document}:
4827+ - state == 'open'
4828+ - wh_iva_id
4829+-
4830+ I check that the withholding document state is draft.
4831+-
4832+ !assert {model: account.invoice, id: supplier_txt_invoice_1, string: When creating a supplier withholding via supplier invoice confirmation the state of the withholding document must be draft, and the wh number is unset (they will be set when the withholding is confirmed)}:
4833+ - wh_iva_id.state == 'draft'
4834+-
4835+ I try to add the txt lines by pressing the 'Lines Generate TXT' button.
4836+-
4837+ !function {model: txt.iva, name: action_generate_lines_txt, id: supplier_txt_iva_1}:
4838+ - model: txt.iva
4839+ eval: "[ref('supplier_txt_iva_1')]"
4840+-
4841+ I check that only withholding documents in done state are added.
4842+-
4843+ !python {model: txt.iva}: |
4844+ txt_id = ref( 'supplier_txt_iva_1' )
4845+ txt_brw = self.browse(cr, uid, txt_id)
4846+ for txt_line_brw in txt_brw.txt_ids:
4847+ assert txt_line_brw.voucher_id.state == 'done', 'Error, only can add withholding documents in done state.'
4848+-
4849+ I confirm the withholding document.
4850+-
4851+ !python {model: account.invoice}: |
4852+ inv_id = ref( 'supplier_txt_invoice_1' )
4853+ inv_brw = self.browse(cr, uid, inv_id)
4854+ awi_id = inv_brw.wh_iva_id.id
4855+ import netsvc
4856+ from openerp.osv import osv
4857+ wf_service = netsvc.LocalService( 'workflow' )
4858+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'wh_iva_confirmed', cr)
4859+-
4860+ I check that the withholding document was confirm.
4861+-
4862+ !assert {model: account.invoice, id: supplier_txt_invoice_1, string: The withholding document was not correctly confirm}:
4863+ - wh_iva_id.state == 'confirmed'
4864+-
4865+ I try to add the txt lines by pressing the 'Lines Generate TXT' button.
4866+-
4867+ !function {model: txt.iva, name: action_generate_lines_txt, id: supplier_txt_iva_1}:
4868+ - model: txt.iva
4869+ eval: "[ref('supplier_txt_iva_1')]"
4870+-
4871+ I check that only withholding documents in done state are added.
4872+-
4873+ !python {model: txt.iva}: |
4874+ txt_id = ref( 'supplier_txt_iva_1' )
4875+ txt_brw = self.browse(cr, uid, txt_id)
4876+ for txt_line_brw in txt_brw.txt_ids:
4877+ assert txt_line_brw.voucher_id.state == 'done', 'Error, only can add withholding documents in done state.'
4878+-
4879+ I change the withholding document to done.
4880+-
4881+ !python {model: account.invoice}: |
4882+ inv_id = ref( 'supplier_txt_invoice_1' )
4883+ inv_brw = self.browse(cr, uid, inv_id)
4884+ awi_id = inv_brw.wh_iva_id.id
4885+ import netsvc
4886+ from openerp.osv import osv
4887+ wf_service = netsvc.LocalService( 'workflow' )
4888+ wf_service.trg_validate(uid, 'account.wh.iva', awi_id, 'wh_iva_done', cr)
4889+-
4890+ I check that the withholding document was set to done.
4891+-
4892+ !assert {model: account.invoice, id: supplier_txt_invoice_1, string: The withholding document was not correctly confirm}:
4893+ - wh_iva_id.state == 'done'
4894+-
4895+ I try to add the txt lines by pressing the 'Lines Generate TXT' button.
4896+-
4897+ !function {model: txt.iva, name: action_generate_lines_txt, id: supplier_txt_iva_1}:
4898+ - model: txt.iva
4899+ eval: "[ref('supplier_txt_iva_1')]"
4900+-
4901+ I check that only withholding documents in done state are added.
4902+-
4903+ !python {model: txt.iva}: |
4904+ txt_id = ref( 'supplier_txt_iva_1' )
4905+ txt_brw = self.browse(cr, uid, txt_id)
4906+ for txt_line_brw in txt_brw.txt_ids:
4907+ assert txt_line_brw.voucher_id.state == 'done', 'Error, only can add withholding documents in done state.'
4908+-
4909+ I check that the txt lines where added.
4910+-
4911+ !assert {model: txt.iva, id: supplier_txt_iva_1, string: the txt lines were not added}:
4912+ - txt_ids
4913+-
4914+ 7.4 I check that a withholding document can be cancel only when the txt
4915+ document associated are in draft state.
4916+-
4917+ I check that the txt document is in draft state.
4918+-
4919+ !assert {model: txt.iva, id: supplier_txt_iva_1, string: the txt document is not in draft state}:
4920+ - state == 'draft'
4921+-
4922+ I confirm the txt document.
4923+-
4924+ !function {model: txt.iva, name: action_confirm, ref: supplier_txt_iva_1}:
4925+ - model: txt.iva
4926+ eval: "[ref('supplier_txt_iva_1')]"
4927+-
4928+ I check that the txt document is confirmed.
4929+-
4930+ !assert {model: txt.iva, id: supplier_txt_iva_1, string: the txt document is not in confirmed state}:
4931+ - state == 'confirmed'
4932+-
4933+ I update the invoice and withholding journals to be able to cancel entries.
4934+-
4935+ !python {model: account.invoice}: |
4936+ inv_id = ref( 'supplier_txt_invoice_1' )
4937+ journal_obj = self.pool.get( 'account.journal' )
4938+ inv_brw = self.browse(cr, uid, inv_id)
4939+ inv_journal_id = inv_brw.journal_id.id
4940+ wh_journal_id = inv_brw.wh_iva_id.journal_id.id
4941+ journal_obj.write(
4942+ cr, uid, [inv_journal_id, wh_journal_id], {'update_posted': True})
4943+-
4944+ I try to cancel the withholding document.
4945+-
4946+ !python {model: account.wh.iva}: |
4947+ inv_id = ref( 'supplier_txt_invoice_1')
4948+ inv_brw = self.pool.get('account.invoice').browse(cr, uid, inv_id)
4949+ awi_id = inv_brw.wh_iva_id.id
4950+ # Note: not use of workflow because it can not manage the exception.
4951+ try:
4952+ self.cancel_check(cr, uid, awi_id)
4953+ assert False, 'The withholding document can not change to cancel state. because has a txt document associated in confirmed state.'
4954+
4955+ self.action_cancel(cr, uid, awi_id)
4956+ except Exception as e:
4957+ pass
4958+-
4959+ I check that the wihholding document remains in done state.
4960+-
4961+ !assert {model: account.invoice, id: supplier_txt_invoice_1, string: The withholding document can not be cancel}:
4962+ - wh_iva_id.state == 'done'
4963+-
4964+ I change the txt document to done state.
4965+-
4966+ !function {model: txt.iva, name: action_done, ref: supplier_txt_iva_1}:
4967+ - model: txt.iva
4968+ eval: "[ref('supplier_txt_iva_1')]"
4969+-
4970+ I check that the txt document is in done state.
4971+-
4972+ !assert {model: txt.iva, id: supplier_txt_iva_1, string: the txt document is not in confirmed state}:
4973+ - state == 'done'
4974+-
4975+ I try to cancel the withholding document.
4976+-
4977+ !python {model: account.wh.iva}: |
4978+ inv_id = ref( 'supplier_txt_invoice_1')
4979+ inv_brw = self.pool.get('account.invoice').browse(cr, uid, inv_id)
4980+ awi_id = inv_brw.wh_iva_id.id
4981+ # Note: not use of workflow because it can not manage the exception.
4982+ try:
4983+ self.cancel_check(cr, uid, awi_id)
4984+ assert False, 'The withholding document can not change to cancel state. because has a txt document associated with done state.'
4985+ self.action_cancel(cr, uid, awi_id)
4986+ except Exception as e:
4987+ pass
4988+-
4989+ I check that the wihholding document remains in done state.
4990+-
4991+ !assert {model: account.invoice, id: supplier_txt_invoice_1, string: The withholding document can not be cancel}:
4992+ - wh_iva_id.state == 'done'
4993+-
4994+ I change the txt document to draft state.
4995+-
4996+ !function {model: txt.iva, name: action_anular, ref: supplier_txt_iva_1}:
4997+ - model: txt.iva
4998+ eval: "[ref('supplier_txt_iva_1')]"
4999+-
5000+ I check that the txt document is in draft state.
The diff has been truncated for viewing.