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

Proposed by hbto [Vauxoo] http://www.vauxoo.com
Status: Rejected
Rejected by: hbto [Vauxoo] http://www.vauxoo.com
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/hbto_wh_iva
Merge into: lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
Prerequisite: lp:~vauxoo/openerp-venezuela-localization/hbto_wh_iva_restructured
Diff against target: 1076 lines (+562/-208) (has conflicts)
9 files modified
l10n_ve_withholding/invoice.py (+22/-17)
l10n_ve_withholding_iva/model/__init__.py (+34/-0)
l10n_ve_withholding_iva/model/account.py (+19/-3)
l10n_ve_withholding_iva/model/invoice.py (+39/-6)
l10n_ve_withholding_iva/model/wh_iva.py (+317/-137)
l10n_ve_withholding_iva/report/wittholding_vat.py (+67/-13)
l10n_ve_withholding_iva/view/account_view.xml (+7/-3)
l10n_ve_withholding_iva/view/wh_iva_view.xml (+48/-21)
l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml (+9/-8)
Conflict adding file l10n_ve_withholding_iva/model.  Moved existing file to l10n_ve_withholding_iva/model.moved.
Path conflict: l10n_ve_withholding_iva/model.moved/account.py / l10n_ve_withholding_iva/model/account.py
Path conflict: l10n_ve_withholding_iva/model.moved/generate_txt.py / l10n_ve_withholding_iva/model/generate_txt.py
Path conflict: l10n_ve_withholding_iva/model.moved/installer.py / l10n_ve_withholding_iva/model/installer.py
Path conflict: l10n_ve_withholding_iva/model.moved/invoice.py / l10n_ve_withholding_iva/model/invoice.py
Path conflict: l10n_ve_withholding_iva/model.moved/partner.py / l10n_ve_withholding_iva/model/partner.py
Path conflict: l10n_ve_withholding_iva/model.moved/wh_iva.py / l10n_ve_withholding_iva/model/wh_iva.py
Conflict adding file l10n_ve_withholding_iva/view.  Moved existing file to l10n_ve_withholding_iva/view.moved.
Path conflict: l10n_ve_withholding_iva/view.moved/account_invoice_view.xml / l10n_ve_withholding_iva/view/account_invoice_view.xml
Path conflict: l10n_ve_withholding_iva/view.moved/account_view.xml / l10n_ve_withholding_iva/view/account_view.xml
Path conflict: l10n_ve_withholding_iva/view.moved/generate_txt_view.xml / l10n_ve_withholding_iva/view/generate_txt_view.xml
Path conflict: l10n_ve_withholding_iva/view.moved/partner_view.xml / l10n_ve_withholding_iva/view/partner_view.xml
Path conflict: l10n_ve_withholding_iva/view.moved/wh_iva_view.xml / l10n_ve_withholding_iva/view/wh_iva_view.xml
Conflict adding files to l10n_ve_withholding_iva/wizard.  Created directory.
Conflict because l10n_ve_withholding_iva/wizard is not versioned, but has versioned children.  Versioned directory.
Conflict adding file l10n_ve_withholding_iva/wizard.  Moved existing file to l10n_ve_withholding_iva/wizard.moved.
Path conflict: l10n_ve_withholding_iva/wizard.moved/l10n_ve_withholding_iva_installer.xml / l10n_ve_withholding_iva/wizard/l10n_ve_withholding_iva_installer.xml
Conflict adding file l10n_ve_withholding_iva/workflow.  Moved existing file to l10n_ve_withholding_iva/workflow.moved.
Path conflict: l10n_ve_withholding_iva/workflow.moved/account_workflow.xml / l10n_ve_withholding_iva/workflow/account_workflow.xml
Path conflict: l10n_ve_withholding_iva/workflow.moved/wh_iva_workflow.xml / l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/hbto_wh_iva
Reviewer Review Type Date Requested Status
Nhomar - Vauxoo Pending
Review via email: mp+86642@code.launchpad.net

This proposal supersedes a proposal from 2011-12-21.

Description of the change

Propuesta de merge para modulo de Retencion IVA tanto para clientes como proveedores,

la propuesta de merge tiene por el momento la finalidad de ir verificando si existe

algun conflicto con la version que actualmente se encuentra al aire.

To post a comment you must log in.
494. By hbto [Vauxoo] http://www.vauxoo.com

