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: Merged
Merged at revision: 552
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: 117 lines (+64/-13)
3 files modified
l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py (+48/-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+89280@code.launchpad.net

Description of the change

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

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py'
2--- l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2012-01-18 20:30:13 +0000
3+++ l10n_ve_fiscal_requirements/wizard/account_invoice_refund.py 2012-01-19 16:13:25 +0000
4@@ -238,27 +238,63 @@
5 result['domain'] = invoice_domain
6 return result
7
8- def validate_withholding(self, cr, uid, ids, context=None):
9- inv_obj = self.pool.get('account.invoice')
10- for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
11- riva = True
12- if inv.type in ('in_invoice','in_refund'):
13+ def validate_total_payment_inv(self, cr, uid, ids, context=None):
14+ """
15+ Method that validate if invoice is totally paid.
16+
17+ return: True: if invoice is paid.
18+ False: if invoice is not paid.
19+ """
20+ inv_obj = self.pool.get('account.invoice')
21+ for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
22+ if inv.reconciled:
23+ raise osv.except_osv(_('Invoice Paid!'), \
24+ _('The invoice refund can not be procesed because invoice "%s" was paid!' % inv.number))
25+ return False
26+ return True
27+
28+ def validate_wh_iva_done(self, cr, uid, ids, context=None):
29+ """
30+ Method that check if wh vat is validated in invoice refund.
31+
32+ return: True: the wh vat is validated.
33+ False: the wh vat is not validated.
34+ """
35+ inv_obj = self.pool.get('account.invoice')
36+ for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
37+ if inv.type in ('out_invoice', 'out_refund') and not inv.islr_wh_doc_id:
38+ rislr = True
39+ else:
40 rislr = inv.islr_wh_doc_id and inv.islr_wh_doc_id.state in ('done') and True or False
41 if not rislr:
42- raise osv.except_osv(_('Wh income validated !'), \
43- _('found a withholding income that is not validated!'))
44+ raise osv.except_osv(_('Error !'), \
45+ _('The withholding income "%s" is not validated!' % inv.islr_wh_doc_id.code ))
46 return False
47+ return True
48+
49+ def validate_wh_income_done(self, cr, uid, ids, context=None):
50+ """
51+ Method that check if wh income is validated in invoice refund.
52+
53+ return: True: the wh income is validated.
54+ False: the wh income is not validated.
55+ """
56+ inv_obj = self.pool.get('account.invoice')
57+ for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
58+ if inv.type in ('out_invoice', 'out_refund') and not inv.wh_iva_id:
59+ riva = True
60 else:
61- riva = inv.partner_id.wh_iva_agent
62- if riva:
63 riva = inv.wh_iva_id and inv.wh_iva_id.state in ('done') and True or False
64 if not riva:
65- raise osv.except_osv(_('Wh IVA validated !'), \
66- _('found a withholding IVA that is not validated!'))
67+ raise osv.except_osv(_('Error !'), \
68+ _('The withholding VAT "%s" is not validated!' % inv.wh_iva_id.code ))
69 return False
70+ return True
71
72 def invoice_refund(self, cr, uid, ids, context=None):
73- self.validate_withholding(cr, uid, ids, context=context)
74+ self.validate_total_payment_inv(cr, uid, ids, context=context)
75+ self.validate_wh_iva_done(cr, uid, ids, context=context)
76+ self.validate_wh_income_done(cr, uid, ids, context=context)
77 data_refund = self.read(cr, uid, ids, [],context=context)[0]['filter_refund']
78 return self.compute_refund(cr, uid, ids, data_refund, context=context)
79
80
81=== modified file 'l10n_ve_withholding_iva/model/wh_iva.py'
82--- l10n_ve_withholding_iva/model/wh_iva.py 2012-01-19 01:29:02 +0000
83+++ l10n_ve_withholding_iva/model/wh_iva.py 2012-01-19 16:13:25 +0000
84@@ -300,6 +300,21 @@
85 raise osv.except_osv(_('Invoices with Missing Withheld Taxes!'),note)
86 return True
87
88+ def write_wh_invoices(self, cr, uid, ids, context=None):
89+ """
90+ Method that writes the wh vat id in sale invoices.
91+
92+ Return: True: write successfully.
93+ False: write unsuccessfully.
94+ """
95+ inv_obj = self.pool.get('account.invoice')
96+ obj = self.browse(cr, uid, ids[0])
97+ if obj.type in ('out_invoice', 'out_refund'):
98+ for wh_line in obj.wh_lines:
99+ if not inv_obj.write(cr,uid,[wh_line.invoice_id.id],{'wh_iva_id':obj.id}):
100+ return False
101+ return True
102+
103 def _check_partner(self, cr, uid, ids, context={}):
104 agt = False
105 obj = self.browse(cr, uid, ids[0])
106
107=== modified file 'l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml'
108--- l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2012-01-03 15:23:32 +0000
109+++ l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2012-01-19 16:13:25 +0000
110@@ -34,7 +34,7 @@
111 <record id="trans_draft_done" model="workflow.transition">
112 <field name="act_from" ref="act_draft"/>
113 <field name="act_to" ref="act_confirmed"/>
114- <field name="condition">check_vat_wh() and check_wh_taxes()</field>
115+ <field name="condition">check_vat_wh() and check_wh_taxes() and write_wh_invoices()</field>
116 <field name="signal">wh_iva_confirmed</field>
117 </record>
118