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: Superseded
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/hbto_wh_iva
Merge into: lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
Diff against target: 1153 lines (+597/-218) (has conflicts)
11 files modified
l10n_ve_withholding/invoice.py (+22/-17)
l10n_ve_withholding_iva/__init__.py (+1/-7)
l10n_ve_withholding_iva/__openerp__.py (+12/-12)
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 (+334/-130)
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 (+53/-19)
l10n_ve_withholding_iva/workflow/wh_iva_workflow.xml (+9/-8)
Text conflict in l10n_ve_withholding_iva/model/wh_iva.py
Text conflict in l10n_ve_withholding_iva/view/wh_iva_view.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+86623@code.launchpad.net

This proposal has been superseded by a proposal from 2011-12-22.

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