Merge lp:~vauxoo/openerp-venezuela-localization/7.0-minor_fixes-rev03-hbto into lp:openerp-venezuela-localization

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/7.0-minor_fixes-rev03-hbto
Merge into: lp:openerp-venezuela-localization
Diff against target: 486 lines (+93/-91)
5 files modified
l10n_ve_fiscal_book/model/fiscal_book.py (+48/-35)
l10n_ve_fiscal_book/view/fiscal_book.xml (+2/-1)
l10n_ve_imex/model/customs_form.py (+16/-46)
l10n_ve_imex/model/invoice.py (+27/-8)
l10n_ve_imex/view/customs_form.xml (+0/-1)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/7.0-minor_fixes-rev03-hbto
Reviewer Review Type Date Requested Status
hbto [Vauxoo] http://www.vauxoo.com Disapprove
Review via email: mp+220089@code.launchpad.net
To post a comment you must log in.
Revision history for this message
hbto [Vauxoo] http://www.vauxoo.com (humbertoarocha) wrote :
review: Disapprove

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_fiscal_book/model/fiscal_book.py'
2--- l10n_ve_fiscal_book/model/fiscal_book.py 2014-05-15 18:24:33 +0000
3+++ l10n_ve_fiscal_book/model/fiscal_book.py 2014-05-19 15:26:08 +0000
4@@ -185,6 +185,17 @@
5 res[fb_brw.id]['get_previous_wh_sum']
6 return res
7
8+ def _get_do_adjustment_vat_tax_sum(self, cr, uid, ids, field_name, arg,
9+ context=None):
10+ res = {}
11+ for fb_brw in self.browse(cr, uid, ids, context=context):
12+ avts = 0
13+ for fbl_brw in fb_brw.fbl_ids:
14+ if fbl_brw.doc_type == 'AJST':
15+ avts += fbl_brw.get_wh_vat
16+ res[fb_brw.id] = avts
17+ return res
18+
19 _description = "Venezuela's Sale & Purchase Fiscal Books"
20 _name = 'fiscal.book'
21 _inherit = ['mail.thread']
22@@ -439,6 +450,9 @@
23 " For Purchase Book it sums Reduced VAT Tax column for domestic" \
24 " transactions. For Sale Book it sums Tax Payer and Non-Tax Payer" \
25 " Reduced VAT Tax columns"),
26+ 'do_adjustment_vat_tax_sum': fields.function(
27+ _get_do_adjustment_vat_tax_sum, method=True, type='float',
28+ string='Adjustment VAT Taxed Amount'),
29
30 #~ Apply only for sale book
31 #~ Totalization fields for tax payer and Non-Tax Payer transactions
32@@ -759,7 +773,7 @@
33
34 def get_order_criteria_adjustment(self, cr, uid, type, context=None):
35 return type == 'sale' \
36- and 'accounting_date asc, invoice_number asc' \
37+ and 'accounting_date asc, nro_ctrl asc' \
38 or 'emission_date asc, invoice_number asc'
39
40 def get_order_criteria(self, cr, uid, type, context=None):
41@@ -850,10 +864,8 @@
42 """
43 context = context or {}
44 data = []
45- my_rank = 1
46 iwdl_obj = self.pool.get('account.wh.iva.line')
47 cf_obj = self.pool.get('customs.form')
48- fbl_obj = self.pool.get('fiscal.book.line')
49 fb_brw = self.browse(cr, uid, fb_id, context=context)
50 rp_obj = self.pool.get('res.partner')
51
52@@ -871,7 +883,6 @@
53 rp_brw = rp_obj._find_accounting_partner(iwdl_brw.retention_id.partner_id)
54 values = {
55 'iwdl_id': iwdl_brw.id,
56- 'rank': my_rank,
57 'type': t_type,
58 'accounting_date': iwdl_brw.date_ret or False,
59 'emission_date': iwdl_brw.date or iwdl_brw.date_ret or False,
60@@ -889,7 +900,6 @@
61 or iwdl_brw.invoice_id.date_invoice,
62 'wh_rate': iwdl_brw.wh_iva_rate,
63 }
64- my_rank += 1
65 data.append((0, 0, values))
66
67 #~ add book lines for invoices
68@@ -901,6 +911,7 @@
69 context=context)
70 doc_type = self.get_doc_type(cr, uid, inv_id=inv_brw.id,
71 context=context)
72+
73 rp_brw = rp_obj._find_accounting_partner(inv_brw.partner_id)
74
75 iwdl_brw = iwdl_obj.browse(cr, uid, iwdl_id, context=context) if \
76@@ -908,7 +919,6 @@
77
78 values = {
79 'invoice_id': inv_brw.id,
80- 'rank': my_rank,
81 'emission_date': (not imex_invoice) \
82 and (inv_brw.date_document or inv_brw.date_invoice) \
83 or False,
84@@ -948,7 +958,6 @@
85 'wh_number': iwdl_brw and iwdl_brw.retention_id.number or '',
86 'wh_rate': iwdl_brw and iwdl_brw.wh_iva_rate or 0.0,
87 }
88- my_rank += 1
89 data.append((0, 0, values))
90
91 #~ add book lines for customs forms
92@@ -1225,20 +1234,18 @@
93
94 for fbl in self.browse(cr, uid, fb_id, context=context).fbl_ids:
95 if fbl.invoice_id:
96+ sign = 1 if fbl.doc_type != 'N/CR' else -1
97 tax_lines = fbl.type in ['im','ex'] \
98 and fbl.invoice_id.imex_tax_line \
99- or fbl.invoice_id.tax_line
100+ or fbl.invoice_id.tax_line
101 for ait in tax_lines:
102 if ait.tax_id.appl_type:
103 base_sum[fbl.type][ait.tax_id.appl_type] += \
104- ait.base_amount
105+ ait.base_amount * sign
106 tax_sum[fbl.type][ait.tax_id.appl_type] += \
107- ait.tax_amount
108- elif fbl.cf_id:
109- if fbl.type != 'do':
110- raise osv.except_osv(_('Programing Error!'),
111- _("Customs form lines are domestic transacctions"))
112- base_sum['do']['sdcf'] += fbl.vat_sdcf
113+ ait.tax_amount * sign
114+ else:
115+ raise osv.except_osv(_('Error!'),_('You must assign the Aliquot Type to: %s')%(ait.tax_id.name))
116
117 data = [ (0, 0, {'tax_type': ttype, 'op_type': optype,
118 'base_amount_sum': base_sum[optype][ttype],
119@@ -1260,16 +1267,17 @@
120 data = {}
121 #~ totalization of book tax amount and base amount fields
122 tax_amount = base_amount = 0.0
123- for fbl in self.browse(cr, uid, fb_id, context=context).fbl_ids:
124- if fbl.invoice_id:
125- taxes = fbl.type in ['im','ex'] \
126- and fbl.invoice_id.imex_tax_line \
127- or fbl.invoice_id.tax_line
128+ for fbl_brw in self.browse(cr, uid, fb_id, context=context).fbl_ids:
129+ sign = 1 if fbl_brw.doc_type != 'N/CR' else -1
130+ if fbl_brw.invoice_id:
131+ taxes = fbl_brw.type in ['im','ex'] \
132+ and fbl_brw.invoice_id.imex_tax_line \
133+ or fbl_brw.invoice_id.tax_line
134 for ait in taxes:
135 if ait.tax_id:
136- base_amount += ait.base_amount
137+ base_amount += ait.base_amount * sign
138 if ait.tax_id.ret:
139- tax_amount += ait.tax_amount
140+ tax_amount += ait.tax_amount * sign
141
142 data['tax_amount'] = tax_amount
143 data['base_amount'] = base_amount
144@@ -1394,7 +1402,7 @@
145 """
146 context = context or {}
147 res = 0.0
148- fbts_obj = self.pool.get('fiscal.book.taxes.summary')
149+ #~ fbts_obj = self.pool.get('fiscal.book.taxes.summary')
150
151 #~ Identifying the field
152 field_info = field_name[:-4].split('_')
153@@ -1428,22 +1436,24 @@
154 data = []
155 for fbl in self.browse(cr, uid, fb_id, context=context).fbl_ids:
156 if fbl.invoice_id:
157+ sign = 1 if fbl.doc_type != 'N/CR' else -1
158 amount_field_data = \
159- { 'total_with_iva': fbl.invoice_id.amount_untaxed,
160+ { 'total_with_iva': fbl.invoice_id.amount_untaxed * sign,
161 'vat_sdcf': 0.0, 'vat_exempt': 0.0 }
162 taxes = fbl.type in ['im','ex'] \
163 and fbl.invoice_id.imex_tax_line \
164 or fbl.invoice_id.tax_line
165 for ait in taxes:
166 if ait.tax_id:
167+
168 data.append((0, 0, {'fb_id': fb_id,
169 'fbl_id': fbl.id,
170 'ait_id': ait.id}))
171- amount_field_data['total_with_iva'] += ait.tax_amount
172+ amount_field_data['total_with_iva'] += ait.tax_amount * sign
173 if ait.tax_id.appl_type == 'sdcf':
174- amount_field_data['vat_sdcf'] += ait.base_amount
175+ amount_field_data['vat_sdcf'] += ait.base_amount * sign
176 if ait.tax_id.appl_type == 'exento':
177- amount_field_data['vat_exempt'] += ait.base_amount
178+ amount_field_data['vat_exempt'] += ait.base_amount * sign
179 else:
180 data.append((0, 0, {'fb_id':
181 fb_id, 'fbl_id': False, 'ait_id': ait.id}))
182@@ -1469,14 +1479,15 @@
183 tax_type = {'reduced': 'reducido', 'general': 'general',
184 'additional': 'adicional'}
185 for fbl_brw in self.browse(cr, uid, fb_id, context=context).fbl_ids:
186+ sign = 1 if fbl_brw.doc_type != 'N/CR' else -1
187 data = {}.fromkeys(field_names, 0.0)
188 for fbt_brw in fbl_brw.fbt_ids:
189 for field_name in field_names:
190 field_tax, field_amount = field_name[4:].split('_')
191 if fbt_brw.ait_id.tax_id.appl_type == tax_type[field_tax]:
192 data[field_name] += field_amount == 'base' \
193- and fbt_brw.base_amount \
194- or fbt_brw.tax_amount
195+ and fbt_brw.base_amount * sign \
196+ or fbt_brw.tax_amount * sign
197 fbl_obj.write(cr, uid, fbl_brw.id, data, context=context)
198 return True
199
200@@ -1643,7 +1654,7 @@
201 inv_brw = inv_obj.browse(cr, uid, inv_id, context=context)
202 if (inv_brw.type in ["in_invoice"] and inv_brw.parent_id) \
203 or inv_brw.type in ["in_refund"]:
204- res = "N/DE"
205+ res = "N/DB"
206 elif (inv_brw.type in ["out_invoice"] and inv_brw.parent_id) or \
207 inv_brw.type in ["out_refund"]:
208 res = "N/CR"
209@@ -1671,7 +1682,7 @@
210
211 def is_invoice_imex(self, cr, uid, inv_id, context=None):
212 """ Boolean method that verify is a invoice is imported by cheking the
213- customs form associated.
214+ customs form associated.
215 @param inv_id: invoice id
216 """
217 context = context or {}
218@@ -1724,8 +1735,9 @@
219 context = context or {}
220 res = {}.fromkeys(ids, 0.0)
221 for fbl_brw in self.browse(cr, uid, ids, context=context):
222+ sign = 1 if fbl_brw.doc_type != 'AJST' else -1
223 if fbl_brw.iwdl_id:
224- res[fbl_brw.id] = fbl_brw.iwdl_id.amount_tax_ret
225+ res[fbl_brw.id] = fbl_brw.iwdl_id.amount_tax_ret * sign
226 return res
227
228 def _get_based_tax_debit(self, cr, uid, ids, field_name, arg,
229@@ -1740,8 +1752,9 @@
230 awilt_obj = self.pool.get("account.wh.iva.line.tax")
231 for fbl_brw in self.browse(cr, uid, ids, context=context):
232 if fbl_brw.iwdl_id:
233+ sign = 1 if fbl_brw.doc_type != 'AJST' else -1
234 for tax in fbl_brw.iwdl_id.tax_line:
235- res[fbl_brw.id] += tax.amount
236+ res[fbl_brw.id] += tax.amount * sign
237 return res
238
239 def _compute_vat_rates(self, cr, uid, ids, field_name, arg, context=None):
240@@ -1890,11 +1903,11 @@
241 help="Vat reduced tax rate "),
242 'vat_general_rate': fields.function(
243 _compute_vat_rates, method=True, type='float',
244- string='Reduced rate', multi='all',
245+ string='General rate', multi='all',
246 help="Vat general tax rate "),
247 'vat_additional_rate': fields.function(
248 _compute_vat_rates, method=True, type='float',
249- string='Reduced rate', multi='all',
250+ string='Additional rate', multi='all',
251 help="Vat plus additional tax rate "),
252 }
253
254
255=== modified file 'l10n_ve_fiscal_book/view/fiscal_book.xml'
256--- l10n_ve_fiscal_book/view/fiscal_book.xml 2013-06-14 16:46:51 +0000
257+++ l10n_ve_fiscal_book/view/fiscal_book.xml 2014-05-19 15:26:08 +0000
258@@ -240,9 +240,10 @@
259 </page>
260
261 </notebook>
262- <group string="Total Taxing Base &amp; Total Taxed Amount" col="4">
263+ <group string="Total Taxing Base &amp; Total Taxed Amount" col="6">
264 <field name="base_amount"/>
265 <field name="tax_amount"/>
266+ <field name="do_adjustment_vat_tax_sum"/>
267 </group>
268 <div class="oe_chatter">
269 <field name="message_follower_ids" widget="mail_followers"/>
270
271=== modified file 'l10n_ve_imex/model/customs_form.py'
272--- l10n_ve_imex/model/customs_form.py 2013-12-11 19:25:04 +0000
273+++ l10n_ve_imex/model/customs_form.py 2014-05-19 15:26:08 +0000
274@@ -120,8 +120,6 @@
275 readonly=True,
276 help="The move of this entry line."),
277 'narration': fields.text('Notes', readonly=False),
278- 'invoice_ids': fields.one2many('account.invoice', 'customs_form_id',
279- 'Related invoices', readonly=True),
280 'state': fields.selection([('draft', 'Draft'), ('open', 'Open'),
281 ('done', 'Done'), ('cancel', 'Cancelled')],
282 string='State', required=True,
283@@ -150,7 +148,6 @@
284 lines = []
285 context = context or {}
286 company_id = context.get('f86_company_id')
287- f86_cfg = context.get('f86_config')
288 rp_obj = self.pool.get('res.partner')
289
290 #~ expenses
291@@ -159,13 +156,15 @@
292 acc_part_brw = rp_obj._find_accounting_partner(line.tax_code.partner_id)
293 if line.tax_code.vat_detail:
294 for vat in line.imex_tax_line:
295- debits.append(
296- {'account_id': vat.tax_id.account_collected_id.id,
297- 'amount': vat.tax_amount,
298- 'tax_info': ' (%s)' % vat.tax_id.name})
299+ if vat.tax_amount:
300+ debits.append(
301+ {'account_id': vat.tax_id.account_collected_id.id,
302+ 'amount': vat.tax_amount,
303+ 'tax_info': ' (%s)' % vat.tax_id.name})
304 else:
305- debits.append({'account_id': line.tax_code.account_id.id,
306- 'amount': line.amount, 'tax_info': ''})
307+ if line.amount:
308+ debits.append({'account_id': line.tax_code.account_id.id,
309+ 'amount': line.amount, 'tax_info': ''})
310
311 credit_account_id = \
312 acc_part_brw.property_account_payable.id
313@@ -201,8 +200,6 @@
314 obj_cfg = self.pool.get('customs.form.config')
315 company_id = self.pool.get('res.users').browse(
316 cr, uid, uid, context=context).company_id.id
317- company = self.pool.get('res.company').browse(cr, uid, company_id,
318- context=context)
319 cfg_id = obj_cfg.search(cr, uid, [('company_id', '=', company_id)],
320 context=context)
321 if cfg_id:
322@@ -211,7 +208,6 @@
323 raise osv.except_osv(_('Error!'),
324 _('Please set a valid configuration in \
325 the imex settings'))
326- date = time.strftime('%Y-%m-%d')
327 context.update({'f86_company_id': company_id, 'f86_config': f86_cfg})
328 move_ids = []
329 for f86 in so_brw:
330@@ -222,24 +218,17 @@
331 'company_id': company_id,
332 'state': 'draft',
333 'to_check': False,
334- 'narration': _('Form 86 # %s\n\tReference: %s\n\tBroker: \
335- %s\n\nRelated invoices:')
336+ 'narration': _('Form 86 # %s\n\tReference: %s\n\tBroker: %s')
337 % (f86.name, f86.ref or '', f86.broker_id.name or ''),
338 }
339- for inv in f86.invoice_ids:
340- str_inv = _('\n\tSupplier: %-40s Reference: %s') % \
341- (inv.partner_id.name, inv.supplier_invoice_number)
342- move['narration'] = '%s%s' % (move['narration'], str_inv)
343- lines = self.create_account_move_lines(cr, uid, f86,
344- context=context)
345+ lines = self.create_account_move_lines(cr, uid, f86, context=context)
346 if lines:
347 move.update({'line_id': lines})
348 move_id = obj_move.create(cr, uid, move, context=context)
349 obj_move.post(cr, uid, [move_id], context=context)
350 if move_id:
351 move_ids.append(move_id)
352- self.write(cr, uid, f86.id, {'move_id': move_id},
353- context=context)
354+ self.write(cr, uid, f86.id, {'move_id': move_id}, context=context)
355 return move_ids
356
357 def button_draft(self, cr, uid, ids, context=None):
358@@ -263,7 +252,6 @@
359 f86 = self.browse(cr, uid, ids[0], context=context)
360 f86_move_id = f86.move_id.id if f86 and f86.move_id else False
361 vals = {'state': 'cancel', 'move_id': 0}
362- res = self.write(cr, uid, ids, vals, context=context)
363 if f86_move_id:
364 self.pool.get('account.move').unlink(cr, uid, [f86_move_id],
365 context=context)
366@@ -273,12 +261,11 @@
367 return True
368
369 def test_open(self, cr, uid, ids, *args):
370- so_brw = self.browse(cr, uid, ids, context={})
371- for f86 in so_brw:
372+ ids = isinstance(ids, (int, long)) and [ids] or ids
373+ for f86 in self.browse(cr, uid, ids, context={}):
374 if f86.amount_total <= 0:
375 raise osv.except_osv(_('Warning!'),
376 _('You must indicate a amount'))
377- f86_invoices = [i.id for i in f86.invoice_ids] # related inv list
378 vat_invoices = [] # for tax (vat) related invoices
379 for line in f86.cfl_ids:
380 if line.vat_detail:
381@@ -290,17 +277,8 @@
382 if abs(vat_total) > 0.001:
383 raise osv.except_osv(
384 _('Warning!'),
385- _('The vat detail data does not correspond with \
386- vat amount in line: %s') % line.tax_code.name)
387- #~ Validate related invoices vs invoice_ids (if vat)
388- if set(f86_invoices) != set(vat_invoices):
389- #~ No todas las facturas relacionadas con la planilla de
390- #~ importación se corresponden con las facturas relacionadas
391- #~ al IVA
392- raise osv.except_osv(
393- _('Warning!'),
394- _('Not all invoices related to the import spreadsheet \
395- correspond to invoices relating to VAT'))
396+ _('The vat detail data does not correspond with '
397+ 'vat amount in line: %s') % line.tax_code.name)
398 return True
399
400 def test_done(self, cr, uid, ids, *args):
401@@ -311,21 +289,13 @@
402 raise osv.except_osv(
403 _('Error!'),
404 _('Multiple operations not allowed'))
405- for f86 in self.browse(cr, uid, ids, context={}):
406+ for f86 in self.browse(cr, uid, ids, context=None):
407 #~ Validate account_move.state != draft
408 if f86.move_id and f86.move_id.state != 'draft':
409 raise osv.except_osv(
410 _('Error!'),
411 _('Can\'t cancel a import while account move state <> \
412 "Draft" (%s)') % f86.move_id.name)
413- #~ Validate state of related invoices (only state = draft)
414- for inv in f86.invoice_ids:
415- if inv.state != 'draft':
416- raise osv.except_osv(
417- _('Error!'),
418- _('Can\'t cancel a import while invoice state <> \
419- "Draft" ([%s] %s, %s)') % inv.name,
420- inv.partner_id.name, inv.supplier_invoice_number)
421 return True
422
423
424
425=== modified file 'l10n_ve_imex/model/invoice.py'
426--- l10n_ve_imex/model/invoice.py 2014-03-17 12:57:59 +0000
427+++ l10n_ve_imex/model/invoice.py 2014-05-19 15:26:08 +0000
428@@ -34,19 +34,38 @@
429
430 _inherit = "account.invoice"
431
432+ def _get_imex_invoices(self, cr, uid, ids, name, args, context=None):
433+ context = context or {}
434+ ids = isinstance(ids, (int, long)) and [ids] or ids
435+ res = {}.fromkeys(ids, False)
436+ for inv in self.browse(cr, uid, ids, context={}):
437+ for ait in inv.imex_tax_line:
438+ res[inv.id] = ait.cfl_id.customs_form_id.id
439+ return res
440+
441+ def _get_inv_from_ait(self, cr, uid, ids, context=None):
442+ '''
443+ Returns
444+ '''
445+ context = context or {}
446+ ids = isinstance(ids, (int, long)) and [ids] or ids
447+ ait_obj = self.pool.get('account.invoice.tax')
448+ ait_brw = ait_obj.browse(cr, uid, ids, context=context)
449+ return list(set([i.invoice_id.id for i in ait_brw if i.imex_inv_id]))
450+
451 _columns = {
452- 'customs_form_id': fields.many2one(
453- 'customs.form', 'Customs form', change_default=True,
454- required=False, readonly=True,
455- states={'draft': [('readonly', False)]}, ondelete='restrict',
456- domain=[('state', '=', ('draft'))],
457- help="The related form 86 for this import invoice (only draft)"),
458+ 'customs_form_id': fields.function(
459+ _get_imex_invoices, method=True,
460+ type='many2one', relation='customs.form',
461+ string='Customs form',
462+ store={
463+ 'account.invoice.tax':(_get_inv_from_ait, ['imex_inv_id'], 50),
464+ }, help="This is the VAT Withholding Document where this invoice is being withheld"),
465 'imex_tax_line': fields.one2many(
466 'account.invoice.tax', 'imex_inv_id', 'Vat lines', readonly=True,
467 attrs="{'readonly':[('vat_detail','=',True)], \
468 'required':[('vat_detail','=',True)]}",),
469- 'expedient':fields.boolean('Dossier', readonly=True,
470- states={'draft':[('readonly',False)]},
471+ 'expedient':fields.boolean('Dossier',
472 help="If it is true, it means this is a \
473 landindg form, you will need to load this \
474 format as an purchase invoice to declarate \
475
476=== modified file 'l10n_ve_imex/view/customs_form.xml'
477--- l10n_ve_imex/view/customs_form.xml 2013-06-10 20:53:35 +0000
478+++ l10n_ve_imex/view/customs_form.xml 2014-05-19 15:26:08 +0000
479@@ -78,7 +78,6 @@
480 <page string="Other">
481 <label string="Notes" colspan="4"/>
482 <field name="narration" colspan="4" nolabel="1"/>
483- <field name="invoice_ids" colspan="4" nolabel="1"/>
484 <field name="move_id"/>
485 <field name="company_id"/>
486 </page>