Merge lp:~vxkikevx/openerp-venezuela-localization/luiseev-wh_iva-fiscal_requirement into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk

Proposed by Luis Escobar V. (Vauxoo)
Status: Rejected
Rejected by: Gabriela Quilarque
Proposed branch: lp:~vxkikevx/openerp-venezuela-localization/luiseev-wh_iva-fiscal_requirement
Merge into: lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
Diff against target: 115 lines (+62/-13)
3 files modified
l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py (+46/-12)
l10n_ve_withholding_iva/model/wh_iva.py (+15/-0)
l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml (+1/-1)
To merge this branch: bzr merge lp:~vxkikevx/openerp-venezuela-localization/luiseev-wh_iva-fiscal_requirement
Reviewer Review Type Date Requested Status
Gabriela Quilarque Pending
Review via email: mp+89266@code.launchpad.net

Description of the change

[IMP] add methods to validate invoice refund.
[FIX] add method to write wh vat id in sale invoices when confirm.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py'
--- l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2012-01-18 20:30:13 +0000
+++ l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2012-01-19 15:20:30 +0000
@@ -238,27 +238,61 @@
238 result['domain'] = invoice_domain238 result['domain'] = invoice_domain
239 return result239 return result
240240
241 def validate_withholding(self, cr, uid, ids, context=None):241 def validate_total_payment_inv(self, cr, uid, ids, context=None):
242 inv_obj = self.pool.get('account.invoice')242 """
243 for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):243 Method that validate if invoice is totally paid.
244 riva = True244
245 if inv.type in ('in_invoice','in_refund'):245 return: True: if invoice is paid.
246 False: if invoice is not paid.
247 """
248 inv_obj = self.pool.get('account.invoice')
249 for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
250 if inv.reconciled:
251 raise osv.except_osv(_('Invoice Paid!'), \
252 _('The invoice refund can not be procesed because invoice "%s" was paid!' % inv.number))
253 else:
254 return True
255
256 def validate_wh_iva_done(self, cr, uid, ids, context=None):
257 """
258 Method that check if wh vat is validated in invoice refund.
259
260 return: True: the wh vat is validated.
261 False: the wh vat is not validated.
262 """
263 inv_obj = self.pool.get('account.invoice')
264 for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
265 if inv.type in ('out_invoice', 'out_refund') and not inv.islr_wh_doc_id:
266 rislr = True
267 else:
246 rislr = inv.islr_wh_doc_id and inv.islr_wh_doc_id.state in ('done') and True or False268 rislr = inv.islr_wh_doc_id and inv.islr_wh_doc_id.state in ('done') and True or False
247 if not rislr:269 if not rislr:
248 raise osv.except_osv(_('Wh income validated !'), \270 raise osv.except_osv(_('Error !'), \
249 _('found a withholding income that is not validated!'))271 _('The withholding income "%s" is not validated!' % inv.islr_wh_doc_id.code ))
250 return False272 return False
273
274 def validate_wh_income_done(self, cr, uid, ids, context=None):
275 """
276 Method that check if wh income is validated in invoice refund.
277
278 return: True: the wh income is validated.
279 False: the wh income is not validated.
280 """
281 inv_obj = self.pool.get('account.invoice')
282 for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
283 if inv.type in ('out_invoice', 'out_refund') and not inv.wh_iva_id:
284 riva = True
251 else:285 else:
252 riva = inv.partner_id.wh_iva_agent
253 if riva:
254 riva = inv.wh_iva_id and inv.wh_iva_id.state in ('done') and True or False286 riva = inv.wh_iva_id and inv.wh_iva_id.state in ('done') and True or False
255 if not riva:287 if not riva:
256 raise osv.except_osv(_('Wh IVA validated !'), \288 raise osv.except_osv(_('Error !'), \
257 _('found a withholding IVA that is not validated!'))289 _('The withholding VAT "%s" is not validated!' % inv.wh_iva_id.code ))
258 return False290 return False
259291
260 def invoice_refund(self, cr, uid, ids, context=None):292 def invoice_refund(self, cr, uid, ids, context=None):
261 self.validate_withholding(cr, uid, ids, context=context)293 self.validate_total_payment_inv(cr, uid, ids, context=context)
294 self.validate_wh_iva_done(cr, uid, ids, context=context)
295 self.validate_wh_income_done(cr, uid, ids, context=context)
262 data_refund = self.read(cr, uid, ids, [],context=context)[0]['filter_refund']296 data_refund = self.read(cr, uid, ids, [],context=context)[0]['filter_refund']
263 return self.compute_refund(cr, uid, ids, data_refund, context=context)297 return self.compute_refund(cr, uid, ids, data_refund, context=context)
264298
265299
=== modified file 'l10n_ve_withholding_iva/model/wh_iva.py'
--- l10n_ve_withholding_iva/model/wh_iva.py 2012-01-19 01:29:02 +0000
+++ l10n_ve_withholding_iva/model/wh_iva.py 2012-01-19 15:20:30 +0000
@@ -300,6 +300,21 @@
300 raise osv.except_osv(_('Invoices with Missing Withheld Taxes!'),note)300 raise osv.except_osv(_('Invoices with Missing Withheld Taxes!'),note)
301 return True301 return True
302 302
303 def write_wh_invoices(self, cr, uid, ids, context=None):
304 """
305 Method that writes the wh id in invoices.
306
307 Return: True: write successfully.
308 False: write unsuccessfully.
309 """
310 inv_obj = self.pool.get('account.invoice')
311 obj = self.browse(cr, uid, ids[0])
312 if obj.type in ('out_invoice', 'out_refund'):
313 for wh_line in obj.wh_lines:
314 if not inv_obj.write(cr,uid,[wh_line.invoice_id.id],{'wh_iva_id':obj.id}):
315 return False
316 return True
317
303 def _check_partner(self, cr, uid, ids, context={}):318 def _check_partner(self, cr, uid, ids, context={}):
304 agt = False319 agt = False
305 obj = self.browse(cr, uid, ids[0])320 obj = self.browse(cr, uid, ids[0])
306321
=== modified file 'l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml'
--- l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2012-01-03 15:23:32 +0000
+++ l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2012-01-19 15:20:30 +0000
@@ -34,7 +34,7 @@
34 <record id="trans_draft_done" model="workflow.transition">34 <record id="trans_draft_done" model="workflow.transition">
35 <field name="act_from" ref="act_draft"/>35 <field name="act_from" ref="act_draft"/>
36 <field name="act_to" ref="act_confirmed"/>36 <field name="act_to" ref="act_confirmed"/>
37 <field name="condition">check_vat_wh() and check_wh_taxes()</field>37 <field name="condition">check_vat_wh() and check_wh_taxes() and write_wh_invoices()</field>
38 <field name="signal">wh_iva_confirmed</field>38 <field name="signal">wh_iva_confirmed</field>
39 </record>39 </record>
4040