[FIX] Minor changes in order to avoid conflict in merge proposal

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_withholding/invoice.py'
2--- l10n_ve_withholding/invoice.py 2011-10-30 22:07:10 +0000
3+++ l10n_ve_withholding/invoice.py 2011-12-28 02:13:23 +0000
4@@ -31,11 +31,19 @@
5
6 class account_invoice(osv.osv):
7 _inherit = 'account.invoice'
8-
9+
10+
11+ def _get_move_lines(self, cr, uid, ids, to_wh, period_id,
12+ pay_journal_id, writeoff_acc_id,
13+ writeoff_period_id, writeoff_journal_id, date,
14+ name, context=None):
15+ if context is None: context = {}
16+ return []
17+
18 def ret_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id,
19 period_id, pay_journal_id, writeoff_acc_id,
20 writeoff_period_id, writeoff_journal_id, date,
21- name, context=None):
22+ name, to_wh, context=None):
23 if context is None:
24 context = {}
25 #TODO check if we can use different period for payment and the writeoff line
26@@ -53,21 +61,18 @@
27 'ref':invoice.number,
28 'date': date,
29 'currency_id': False,
30- }
31- l2 = {
32- 'debit': direction * pay_amount<0 and - direction * pay_amount,
33- 'credit': direction * pay_amount>0 and direction * pay_amount,
34- 'account_id': pay_account_id,
35- 'partner_id': invoice.partner_id.id,
36- 'ref':invoice.number,
37- 'date': date,
38- 'currency_id': False,
39- }
40-
41- l1['name'] = name
42- l2['name'] = name
43-
44- lines = [(0, 0, l1), (0, 0, l2)]
45+ 'name':name
46+ }
47+ lines = [(0, 0, l1)]
48+
49+ l2 = self._get_move_lines(cr, uid, ids, to_wh, period_id,
50+ pay_journal_id, writeoff_acc_id,
51+ writeoff_period_id, writeoff_journal_id, date,
52+ name, context=context)
53+ if not l2:
54+ raise osv.except_osv(_('Warning !'), _('No accounting moves were created.\n Please, Check if there are Taxes/Concepts to withhold in the Invoices!'))
55+ lines += l2
56+
57 move = {'ref': invoice.number, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
58 move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
59
60
61=== added file 'l10n_ve_withholding_iva/files/IVA_LIBROS.pdf'
62Binary files l10n_ve_withholding_iva/files/IVA_LIBROS.pdf 1970-01-01 00:00:00 +0000 and l10n_ve_withholding_iva/files/IVA_LIBROS.pdf 2011-12-28 02:13:23 +0000 differ
63=== added directory 'l10n_ve_withholding_iva/model'
64=== renamed directory 'l10n_ve_withholding_iva/model' => 'l10n_ve_withholding_iva/model.moved'
65=== added file 'l10n_ve_withholding_iva/model/__init__.py'
66--- l10n_ve_withholding_iva/model/__init__.py 1970-01-01 00:00:00 +0000
67+++ l10n_ve_withholding_iva/model/__init__.py 2011-12-28 02:13:23 +0000
68@@ -0,0 +1,34 @@
69+#!/usr/bin/python
70+# -*- encoding: utf-8 -*-
71+###########################################################################
72+# Module Writen to OpenERP, Open Source Management Solution
73+# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
74+# All Rights Reserved
75+###############Credits######################################################
76+# Coded by: Vauxoo C.A.
77+# Planified by: Nhomar Hernandez
78+# Audited by: Vauxoo C.A.
79+#############################################################################
80+# This program is free software: you can redistribute it and/or modify
81+# it under the terms of the GNU Affero General Public License as published by
82+# the Free Software Foundation, either version 3 of the License, or
83+# (at your option) any later version.
84+#
85+# This program is distributed in the hope that it will be useful,
86+# but WITHOUT ANY WARRANTY; without even the implied warranty of
87+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88+# GNU Affero General Public License for more details.
89+#
90+# You should have received a copy of the GNU Affero General Public License
91+# along with this program. If not, see <http://www.gnu.org/licenses/>.
92+################################################################################
93+import wh_iva
94+import account
95+import invoice
96+import partner
97+import generate_txt
98+import report
99+import installer
100+import wizard
101+
102+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
103
104=== renamed file 'l10n_ve_withholding_iva/model/account.py' => 'l10n_ve_withholding_iva/model/account.py'
105--- l10n_ve_withholding_iva/model/account.py 2011-12-22 00:20:54 +0000
106+++ l10n_ve_withholding_iva/model/account.py 2011-12-28 02:13:23 +0000
107@@ -29,9 +29,25 @@
108 class account_tax(osv.osv):
109 _inherit = 'account.tax'
110 _columns = {
111- 'ret': fields.boolean('Withhold', help="Indicate if the amount of tax must be withholded"),
112+ 'ret': fields.boolean('Withholdable', help="Indicate if the tax must be withholded"),
113+ 'wh_vat_collected_account_id': fields.many2one(
114+ 'account.account',
115+ type='many2one',
116+ relation='account.account',
117+ string="Invoice Withholding VAT Account",
118+ method=True,
119+ view_load=True,
120+ domain="[('type', '=', 'other')]",
121+ help="This account will be used when applying a withhold to an Invoice"),
122+ 'wh_vat_paid_account_id': fields.many2one(
123+ 'account.account',
124+ type='many2one',
125+ relation='account.account',
126+ string="Refund Withholding VAT Account",
127+ method=True,
128+ view_load=True,
129+ domain="[('type', '=', 'other')]",
130+ help="This account will be used when applying a withhold to a Refund"),
131 }
132
133 account_tax()
134-
135-
136
137=== renamed file 'l10n_ve_withholding_iva/model/generate_txt.py' => 'l10n_ve_withholding_iva/model/generate_txt.py'
138=== renamed file 'l10n_ve_withholding_iva/model/installer.py' => 'l10n_ve_withholding_iva/model/installer.py'
139=== renamed file 'l10n_ve_withholding_iva/model/invoice.py' => 'l10n_ve_withholding_iva/model/invoice.py'
140--- l10n_ve_withholding_iva/model/invoice.py 2011-12-22 00:20:54 +0000
141+++ l10n_ve_withholding_iva/model/invoice.py 2011-12-28 02:13:23 +0000
142@@ -142,9 +142,11 @@
143 return lines
144
145 def wh_iva_line_create(self, cr, uid, inv):
146+ wh_iva_rate = inv.type in ('in_invoice', 'in_refund') and inv.partner_id.wh_iva_rate or inv.type in ('out_invoice', 'out_refund') and inv.company_id.partner_id.wh_iva_rate
147 return (0, False, {
148 'name': inv.name or inv.number,
149 'invoice_id': inv.id,
150+ 'wh_iva_rate': wh_iva_rate,
151 })
152
153 def action_wh_iva_create(self, cr, uid, ids, *args):
154@@ -154,10 +156,10 @@
155 raise osv.except_osv('Invalid Action !', _('This invoice is already withholded'))
156 ret_line = []
157 if inv.type in ('out_invoice', 'out_refund'):
158- acc_id = inv.partner_id.property_wh_iva_receivable.id
159+ acc_id = inv.partner_id.property_account_receivable.id
160 wh_type = 'out_invoice'
161 else:
162- acc_id = inv.partner_id.property_wh_iva_payable.id
163+ acc_id = inv.partner_id.property_account_payable.id
164 wh_type = 'in_invoice'
165 if not acc_id:
166 raise osv.except_osv('Invalid Action !',\
167@@ -209,7 +211,7 @@
168 if context is None:
169 context={}
170 return any([line.tax_id.ret for line in self.browse(cr, uid, ids[0], context=context).tax_line])
171-
172+
173 def check_wh_apply(self, cr, uid, ids, context=None):
174 if context is None:
175 context={}
176@@ -218,10 +220,42 @@
177 wh_apply.append(self._withholding_partner(cr, uid, ids, context=context))
178 return all(wh_apply)
179
180+ def _get_move_lines(self, cr, uid, ids, to_wh, period_id,
181+ pay_journal_id, writeoff_acc_id,
182+ writeoff_period_id, writeoff_journal_id, date,
183+ name, context=None):
184+ if context is None: context = {}
185+ res = super(account_invoice,self)._get_move_lines(cr, uid, ids, to_wh, period_id,
186+ pay_journal_id, writeoff_acc_id,
187+ writeoff_period_id, writeoff_journal_id, date,
188+ name, context=context)
189+ if context.get('vat_wh',False):
190+ invoice = self.browse(cr, uid, ids[0])
191+
192+ types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
193+ direction = types[invoice.type]
194+
195+ for tax_brw in to_wh:
196+ if 'invoice' in invoice.type:
197+ acc = tax_brw.tax_id.wh_vat_collected_account_id and tax_brw.tax_id.wh_vat_collected_account_id.id or False
198+ elif 'refund' in invoice.type:
199+ acc = tax_brw.tax_id.wh_vat_paid_account_id and tax_brw.tax_id.wh_vat_paid_account_id or False
200+ if not acc:
201+ raise osv.except_osv(_('Missing Account in Tax!'),_("Tax [%s] has missing account. Please, fill the missing fields") % (tax_brw.tax_id.name,))
202+ res.append((0,0,{
203+ 'debit': direction * tax_brw.amount_ret<0 and - direction * tax_brw.amount_ret,
204+ 'credit': direction * tax_brw.amount_ret>0 and direction * tax_brw.amount_ret,
205+ 'account_id': acc,
206+ 'partner_id': invoice.partner_id.id,
207+ 'ref':invoice.number,
208+ 'date': date,
209+ 'currency_id': False,
210+ 'name':name
211+ }))
212+
213+ return res
214 account_invoice()
215
216-
217-
218 class account_invoice_tax(osv.osv):
219 _inherit = 'account.invoice.tax'
220 _columns = {
221@@ -229,7 +263,6 @@
222 'base_ret': fields.float('Amount', digits_compute= dp.get_precision('Withhold'), help="Amount without tax"),
223 }
224
225-
226 def compute_amount_ret(self, cr, uid, invoice_id, context={}):
227 res = {}
228 inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context)
229
230=== renamed file 'l10n_ve_withholding_iva/model/partner.py' => 'l10n_ve_withholding_iva/model/partner.py'
231=== renamed file 'l10n_ve_withholding_iva/model/wh_iva.py' => 'l10n_ve_withholding_iva/model/wh_iva.py'
232--- l10n_ve_withholding_iva/model/wh_iva.py 2011-12-22 00:20:54 +0000
233+++ l10n_ve_withholding_iva/model/wh_iva.py 2011-12-28 02:13:23 +0000
234@@ -28,8 +28,193 @@
235 from tools.translate import _
236 import decimal_precision as dp
237
238-
239-class account_wh_iva(osv.osv):
240+class account_wh_iva_line_tax(osv.osv):
241+ _name = 'account.wh.iva.line.tax'
242+account_wh_iva_line_tax()
243+
244+class account_wh_iva_line(osv.osv):
245+ _name = "account.wh.iva.line"
246+account_wh_iva_line()
247+
248+class account_wh_iva(osv.osv):
249+ _name = "account.wh.iva"
250+account_wh_iva()
251+
252+class account_wh_iva_line_tax(osv.osv):
253+
254+ def _set_amount_ret(self, cr, uid, id, name, value, arg, ctx=None):
255+ if ctx is None:
256+ ctx = {}
257+ if not self.browse(cr,uid,id,context=ctx).wh_vat_line_id.retention_id.type=='out_invoice':
258+ return False
259+ sql_str = """UPDATE account_wh_iva_line_tax set
260+ amount_ret='%s'
261+ WHERE id=%d """ % (value, id)
262+ cr.execute(sql_str)
263+ return True
264+
265+ def _get_amount_ret(self, cr, uid, ids, fieldname, args, context=None):
266+ if context is None: context=None
267+ res = {}
268+
269+ awilt_brw = self.browse(cr, uid, ids, context=context)
270+
271+ for each in awilt_brw:
272+ #~ TODO: THIS NEEDS REFACTORY IN ORDER TO COMPLY WITH THE SALE WITHHOLDING
273+ res[each.id] = each.amount * each.wh_vat_line_id.wh_iva_rate /100.0
274+ return res
275+
276+ _name = 'account.wh.iva.line.tax'
277+ _columns = {
278+ 'inv_tax_id': fields.many2one('account.invoice.tax', 'Invoice Tax', required=True, ondelete='set null', help="Tax Line"),
279+ 'wh_vat_line_id':fields.many2one('account.wh.iva.line', 'Withholding VAT Line', required=True, ondelete='cascade',),
280+ 'tax_id': fields.related('inv_tax_id', 'tax_id', type='many2one',relation='account.tax', string='Tax', store=True, select=True, readonly=True, ondelete='set null'),
281+ 'name': fields.related('inv_tax_id', 'name', type='char', string='Tax Name', size=256, store=True, select=True, readonly=True, ondelete='set null'),
282+ 'base': fields.related('inv_tax_id', 'base', type='float', string='Tax Base', store=True, select=True, readonly=True, ondelete='set null'),
283+ 'amount': fields.related('inv_tax_id', 'amount', type='float', string='Taxed Amount', store=True, select=True, readonly=True, ondelete='set null'),
284+ # Otro campo related
285+ 'company_id': fields.related('inv_tax_id', 'company_id', type='many2one',relation='res.company', string='Company', store=True, select=True, readonly=True, ondelete='set null'),
286+ 'amount_ret': fields.function(
287+ _get_amount_ret,
288+ method=True,
289+ type='float',
290+ string='Withheld Taxed Amount',
291+ digits_compute= dp.get_precision('Withhold'),
292+ store= {
293+ 'account.wh.iva.line.tax': (lambda self, cr, uid, ids, c={}: ids, ['amount'],15)
294+ },
295+ fnct_inv=_set_amount_ret,
296+ help="Withholding vat amount"),
297+ #~ 'amount_ret': fields.float('Withheld Taxed Amount', digits_compute= dp.get_precision('Withhold'), help="Withholding vat amount"),
298+ }
299+
300+account_wh_iva_line_tax()
301+
302+class account_wh_iva_line(osv.osv):
303+
304+ ####################################################################
305+ #~ ESTO SE DEBE BORRAR UNA VEZ QUE SE TERMINE
306+ #~ DE DEFINIR LA EXISTENCIA DE LAS LINEAS NUEVAS PARA RETENCION
307+ ####################################################################
308+
309+ def _compute_tax_lines(self, cr, uid, ids, name, args, context=None):
310+ if context is None: context = {}
311+ res = {}
312+ awilt_obj = self.pool.get('account.wh.iva.line.tax')
313+ for ret_line in self.browse(cr, uid, ids, context):
314+ lines = []
315+ if ret_line.invoice_id:
316+ tax_ids = [i.id for i in ret_line.invoice_id.tax_line if i.tax_id and i.tax_id.ret]
317+ for i in tax_ids:
318+ lines.append(awilt_obj.create(cr, uid, {
319+ 'inv_tax_id':i,
320+ 'wh_vat_line_id':ret_line.id
321+ }, context=context))
322+ res[ret_line.id] = lines
323+ return res
324+
325+ def _get_tax_lines(self, cr, uid, tax_id_brw, context=None):
326+ if context is None: context = {}
327+ return {
328+ 'inv_tax_id':tax_id_brw.id,
329+ 'tax_id':tax_id_brw.tax_id.id,
330+ 'name':tax_id_brw.tax_id.name,
331+ 'base':tax_id_brw.base,
332+ 'amount':tax_id_brw.amount,
333+ 'company_id':tax_id_brw.company_id.id,
334+ 'wh_iva_rate':tax_id_brw.invoice_id.partner_id.wh_iva_rate
335+ }
336+
337+ def load_taxes(self, cr, uid, ids, context=None):
338+ if context is None: context = {}
339+ awilt_obj = self.pool.get('account.wh.iva.line.tax')
340+ for ret_line in self.browse(cr, uid, ids, context):
341+ lines = []
342+ if ret_line.invoice_id:
343+ rate = \
344+ ret_line.retention_id.type == 'out_invoice' and ret_line.invoice_id.company_id.partner_id.wh_iva_rate or \
345+ ret_line.retention_id.type == 'in_invoice' and ret_line.invoice_id.partner_id.wh_iva_rate
346+ self.write(cr, uid, ret_line.id, {'wh_iva_rate': rate})
347+ tax_lines = awilt_obj.search(cr, uid, [('wh_vat_line_id', '=', ret_line.id)])
348+ if tax_lines:
349+ awilt_obj.unlink(cr, uid, tax_lines)
350+
351+ tax_ids = [i for i in ret_line.invoice_id.tax_line if i.tax_id and i.tax_id.ret]
352+ for i in tax_ids:
353+ values = self._get_tax_lines(cr, uid, i, context=context)
354+ values.update({'wh_vat_line_id':ret_line.id,})
355+ lines.append(awilt_obj.create(cr, uid, values, context=context))
356+ return True
357+
358+ ####################################################################
359+ #~ FIN DEL BORRADO
360+ ####################################################################
361+
362+ def _amount_all(self, cr, uid, ids, fieldname, args, context=None):
363+ res = {}
364+ for ret_line in self.browse(cr, uid, ids, context):
365+ res[ret_line.id] = {
366+ 'amount_tax_ret': 0.0,
367+ 'base_ret': 0.0
368+ }
369+ for line in ret_line.tax_line:
370+ res[ret_line.id]['amount_tax_ret'] += line.amount_ret
371+ res[ret_line.id]['base_ret'] += line.base
372+
373+ return res
374+
375+ _name = "account.wh.iva.line"
376+ _description = "Withholding vat line"
377+ _columns = {
378+ 'name': fields.char('Description', size=64, required=True, help="Withholding line Description"),
379+ 'retention_id': fields.many2one('account.wh.iva', 'Withholding vat', ondelete='cascade', help="Withholding vat"),
380+ 'invoice_id': fields.many2one('account.invoice', 'Invoice', required=True, ondelete='set null', help="Withholding invoice"),
381+ #########################################
382+ #~ REDEFINIENDO EL CAMPO TAX LINE,
383+ #~ AHORA SERA UN NUEVO MODELO EL QUE LLEVARA A CABO TAL TAREA
384+ 'tax_line': fields.one2many('account.wh.iva.line.tax','wh_vat_line_id', string='Taxes', help="Invoice taxes"),
385+ #~ 'tax_line': fields.function(_compute_tax_lines, method=True, relation='account.wh.iva.line.tax', type="one2many", string='Taxes', help="Invoice taxes",store = {'account.wh.iva.line': (lambda self, cr, uid, ids, c={}: ids,['invoice_id'],15)}),
386+ #~ 'tax_line': fields.function(_compute_tax_lines, method=True, relation='account.invoice.tax', type="one2many", string='Taxes', help="Invoice taxes"),
387+ #########################################
388+ 'amount_tax_ret': fields.function(_amount_all, method=True, digits=(16,4), string='Wh. tax amount', multi='all', help="Withholding tax amount"),
389+ 'base_ret': fields.function(_amount_all, method=True, digits=(16,4), string='Wh. amount', multi='all', help="Withholding without tax amount"),
390+# 'retention_rate': fields.function(_retention_rate, method=True, string='Wh. rate', type='float', help="Withholding rate"),
391+ 'move_id': fields.many2one('account.move', 'Account Entry', readonly=True, help="Account entry"),
392+ #~ 'amount_base_wh': fields.float('Amount', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount without tax"),
393+ #~ 'amount_tax_wh': fields.float('Amount wh. tax vat', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount withholding tax vat"),
394+ 'wh_iva_rate': fields.float(string='Withholding Vat Rate', digits_compute= dp.get_precision('Withhold'), help="Withholding vat rate"),
395+ }
396+
397+ _sql_constraints = [
398+ ('ret_fact_uniq', 'unique (invoice_id)', 'The invoice has already assigned in withholding vat, you cannot assigned it twice!')
399+ ]
400+
401+ def invoice_id_change(self, cr, uid, ids, invoice, context=None):
402+ if context is None:
403+ context = {}
404+ if not invoice:
405+ return {}
406+ result = {}
407+ lst=[]
408+ domain = {}
409+ ok = True
410+ res = self.pool.get('account.invoice').browse(cr, uid, invoice, context=context)
411+ cr.execute('select retention_id from account_wh_iva_line where invoice_id=%s', (invoice,))
412+ ret_ids = cr.fetchone()
413+ ok = ok and bool(ret_ids)
414+ if ok:
415+ ret = self.pool.get('account.wh.iva').browse(cr, uid, ret_ids[0], context)
416+ raise osv.except_osv('Assigned Invoice !',"The invoice has already assigned in withholding vat code: '%s' !" % (ret.code,))
417+
418+ result['name'] = res.name
419+
420+
421+ return {'value':result, 'domain':domain}
422+
423+account_wh_iva_line()
424+
425+class account_wh_iva(osv.osv):
426+
427 def _amount_ret_all(self, cr, uid, ids, name, args, context=None):
428 res = {}
429 for retention in self.browse(cr, uid, ids, context):
430@@ -94,8 +279,8 @@
431 'journal_id': fields.many2one('account.journal', 'Journal', required=True,readonly=True, states={'draft':[('readonly',False)]}, help="Journal entry"),
432 'company_id': fields.many2one('res.company', 'Company', required=True, help="Company"),
433 'wh_lines': fields.one2many('account.wh.iva.line', 'retention_id', 'Withholding vat lines', readonly=True, states={'draft':[('readonly',False)]}, help="Withholding vat lines"),
434- 'tot_amount_base_wh': fields.float('Amount', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount without tax"),
435- 'tot_amount_tax_wh': fields.float('Amount wh. tax vat', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount withholding tax vat"),
436+ #~ 'tot_amount_base_wh': fields.float('Amount', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount without tax"),
437+ #~ 'tot_amount_tax_wh': fields.float('Amount wh. tax vat', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount withholding tax vat"),
438 'amount_base_ret': fields.function(_amount_ret_all, method=True, digits_compute= dp.get_precision('Withhold'), string='Compute amount', multi='all', help="Compute amount without tax"),
439 'total_tax_ret': fields.function(_amount_ret_all, method=True, digits_compute= dp.get_precision('Withhold'), string='Compute amount wh. tax vat', multi='all', help="compute amount withholding tax vat"),
440
441@@ -112,6 +297,43 @@
442
443 }
444
445+ def _get_valid_wh(self, cr, uid, amount_ret, amount, wh_iva_rate, offset=0.5, context=None):
446+ '''This method can be override in a way that
447+ you can afford your own value for the offset'''
448+ if context is None: context = {}
449+ return amount_ret >= amount * (wh_iva_rate - offset)/100.0 and amount_ret <= amount * (wh_iva_rate + offset)/100.0
450+
451+ def check_wh_taxes(self, cr, uid, ids, context=None):
452+ if context is None: context = {}
453+ res = {}
454+ note = _('Taxes in the following invoices have been miscalculated\n\n')
455+ for wh_line in self.browse(cr,uid, ids[0]).wh_lines:
456+ for tax in wh_line.tax_line:
457+ #~ if not self._get_valid_wh(cr, uid, tax.amount_ret, tax.amount, tax.wh_vat_line_id.wh_iva_rate, context=context):
458+ if not self._get_valid_wh(cr, uid, tax.amount_ret, tax.amount, tax.wh_vat_line_id.wh_iva_rate, context=context):
459+ if not res.get(wh_line.id, False):
460+ note += _('\tInvoice: %s, %s, %s\n')%(wh_line.invoice_id.name,wh_line.invoice_id.number,wh_line.invoice_id.reference or '/')
461+ res[wh_line.id] = True
462+ note += '\t\t%s\n'%tax.name
463+ if res:
464+ raise osv.except_osv(_('Miscalculated Withheld Taxes'),note)
465+ return True
466+
467+ def check_vat_wh(self, cr, uid, ids, context={}):
468+ obj = self.browse(cr, uid, ids[0])
469+ res = {}
470+ for wh_line in obj.wh_lines:
471+ if not wh_line.tax_line:
472+ res[wh_line.id] = (wh_line.invoice_id.name,wh_line.invoice_id.number,wh_line.invoice_id.reference)
473+ if res:
474+ note = _('The Following Invoices Have not already been withheld:\n\n')
475+ for i in res:
476+ note += '* %s, %s, %s\n'%res[i]
477+ note += _('\nPlease, Load the Taxes to be withheld and Try Again')
478+
479+ raise osv.except_osv(_('Invoices with Missing Withheld Taxes!'),note)
480+ return True
481+
482 def _check_partner(self, cr, uid, ids, context={}):
483 agt = False
484 obj = self.browse(cr, uid, ids[0])
485@@ -164,75 +386,122 @@
486
487 def action_move_create(self, cr, uid, ids, context=None):
488 inv_obj = self.pool.get('account.invoice')
489- context = {}
490-
491- for ret in self.browse(cr, uid, ids, context):
492- for line in ret.wh_lines:
493- if line.move_id or line.invoice_id.wh_iva:
494- raise osv.except_osv(_('Invoice already withhold !'),\
495- _("You must omit the follow invoice '%s' !") %\
496- (line.invoice_id.name,))
497- return False
498-
499- acc_id = ret.account_id.id
500-
501- period_id = ret.period_id and ret.period_id.id or False
502- journal_id = ret.journal_id.id
503+ if context is None: context = {}
504+
505+ context.update({'vat_wh':True})
506+
507+ ret = self.browse(cr, uid, ids[0], context)
508+ for line in ret.wh_lines:
509+ if line.move_id or line.invoice_id.wh_iva:
510+ raise osv.except_osv(_('Invoice already withhold !'),\
511+ _("You must omit the follow invoice '%s' !") %\
512+ (line.invoice_id.name,))
513+
514+ acc_id = ret.account_id.id
515+
516+ period_id = ret.period_id and ret.period_id.id or False
517+ journal_id = ret.journal_id.id
518+ if not period_id:
519+ per_obj = self.pool.get('account.period')
520+ period_id = per_obj.find(cr, uid,ret.date_ret or time.strftime('%Y-%m-%d'))
521+ period_id = per_obj.search(cr,uid,[('id','in',period_id),('special','=',False)])
522 if not period_id:
523- period_ids = self.pool.get('account.period').search(cr,uid,[('date_start','<=',ret.date_ret or time.strftime('%Y-%m-%d')),('date_stop','>=',ret.date_ret or time.strftime('%Y-%m-%d'))])
524- if len(period_ids):
525- period_id = period_ids[0]
526-
527+ raise osv.except_osv(_('Missing Periods!'),\
528+ _("There are not Periods created for the pointed day: %s!") %\
529+ (ret.date_ret or time.strftime('%Y-%m-%d')))
530+ period_id = period_id[0]
531+ if period_id:
532 if ret.wh_lines:
533 for line in ret.wh_lines:
534 writeoff_account_id,writeoff_journal_id = False, False
535- amount = line.amount_tax_wh
536+ amount = line.amount_tax_ret
537 if line.invoice_id.type in ['in_invoice','in_refund']:
538 name = 'COMP. RET. IVA ' + ret.number + ' Doc. '+ (line.invoice_id.reference or '')
539 else:
540 name = 'COMP. RET. IVA ' + ret.number + ' Doc. '+ (line.invoice_id.number or '')
541 ret_move = inv_obj.ret_and_reconcile(cr, uid, [line.invoice_id.id],
542 amount, acc_id, period_id, journal_id, writeoff_account_id,
543- period_id, writeoff_journal_id, ret.date_ret, name, context)
544-
545+ period_id, writeoff_journal_id, ret.date_ret, name,line.tax_line, context)
546 # make the withholding line point to that move
547 rl = {
548 'move_id': ret_move['move_id'],
549 }
550 lines = [(1, line.id, rl)]
551 self.write(cr, uid, [ret.id], {'wh_lines':lines, 'period_id':period_id})
552+
553 return True
554
555
556- def onchange_partner_id(self, cr, uid, ids, type, partner_id):
557+ def onchange_partner_id(self, cr, uid, ids, type, partner_id,context=None):
558+ if context is None: context = {}
559+
560 acc_id = False
561+ res = {}
562+ inv_obj = self.pool.get('account.invoice')
563+
564 if partner_id:
565 p = self.pool.get('res.partner').browse(cr, uid, partner_id)
566 if type in ('out_invoice', 'out_refund'):
567- acc_id = p.property_wh_iva_receivable.id
568+ acc_id = p.property_account_receivable and p.property_account_receivable.id or False
569 else:
570- acc_id = p.property_wh_iva_payable.id
571-
572- self._update_check(cr, uid, ids, partner_id)
573- result = {'value': {
574- 'account_id': acc_id}
575+ acc_id = p.property_account_payable and p.property_account_payable.id or False
576+
577+ wh_line_obj = self.pool.get('account.wh.iva.line')
578+ wh_lines = ids and wh_line_obj.search(cr, uid, [('retention_id', '=', ids[0])]) or False
579+ res_wh_lines = []
580+ if wh_lines:
581+ wh_line_obj.unlink(cr, uid, wh_lines)
582+
583+ inv_ids = inv_obj.search(cr,uid,[('state', '=', 'open'), ('wh_iva', '=', False), ('partner_id','=',partner_id)],context=context)
584+
585+ if inv_ids:
586+ #~ Get only the invoices which are not in a document yet
587+ inv_ids = [i for i in inv_ids if not wh_line_obj.search(cr, uid, [('invoice_id', '=', i)])]
588+
589+ if inv_ids:
590+ awil_obj = self.pool.get('account.wh.iva.line')
591+ res_wh_lines = [{
592+ 'invoice_id': inv_brw.id,
593+ 'name': inv_brw.name or _('N/A'),
594+ 'wh_iva_rate': inv_brw.partner_id.wh_iva_rate,
595+ #~ 'tax_line': [awil_obj._get_tax_lines(cr, uid, i, context=context) for i in inv_brw.tax_line if i.tax_id and i.tax_id.ret]
596+
597+ } for inv_brw in inv_obj.browse(cr,uid,inv_ids,context=context)]
598+
599+ res = {'value': {
600+ 'account_id': acc_id,
601+ 'wh_lines':res_wh_lines}
602 }
603
604- return result
605+ return res
606
607+ #~ ##########################################
608+ #~ BEGIN DELETE
609+ #~ ##########################################
610+ #~ ESTO SE DEBE BORRAR SI EN EL ONCHANGE
611+ #~ DEL DOCUMENTO YA SE ESTA CONSIDERANDO
612+ #~ EL BORRADO DE LOS DOCUMENTOS QUE ESTABAN
613+ #~ PREVIAMENTE
614+ #~ ##########################################
615+
616 def _update_check(self, cr, uid, ids, partner_id, context={}):
617 if ids:
618 ret = self.browse(cr, uid, ids[0])
619 inv_str = ''
620 for line in ret.wh_lines:
621 if line.invoice_id.partner_id.id != partner_id:
622- inv_str+= '%s'% '\n'+line.invoice_id.name
623+ inv_str+= line.invoice_id.name and '%s'% '\n'+line.invoice_id.name or ''
624
625 if inv_str:
626 raise osv.except_osv('Incorrect Invoices !',"The following invoices are not the selected partner: %s " % (inv_str,))
627
628 return True
629
630+ #~ ##########################################
631+ #~ END DELETE
632+ #~ ##########################################
633+
634+
635 def _new_check(self, cr, uid, values, context={}):
636 lst_inv = []
637
638@@ -254,20 +523,6 @@
639
640 return True
641
642-
643- def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
644- if not context:
645- context={}
646- ret = self.browse(cr, uid, ids[0])
647- if update_check:
648- if 'partner_id' in vals and vals['partner_id']:
649- self._update_check(cr, uid, ids, vals['partner_id'], context)
650- else:
651- self._update_check(cr, uid, ids, ret.partner_id.id, context)
652-
653- return super(account_wh_iva, self).write(cr, uid, ids, vals, context=context)
654-
655-
656 def create(self, cr, uid, vals, context=None, check=True):
657 if not context:
658 context={}
659@@ -282,96 +537,21 @@
660 def compute_amount_wh(self, cr, uid, ids, context=None):
661 res = {}
662 if context is None:
663- context = {}
664+ context = {}
665+ awil_obj = self.pool.get('account.wh.iva.line')
666 for retention in self.browse(cr, uid, ids, context):
667- res[retention.id] = {
668- 'tot_amount_base_wh': 0.0,
669- 'tot_amount_tax_wh': 0.0
670- }
671- for line in retention.wh_lines:
672- res[retention.id]['tot_amount_base_wh'] += line.amount_base_wh
673- res[retention.id]['tot_amount_tax_wh'] += line.amount_tax_wh
674- self.write(cr, uid, [retention.id], res[retention.id])
675+
676+ #~ res[retention.id] = {
677+ #~ 'tot_amount_base_wh': 0.0,
678+ #~ 'tot_amount_tax_wh': 0.0
679+ #~ }
680+ whl_ids = [line.id for line in retention.wh_lines]
681+ if whl_ids:
682+ awil_obj.load_taxes(cr, uid, whl_ids , context=context)
683+
684+ #~ res[retention.id]['tot_amount_base_wh'] += line.amount_base_wh
685+ #~ res[retention.id]['tot_amount_tax_wh'] += line.amount_tax_wh
686+ #~ self.write(cr, uid, [retention.id], res[retention.id])
687 return True
688
689 account_wh_iva()
690-
691-
692-
693-class account_wh_iva_line(osv.osv):
694- def _compute_tax_lines(self, cr, uid, ids, name, args, context=None):
695- result = {}
696- for ret_line in self.browse(cr, uid, ids, context):
697- lines = []
698- if ret_line.invoice_id:
699- ids_tline = ret_line.invoice_id.tax_line
700- lines = map(lambda x: x.id, ids_tline)
701- result[ret_line.id] = lines
702- return result
703-
704- def _amount_all(self, cr, uid, ids, name, args, context=None):
705- res = {}
706- for ret_line in self.browse(cr, uid, ids, context):
707- res[ret_line.id] = {
708- 'amount_tax_ret': 0.0,
709- 'base_ret': 0.0
710- }
711- for line in ret_line.invoice_id.tax_line:
712- res[ret_line.id]['amount_tax_ret'] += line.amount_ret
713- res[ret_line.id]['base_ret'] += line.base_ret
714-
715- return res
716-
717- def check_a_retention(self, cr, uid, ids, context=None):
718- amount = 0.0
719- for tax_line in self.browse(cr,uid, ids[0]).tax_line:
720- amount+= tax_line.amount
721- wh_vat_line=self.browse(cr, uid, ids, context)[0]
722- if wh_vat_line.amount_base_wh > amount:
723- raise osv.except_osv(_('Amount Error'),_('the amount is greater than the tax'))
724- return True
725-
726-
727- _name = "account.wh.iva.line"
728- _description = "Withholding vat line"
729- _columns = {
730- 'name': fields.char('Description', size=64, required=True, help="Withholding line Description"),
731- 'retention_id': fields.many2one('account.wh.iva', 'Withholding vat', ondelete='cascade', help="Withholding vat"),
732- 'invoice_id': fields.many2one('account.invoice', 'Invoice', required=True, ondelete='set null', help="Withholding invoice"),
733- 'tax_line': fields.function(_compute_tax_lines, method=True, relation='account.invoice.tax', type="one2many", string='Taxes', help="Invoice taxes"),
734- 'amount_tax_ret': fields.function(_amount_all, method=True, digits=(16,4), string='Wh. tax amount', multi='all', help="Withholding tax amount"),
735- 'base_ret': fields.function(_amount_all, method=True, digits=(16,4), string='Wh. amount', multi='all', help="Withholding without tax amount"),
736-# 'retention_rate': fields.function(_retention_rate, method=True, string='Wh. rate', type='float', help="Withholding rate"),
737- 'move_id': fields.many2one('account.move', 'Account Entry', readonly=True, help="Account entry"),
738- 'amount_base_wh': fields.float('Amount', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount without tax"),
739- 'amount_tax_wh': fields.float('Amount wh. tax vat', required=False, digits_compute= dp.get_precision('Withhold'), help="Amount withholding tax vat"),
740-
741- }
742-
743- _sql_constraints = [
744- ('ret_fact_uniq', 'unique (invoice_id)', 'The invoice has already assigned in withholding vat, you cannot assigned it twice!')
745- ]
746-
747- def invoice_id_change(self, cr, uid, ids, invoice, context=None):
748- if context is None:
749- context = {}
750- if not invoice:
751- return {}
752- result = {}
753- lst=[]
754- domain = {}
755- ok = True
756- res = self.pool.get('account.invoice').browse(cr, uid, invoice, context=context)
757- cr.execute('select retention_id from account_wh_iva_line where invoice_id=%s', (invoice,))
758- ret_ids = cr.fetchone()
759- ok = ok and bool(ret_ids)
760- if ok:
761- ret = self.pool.get('account.wh.iva').browse(cr, uid, ret_ids[0], context)
762- raise osv.except_osv('Assigned Invoice !',"The invoice has already assigned in withholding vat code: '%s' !" % (ret.code,))
763-
764- result['name'] = res.name
765-
766-
767- return {'value':result, 'domain':domain}
768-
769-account_wh_iva_line()
770
771=== modified file 'l10n_ve_withholding_iva/report/wittholding_vat.py'
772--- l10n_ve_withholding_iva/report/wittholding_vat.py 2011-11-09 21:04:25 +0000
773+++ l10n_ve_withholding_iva/report/wittholding_vat.py 2011-12-28 02:13:23 +0000
774@@ -147,24 +147,78 @@
775 ttal = {}
776 lst_comp = []
777
778+ dic_inv = {}
779 for rl in comp.wh_lines:
780- dic_inv = {}
781 lst_tmp = []
782 k=1
783 no_fac_afe = rl.invoice_id.origin or ''
784 if rl.invoice_id.type in ['in_refund', 'out_refund']:
785 k=-1
786 no_fac_afe = rl.invoice_id.parent_id and rl.invoice_id.parent_id.reference or ''
787+
788+ #~ Codigo para cumplir los cambios en el nuevo uso del campo ret,
789+ #~ y la relacion nueva en account.invoice.tax
790+
791 for txl in rl.invoice_id.tax_line:
792- sdcf = False
793- tot_base_imp[types[rl.invoice_id.type]] = tot_base_imp.get(types[rl.invoice_id.type],0.0) + txl.base_ret
794- tot_imp_iva[types[rl.invoice_id.type]] = tot_imp_iva.get(types[rl.invoice_id.type],0.0) + txl.amount
795- tot_iva_ret[types[rl.invoice_id.type]] = tot_iva_ret.get(types[rl.invoice_id.type],0.0) + txl.amount_ret
796+ #~ Aqui se esta revisando son los impuestos que estan
797+ #~ en la factura solo con el fin de poder obtener
798+ #~ solo los impuestos que no son objeto de retencion
799+
800+ a= (txl.name and txl.name.find('SDCF')!=-1)
801+ b= (txl.tax_id and not txl.tax_id.ret)
802+ if not any([a,b]):
803+ continue
804+
805+ sdcf = False
806+ tot_base_imp[types[rl.invoice_id.type]] = tot_base_imp.get(types[rl.invoice_id.type],0.0) + txl.base
807+ tot_imp_iva[types[rl.invoice_id.type]] = tot_imp_iva.get(types[rl.invoice_id.type],0.0) + txl.amount
808+ tot_iva_ret[types[rl.invoice_id.type]] = tot_iva_ret.get(types[rl.invoice_id.type],0.0) + txl.amount_ret
809+
810+ if any([a,b]):
811+ tot_comp_sdc[types[rl.invoice_id.type]] = tot_comp_sdc.get(types[rl.invoice_id.type],0.0) + (txl.base+txl.amount)
812+ sdcf = True
813+ else:
814+ tot_comp[types[rl.invoice_id.type]] = tot_comp.get(types[rl.invoice_id.type],0.0) + (txl.base+txl.amount)
815+
816+ d1 = {
817+ 'fecha': rl.invoice_id.date_invoice,
818+ 'nro_fact': rl.invoice_id.reference,
819+ 'nro_ctrl': rl.invoice_id.nro_ctrl,
820+ 'nro_ncre': rl.invoice_id.reference,
821+ 'nro_ndeb': rl.invoice_id.reference,
822+ 'porcenta': rl.invoice_id.wh_iva_rate,
823+ 'tip_tran': self._get_tipo_doc(rl.invoice_id.type),
824+ 'nro_fafe': no_fac_afe,
825+ 'tot_civa': not sdcf and k*(txl.base+txl.amount) or 0.0,
826+ 'cmp_sdcr': sdcf and k*(txl.base+txl.amount) or 0.0,
827+ 'bas_impo': k*txl.base,
828+ 'alic': txl.tax_id.amount and txl.tax_id.amount * 100.0 or 0.0,
829+ 'iva': k*txl.amount,
830+ 'iva_ret': k*txl.amount_ret,
831+ 'inv_type': rl.invoice_id.type
832+ }
833+ lst_tmp.append(d1)
834+ dic_inv[rl.invoice_id.id] = lst_tmp
835+
836+ for txl in rl.tax_line:
837+ a= (txl.name and txl.name.find('SDCF')!=-1)
838+ b= (txl.tax_id and not txl.tax_id.ret)
839+ if any([a,b]):
840+ continue
841+ sdcf = False
842+ tot_base_imp[types[rl.invoice_id.type]] = tot_base_imp.get(types[rl.invoice_id.type],0.0) + txl.base
843+ tot_imp_iva[types[rl.invoice_id.type]] = tot_imp_iva.get(types[rl.invoice_id.type],0.0) + txl.amount
844+ tot_iva_ret[types[rl.invoice_id.type]] = tot_iva_ret.get(types[rl.invoice_id.type],0.0) + txl.amount_ret
845+
846+ #~ TODO: ESTO SE DEBE SOLUCIONAR, MEDIANTE EL USO DEL CAMPO RET
847+ #~ EN EL MODELO ACCOUNT.TAX, DE TAL MANERA QUE SI EL IMPUESTO APARECE
848+ #~ CON EL VALOR EN FALSE, Y DADO QUE AHORA CONTAMOS CON UN TAX_ID EN ACCOUNT.INVOICE.TAX
849+ #~ PODEMOS HACER EL RASTREO HASTA EL ACCOUNT.TAX
850 if txl.name.find('SDCF')!=-1:
851- tot_comp_sdc[types[rl.invoice_id.type]] = tot_comp_sdc.get(types[rl.invoice_id.type],0.0) + (txl.base_ret+txl.amount)
852+ tot_comp_sdc[types[rl.invoice_id.type]] = tot_comp_sdc.get(types[rl.invoice_id.type],0.0) + (txl.base+txl.amount)
853 sdcf = True
854 else:
855- tot_comp[types[rl.invoice_id.type]] = tot_comp.get(types[rl.invoice_id.type],0.0) + (txl.base_ret+txl.amount)
856+ tot_comp[types[rl.invoice_id.type]] = tot_comp.get(types[rl.invoice_id.type],0.0) + (txl.base+txl.amount)
857
858 d1 = {
859 'fecha': rl.invoice_id.date_invoice,
860@@ -175,17 +229,18 @@
861 'porcenta': rl.invoice_id.wh_iva_rate,
862 'tip_tran': self._get_tipo_doc(rl.invoice_id.type),
863 'nro_fafe': no_fac_afe,
864- 'tot_civa': not sdcf and k*(txl.base_ret+txl.amount) or 0.0,
865- 'cmp_sdcr': sdcf and k*(txl.base_ret+txl.amount) or 0.0,
866- 'bas_impo': k*txl.base_ret,
867- 'alic': txl.base_amount and (txl.tax_amount/txl.base_amount*100) or 0.0,
868+ 'tot_civa': not sdcf and k*(txl.base+txl.amount) or 0.0,
869+ 'cmp_sdcr': sdcf and k*(txl.base+txl.amount) or 0.0,
870+ 'bas_impo': k*txl.base,
871+ 'alic': txl.tax_id.amount and txl.tax_id.amount * 100.0 or 0.0,
872 'iva': k*txl.amount,
873 'iva_ret': k*txl.amount_ret,
874 'inv_type': rl.invoice_id.type
875 }
876 lst_tmp.append(d1)
877 dic_inv[rl.invoice_id.id] = lst_tmp
878-
879+
880+
881 for inv_id in dic_inv.keys():
882 i=0
883 cf = False
884@@ -211,7 +266,6 @@
885 self.ttbase = tot_base_imp.get('s',0.0) - tot_base_imp.get('r',0.0)
886 self.ttiva = tot_imp_iva.get('s',0.0) - tot_imp_iva.get('r',0.0)
887 self.ttretencion = tot_iva_ret.get('s',0.0) - tot_iva_ret.get('r',0.0)
888-
889 return lst_comp
890
891 def _get_tot_gral_compra(self):
892
893=== added directory 'l10n_ve_withholding_iva/view'
894=== renamed directory 'l10n_ve_withholding_iva/view' => 'l10n_ve_withholding_iva/view.moved'
895=== renamed file 'l10n_ve_withholding_iva/view/account_invoice_view.xml' => 'l10n_ve_withholding_iva/view/account_invoice_view.xml'
896=== renamed file 'l10n_ve_withholding_iva/view/account_view.xml' => 'l10n_ve_withholding_iva/view/account_view.xml'
897--- l10n_ve_withholding_iva/view/account_view.xml 2011-12-22 00:20:54 +0000
898+++ l10n_ve_withholding_iva/view/account_view.xml 2011-12-28 02:13:23 +0000
899@@ -18,6 +18,13 @@
900 <field name="arch" type="xml">
901 <xpath expr="/form/group/field[@name='active']" position="after">
902 <field name="ret" />
903+ </xpath>
904+ <xpath expr="/form/notebook/page[@string='Tax Definition']/group/separator[@string='Tax Declaration: Invoices']" position="before">
905+ <separator colspan="4" string="Withholding Tax Accounts"/>
906+ <field name="wh_vat_collected_account_id" attrs="{'required':[('ret','=',True)]}"/>
907+ <label colspan="2" nolabel="1" string="This account will be used when applying a withhold to an Invoice"/>
908+ <field name="wh_vat_paid_account_id" attrs="{'required':[('ret','=',True)]}"/>
909+ <label colspan="2" nolabel="1" string="This account will be used when applying a withhold to a Refund"/>
910 </xpath>
911 </field>
912 </record>
913@@ -26,6 +33,3 @@
914
915 </data>
916 </openerp>
917-
918-
919-
920
921=== renamed file 'l10n_ve_withholding_iva/view/generate_txt_view.xml' => 'l10n_ve_withholding_iva/view/generate_txt_view.xml'
922=== renamed file 'l10n_ve_withholding_iva/view/partner_view.xml' => 'l10n_ve_withholding_iva/view/partner_view.xml'
923=== renamed file 'l10n_ve_withholding_iva/view/wh_iva_view.xml' => 'l10n_ve_withholding_iva/view/wh_iva_view.xml'
924--- l10n_ve_withholding_iva/view/wh_iva_view.xml 2011-12-22 00:20:54 +0000
925+++ l10n_ve_withholding_iva/view/wh_iva_view.xml 2011-12-28 02:13:23 +0000
926@@ -17,10 +17,9 @@
927 <field name="name"/>
928 <field name="invoice_id" on_change="invoice_id_change(invoice_id)" domain="[('state', '=', 'open'), ('wh_iva', '=', False), ('partner_id','=',parent.partner_id)]"/>
929 <!-- <field name="retention_rate" />-->
930- <field name="base_ret"/>
931 <field name="amount_tax_ret"/>
932- <field name="amount_base_wh"/>
933- <field name="amount_tax_wh"/>
934+ <field name="wh_iva_rate" />
935+ <field name="tax_line"/>
936 <field name="move_id"/>
937 </tree>
938 </field>
939@@ -33,31 +32,53 @@
940 <field name="arch" type="xml">
941 <form string="Withholding Lines">
942 <notebook>
943- <page string="Line">
944- <field name="invoice_id" on_change="invoice_id_change(invoice_id)" domain="[('state', '=', 'open'), ('wh_iva', '=', False), ('partner_id','=',parent.partner_id)]"/>
945-<!-- <field name="retention_rate" />-->
946- <field colspan="4" name="name" select="1"/>
947+ <page string="Withheld Invoice">
948+ <field name="invoice_id" colspan="2" on_change="invoice_id_change(invoice_id)" domain="[('state', '=', 'open'), ('wh_iva', '=', False), ('partner_id','=',parent.partner_id)]"/>
949+ <field colspan="2" name="name" select="1"/>
950 <group col="1" colspan="4">
951 <field name="tax_line" nolabel="1">
952- <tree string="Taxes">
953+ <tree string="Taxes" editable='top'>
954 <field name="name"/>
955 <field name="base" />
956 <field name="amount" />
957- <field name="base_ret" />
958 <field name="amount_ret" />
959- <field invisible="True" name="base_amount"/>
960- <field invisible="True" name="tax_amount"/>
961 </tree>
962+ <form string="Taxes">
963+ <field colspan="4" name="name"/>
964+ <field name="tax_id" />
965+ <field name="base" />
966+ <field name="amount" />
967+ <field name="amount_ret" />
968+ <field name="company_id" />
969+ </form>
970 </field>
971 </group>
972- <field name="move_id"/>
973- <group col="2" colspan="2">
974- <field name="amount_tax_ret"/>
975- <field name="base_ret"/>
976- <field name="amount_base_wh"/>
977- <field name="amount_tax_wh"/>
978- </group>
979- <button name="check_a_retention" string="Validate Amount Retention" type="object" icon="gtk-ok"/>
980+ <separator colspan='4'/>
981+ <field name="wh_iva_rate" colspan='2' invisible='True'/>
982+ <group col="2" colspan="2">
983+ <label
984+ string='Please, if there are not taxes loaded, Click on Load Taxes'
985+ colspan='2'
986+ />
987+ <vpaned/>
988+ <field colspan='2' name="move_id"/>
989+ </group>
990+ <group col="2" colspan="2">
991+ <group col="2" colspan="2">
992+ <button
993+ name="load_taxes"
994+ string="Load Taxes"
995+ type="object"
996+ icon="gtk-ok"
997+ colspan='2'
998+ />
999+ </group>
1000+ <separator/>
1001+ <group col="2" colspan="2">
1002+ <field name="amount_tax_ret" colspan='2'/>
1003+ <field name="base_ret" colspan='2' />
1004+ </group>
1005+ </group>
1006 </page>
1007 </notebook>
1008 </form>
1009@@ -156,8 +177,12 @@
1010 <button colspan="2" name="compute_amount_wh" states="draft" string="Compute Withholding Vat" type="object" icon="terp-stock_format-scientific"/>
1011 <field name="amount_base_ret"/>
1012 <field name="total_tax_ret"/>
1013+<!--
1014 <field name="tot_amount_base_wh" groups='l10n_ve_withholding_iva.group_account_wh_iva_manager'/>
1015+-->
1016+<!--
1017 <field name="tot_amount_tax_wh" groups='l10n_ve_withholding_iva.group_account_wh_iva_manager'/>
1018+-->
1019 </group>
1020 </page>
1021 <page string="Other Information">
1022@@ -200,8 +225,10 @@
1023 <group col="2" colspan="2">
1024 <!-- <field name="amount_base_ret"/>-->
1025 <!-- <field name="total_tax_ret"/>-->
1026- <field name="tot_amount_base_wh"/>
1027- <field name="tot_amount_tax_wh"/>
1028+<!-- <field name="tot_amount_base_wh"/> -->
1029+<!-- <field name="tot_amount_tax_wh"/> -->
1030+ <field name="amount_base_ret"/>
1031+ <field name="total_tax_ret"/>
1032 </group>
1033 </page>
1034 <page string="Other Information">
1035
1036=== added directory 'l10n_ve_withholding_iva/wizard'
1037=== renamed directory 'l10n_ve_withholding_iva/wizard' => 'l10n_ve_withholding_iva/wizard.moved'
1038=== renamed file 'l10n_ve_withholding_iva/wizard/l10n_ve_withholding_iva_installer.xml' => 'l10n_ve_withholding_iva/wizard/l10n_ve_withholding_iva_installer.xml'
1039=== added directory 'l10n_ve_withholding_iva/workflow'
1040=== renamed directory 'l10n_ve_withholding_iva/workflow' => 'l10n_ve_withholding_iva/workflow.moved'
1041=== renamed file 'l10n_ve_withholding_iva/workflow/account_workflow.xml' => 'l10n_ve_withholding_iva/workflow/account_workflow.xml'
1042=== renamed file 'l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml' => 'l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml'
1043--- l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2011-12-22 00:20:54 +0000
1044+++ l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml 2011-12-28 02:13:23 +0000
1045@@ -16,16 +16,16 @@
1046
1047 <record id="act_confirmed" model="workflow.activity">
1048 <field name="wkf_id" ref="wh_iva_order"/>
1049+ <field name="action">write({'state':'confirmed'})</field>
1050+ <field name="kind">function</field>
1051+ <field name="name">confirmed</field>
1052+ </record>
1053+
1054+ <record id="act_done" model="workflow.activity">
1055+ <field name="wkf_id" ref="wh_iva_order"/>
1056 <field name="action">action_number()
1057 action_date_ret()
1058-write({'state':'confirmed'})</field>
1059- <field name="kind">function</field>
1060- <field name="name">confirmed</field>
1061- </record>
1062-
1063- <record id="act_done" model="workflow.activity">
1064- <field name="wkf_id" ref="wh_iva_order"/>
1065- <field name="action">action_move_create()
1066+action_move_create()
1067 write({'state':'done'})</field>
1068 <field name="kind">function</field>
1069 <field name="name">done</field>
1070@@ -34,6 +34,7 @@
1071 <record id="trans_draft_done" model="workflow.transition">
1072 <field name="act_from" ref="act_draft"/>
1073 <field name="act_to" ref="act_confirmed"/>
1074+ <field name="condition">check_vat_wh() and check_wh_taxes()</field>
1075 <field name="signal">wh_iva_confirmed</field>
1076 </record>
1077