Merge lp:~vauxoo/openerp-venezuela-localization/hbto_bug933809 into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk

Proposed by hbto [Vauxoo] http://www.vauxoo.com
Status: Merged
Merged at revision: 621
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/hbto_bug933809
Merge into: lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
Diff against target: 89 lines (+50/-2)
3 files modified
l10n_ve_withholding/account.py (+26/-1)
l10n_ve_withholding_iva/model/invoice.py (+23/-0)
l10n_ve_withholding_iva/workflow/account_workflow.xml (+1/-1)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/hbto_bug933809
Reviewer Review Type Date Requested Status
Gabriela Quilarque Pending
Nhomar - Vauxoo Pending
Review via email: mp+93533@code.launchpad.net

Description of the change

URGENT
This merge should be immediately applied
please, refer to bug description, where you
can find the needed info to test the right
behavior to this patch.
URGENTE
Este merge se deberia aplicar de inmediato
por favor dirijase a la descripcion del bug
donde podra encontrar la informacion necesaria
para probar el comportamiento adecuado de este
parche.

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_withholding/account.py'
2--- l10n_ve_withholding/account.py 2012-01-26 20:23:30 +0000
3+++ l10n_ve_withholding/account.py 2012-02-17 05:42:26 +0000
4@@ -24,7 +24,7 @@
5 ################################################################################
6
7 from osv import fields, osv
8-
9+import time
10
11 class account_journal(osv.osv):
12 _inherit = 'account.journal'
13@@ -39,4 +39,29 @@
14
15 account_journal()
16
17+class account_period(osv.osv):
18+ _inherit = "account.period"
19+
20+ def find_fortnight(self, cr, uid, dt=None, context=None):
21+ '''
22+ This Function returns a tuple composed of
23+ *) period for the asked dt (int)
24+ *) fortnight for the asked dt (boolean):
25+ -) False: for the 1st. fortnight
26+ -) True: for the 2nd. fortnight.
27+ Example:
28+ (3,True) => a period whose id is 3 in the second fortnight
29+ '''
30+ if context is None: context = {}
31+ if not dt:
32+ dt = time.strftime('%Y-%m-%d')
33+ period_ids = self.find(cr,uid,dt=dt,context=context)
34+ period_ids = self.search(cr,uid,[('special','=',False),('id','in',period_ids)])
35+ if not period_ids:
36+ raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create a fiscal year.')%dt)
37+
38+ fortnight= False if int(dt.split('-')[2]) <= 15 else True
39+ return (period_ids[0],fortnight)
40+account_period()
41+
42 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
43
44=== modified file 'l10n_ve_withholding_iva/model/invoice.py'
45--- l10n_ve_withholding_iva/model/invoice.py 2012-02-06 19:05:01 +0000
46+++ l10n_ve_withholding_iva/model/invoice.py 2012-02-17 05:42:26 +0000
47@@ -230,6 +230,29 @@
48 context={}
49 return any([line.tax_id.ret for line in self.browse(cr, uid, ids[0], context=context).tax_line])
50
51+ def check_withholdable(self, cr, uid, ids, context=None):
52+ '''
53+ This will test for Refund invoice trying to find out
54+ if its regarding parent is in the same fortnight.
55+
56+ return True if invoice is type 'in_invoice'
57+ return True if invoice is type 'in_refund' and parent_id invoice
58+ are both in the same fortnight.
59+ return False otherwise
60+ '''
61+ per_obj = self.pool.get('account.period')
62+ if context is None:
63+ context={}
64+ inv_brw = self.browse(cr,uid,ids[0],context=context)
65+ if inv_brw.type == 'in_invoice':
66+ return True
67+ if inv_brw.type == 'in_refund' and inv_brw.parent_id:
68+ dt_refund = inv_brw.date_invoice or time.strftime('%Y-%m-%d')
69+ dt_invoice = inv_brw.parent_id.date_invoice
70+ return per_obj.find_fortnight(cr, uid, dt=dt_refund, context=context) == \
71+ per_obj.find_fortnight(cr, uid, dt=dt_invoice, context=context)
72+ return False
73+
74 def check_wh_apply(self, cr, uid, ids, context=None):
75 if context is None:
76 context={}
77
78=== modified file 'l10n_ve_withholding_iva/workflow/account_workflow.xml'
79--- l10n_ve_withholding_iva/workflow/account_workflow.xml 2012-01-25 16:57:07 +0000
80+++ l10n_ve_withholding_iva/workflow/account_workflow.xml 2012-02-17 05:42:26 +0000
81@@ -31,7 +31,7 @@
82 <record id="trans_wh_router_wh_vat" model="workflow.transition">
83 <field name="act_from" ref="l10n_ve_withholding.act_wh_router"/>
84 <field name="act_to" ref="act_withold_vat"/>
85- <field name="condition">check_wh_apply()</field>
86+ <field name="condition">check_wh_apply() and check_withholdable()</field>
87 <field name="signal"></field>
88 </record>
89 <!-- From Withholdings to paid-->