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