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
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 15:20:30 +0000
4@@ -238,27 +238,61 @@
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+ else:
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+
48+ def validate_wh_income_done(self, cr, uid, ids, context=None):
49+ """
50+ Method that check if wh income is validated in invoice refund.
51+
52+ return: True: the wh income is validated.
53+ False: the wh income is not validated.
54+ """
55+ inv_obj = self.pool.get('account.invoice')
56+ for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context):
57+ if inv.type in ('out_invoice', 'out_refund') and not inv.wh_iva_id:
58+ riva = True
59 else:
60- riva = inv.partner_id.wh_iva_agent
61- if riva:
62 riva = inv.wh_iva_id and inv.wh_iva_id.state in ('done') and True or False
63 if not riva:
64- raise osv.except_osv(_('Wh IVA validated !'), \
65- _('found a withholding IVA that is not validated!'))
66+ raise osv.except_osv(_('Error !'), \
67+ _('The withholding VAT "%s" is not validated!' % inv.wh_iva_id.code ))
68 return False
69
70 def invoice_refund(self, cr, uid, ids, context=None):
71- self.validate_withholding(cr, uid, ids, context=context)
72+ self.validate_total_payment_inv(cr, uid, ids, context=context)
73+ self.validate_wh_iva_done(cr, uid, ids, context=context)
74+ self.validate_wh_income_done(cr, uid, ids, context=context)
75 data_refund = self.read(cr, uid, ids, [],context=context)[0]['filter_refund']
76 return self.compute_refund(cr, uid, ids, data_refund, context=context)
77
78
79=== modified file 'l10n_ve_withholding_iva/model/wh_iva.py'
80--- l10n_ve_withholding_iva/model/wh_iva.py 2012-01-19 01:29:02 +0000
81+++ l10n_ve_withholding_iva/model/wh_iva.py 2012-01-19 15:20:30 +0000
82@@ -300,6 +300,21 @@
83 raise osv.except_osv(_('Invoices with Missing Withheld Taxes!'),note)
84 return True
85
86+ def write_wh_invoices(self, cr, uid, ids, context=None):
87+ """
88+ Method that writes the wh id in invoices.
89+
90+ Return: True: write successfully.
91+ False: write unsuccessfully.
92+ """
93+ inv_obj = self.pool.get('account.invoice')
94+ obj = self.browse(cr, uid, ids[0])
95+ if obj.type in ('out_invoice', 'out_refund'):
96+ for wh_line in obj.wh_lines:
97+ if not inv_obj.write(cr,uid,[wh_line.invoice_id.id],{'wh_iva_id':obj.id}):
98+ return False
99+ return True
100+
101 def _check_partner(self, cr, uid, ids, context={}):
102 agt = False
103 obj = self.browse(cr, uid, ids[0])
104
105=== modified file 'l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml'
106--- l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2012-01-03 15:23:32 +0000
107+++ l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2012-01-19 15:20:30 +0000
108@@ -34,7 +34,7 @@
109 <record id="trans_draft_done" model="workflow.transition">
110 <field name="act_from" ref="act_draft"/>
111 <field name="act_to" ref="act_confirmed"/>
112- <field name="condition">check_vat_wh() and check_wh_taxes()</field>
113+ <field name="condition">check_vat_wh() and check_wh_taxes() and write_wh_invoices()</field>
114 <field name="signal">wh_iva_confirmed</field>
115 </record>
116