Merge lp:~inddiana/diana-addons/nota_credito_desc_financieros into lp:diana-addons/6.0
- nota_credito_desc_financieros
- Merge into trunk-2
Proposed by
[SISB] Aryrosa Fuentes
Status: | Merged |
---|---|
Merged at revision: | 12 |
Proposed branch: | lp:~inddiana/diana-addons/nota_credito_desc_financieros |
Merge into: | lp:diana-addons/6.0 |
Diff against target: |
499 lines (+444/-0) 10 files modified
notas_de_credito/__init__.py (+4/-0) notas_de_credito/__openerp__.py (+22/-0) notas_de_credito/model/__init__.py (+21/-0) notas_de_credito/model/product_tax.py (+32/-0) notas_de_credito/security/ir.model.access.csv (+2/-0) notas_de_credito/security/nc_des_financiero_security.xml (+13/-0) notas_de_credito/view/nota_credito_desc_financiero.xml (+62/-0) notas_de_credito/wizard/__init__.py (+21/-0) notas_de_credito/wizard/nota_credito_1_x_100_wizard.py (+235/-0) notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml (+32/-0) |
To merge this branch: | bzr merge lp:~inddiana/diana-addons/nota_credito_desc_financieros |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aristóbulo Meneses | Pending | ||
Review via email: mp+161058@code.launchpad.net |
Commit message
Description of the change
[ADD] Nuevo modulo para aplicar notas de credito a descuentos financieros de 1 porciento.
Se debe comentar el constraint en presupuesto. Se debe configurar los productos, asociar al grupo la categoria de estos productos, asociar el usuario al nuevo grupo.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'notas_de_credito' |
2 | === added file 'notas_de_credito/__init__.py' |
3 | --- notas_de_credito/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ notas_de_credito/__init__.py 2013-04-26 02:38:26 +0000 |
5 | @@ -0,0 +1,4 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | + |
8 | +import model |
9 | +import wizard |
10 | |
11 | === added file 'notas_de_credito/__openerp__.py' |
12 | --- notas_de_credito/__openerp__.py 1970-01-01 00:00:00 +0000 |
13 | +++ notas_de_credito/__openerp__.py 2013-04-26 02:38:26 +0000 |
14 | @@ -0,0 +1,22 @@ |
15 | +# -*- coding: utf-8 -*- |
16 | + |
17 | +{ |
18 | + "name" : "Registro nota de credito por descuentos financieros", |
19 | + "version" : "1.0", |
20 | + "author" : "Industrias Diana C.A.", |
21 | + "category" : "Interfaces", |
22 | + "website" : "http://www.industriasdiana.gob.ve", |
23 | + "depends" : ["sisb_ventas", |
24 | + 'l10n_ve_presupuesto', |
25 | + ], |
26 | + "description": """Wizard para registrar nota de credito por descuentos financieros para facturas de ventas. Incluye la informacion para presupuesto.""", |
27 | + "update_xml" : [ |
28 | + 'security/nc_des_financiero_security.xml', |
29 | + 'security/ir.model.access.csv', |
30 | + 'view/nota_credito_desc_financiero.xml', |
31 | + 'wizard/nota_credito_1_x_100_wizard.xml', |
32 | + ], |
33 | + "active": False, |
34 | + "installable": True, |
35 | + 'data' : [], |
36 | +} |
37 | |
38 | === added directory 'notas_de_credito/i18n' |
39 | === added directory 'notas_de_credito/model' |
40 | === added file 'notas_de_credito/model/__init__.py' |
41 | --- notas_de_credito/model/__init__.py 1970-01-01 00:00:00 +0000 |
42 | +++ notas_de_credito/model/__init__.py 2013-04-26 02:38:26 +0000 |
43 | @@ -0,0 +1,21 @@ |
44 | +#!/usr/bin/python |
45 | +# -*- encoding: utf-8 -*- |
46 | +###############Credits######################################################### |
47 | +# Finance by: Industrias Diana, C.A. http://www.industriasdiana.gob.ve |
48 | +############################################################################### |
49 | +# This program is free software: you can redistribute it and/or modify |
50 | +# it under the terms of the GNU Affero General Public License as published by |
51 | +# the Free Software Foundation, either version 3 of the License, or |
52 | +# (at your option) any later version. |
53 | +# |
54 | +# This program is distributed in the hope that it will be useful, |
55 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
56 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
57 | +# GNU Affero General Public License for more details. |
58 | +# |
59 | +# You should have received a copy of the GNU Affero General Public License |
60 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
61 | +############################################################################### |
62 | + |
63 | + |
64 | +import product_tax |
65 | |
66 | === added file 'notas_de_credito/model/product_tax.py' |
67 | --- notas_de_credito/model/product_tax.py 1970-01-01 00:00:00 +0000 |
68 | +++ notas_de_credito/model/product_tax.py 2013-04-26 02:38:26 +0000 |
69 | @@ -0,0 +1,32 @@ |
70 | +# -*- coding: utf-8 -*- |
71 | +""" |
72 | +Módulo utilizado para configurar los productos a escoger para asociar a las notas de credito del 1 porciento segun los impuestos |
73 | +""" |
74 | + |
75 | +import time |
76 | +import netsvc |
77 | +from osv import fields, osv |
78 | +from tools import config |
79 | +from tools.translate import _ |
80 | +import decimal_precision as dp |
81 | + |
82 | +#---------------------------------------------------------- |
83 | +# Productos tipo servicio y el impuesto asociado |
84 | +#---------------------------------------------------------- |
85 | + |
86 | +class nota_credito_product_tax(osv.osv): |
87 | + _name = "nota.credito.product_tax" |
88 | + _description = "Productos de Notas de Credito" |
89 | + _order = "name" |
90 | + |
91 | + _columns = { |
92 | + 'name': fields.char('Nombre', size=64, select=True, required=True), |
93 | + 'tax_id': fields.many2one('account.tax', 'Impuesto', required=True), |
94 | + 'product_id': fields.many2one('product.product', 'Servicio de Descuento', required=True), |
95 | + } |
96 | + _sql_constraints = [ |
97 | + ('tax_product_uniq', 'unique (tax_id, product_id)', 'The combination of tax and product must be unique !'), |
98 | + ] |
99 | + |
100 | + |
101 | +nota_credito_product_tax() |
102 | |
103 | === added directory 'notas_de_credito/security' |
104 | === added file 'notas_de_credito/security/ir.model.access.csv' |
105 | --- notas_de_credito/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
106 | +++ notas_de_credito/security/ir.model.access.csv 2013-04-26 02:38:26 +0000 |
107 | @@ -0,0 +1,2 @@ |
108 | +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
109 | +"access_nc_des_financiero","nota_credito.product_tax","model_nota_credito_product_tax","group_nc_des_financiero_user",1,1,1,0 |
110 | |
111 | === added file 'notas_de_credito/security/nc_des_financiero_security.xml' |
112 | --- notas_de_credito/security/nc_des_financiero_security.xml 1970-01-01 00:00:00 +0000 |
113 | +++ notas_de_credito/security/nc_des_financiero_security.xml 2013-04-26 02:38:26 +0000 |
114 | @@ -0,0 +1,13 @@ |
115 | +<?xml version="1.0" encoding="utf-8"?> |
116 | +<openerp> |
117 | + <data noupdate="0"> |
118 | + |
119 | +<!-- |
120 | + Grupo |
121 | +--> |
122 | + <record id="group_nc_des_financiero_user" model="res.groups"> |
123 | + <field name="name">NC para Descuento Financiero / User</field> |
124 | + </record> |
125 | + |
126 | + </data> |
127 | +</openerp> |
128 | |
129 | === added directory 'notas_de_credito/view' |
130 | === added file 'notas_de_credito/view/nota_credito_desc_financiero.xml' |
131 | --- notas_de_credito/view/nota_credito_desc_financiero.xml 1970-01-01 00:00:00 +0000 |
132 | +++ notas_de_credito/view/nota_credito_desc_financiero.xml 2013-04-26 02:38:26 +0000 |
133 | @@ -0,0 +1,62 @@ |
134 | +<?xml version="1.0"?> |
135 | +<openerp> |
136 | + <data> |
137 | + <record id="view_nc_product_tax_form" model="ir.ui.view"> |
138 | + <field name="name">nota.credito.product_tax.form</field> |
139 | + <field name="model">nota.credito.product_tax</field> |
140 | + <field name="type">form</field> |
141 | + <field name="arch" type="xml"> |
142 | + <form string="Impuestos y productos asociados para la nota de credito"> |
143 | + <group colspan="4" col="6"> |
144 | + <group colspan="2" col="2"> |
145 | + <field name="name"/> |
146 | + <field name="tax_id" domain="[('type_tax_use','=','sale')]"/> |
147 | + </group> |
148 | + <group colspan="2" col="2"> |
149 | + <field name="product_id" domain="[('type','=','service')]"/> |
150 | + </group> |
151 | + </group> |
152 | + </form> |
153 | + </field> |
154 | + </record> |
155 | + |
156 | + <record id="view_nc_product_tax_search" model="ir.ui.view"> |
157 | + <field name="name">nota.credito.product_tax.search</field> |
158 | + <field name="model">nota.credito.product_tax</field> |
159 | + <field name="type">search</field> |
160 | + <field name="arch" type="xml"> |
161 | + <search string="Impuestos y productos"> |
162 | + <field name="name"/> |
163 | + <field name="tax_id"/> |
164 | + <field name="product_id"/> |
165 | + </search> |
166 | + </field> |
167 | + </record> |
168 | + |
169 | + <record id="view_nc_product_tax_tree" model="ir.ui.view"> |
170 | + <field name="name">nota.credito.product_tax.tree</field> |
171 | + <field name="model">nota.credito.product_tax</field> |
172 | + <field name="type">tree</field> |
173 | + <field name="priority" eval="2"/> |
174 | + <field name="arch" type="xml"> |
175 | + <tree string="Impuestos y productos"> |
176 | + <field name="name"/> |
177 | + <field name="tax_id"/> |
178 | + <field name="product_id"/> |
179 | + </tree> |
180 | + </field> |
181 | + </record> |
182 | + |
183 | + <record id="action_nc_product_tax_form" model="ir.actions.act_window"> |
184 | + <field name="name">Impuestos y productos</field> |
185 | + <field name="res_model">nota.credito.product_tax</field> |
186 | + <field name="type">ir.actions.act_window</field> |
187 | + <field name="view_type">form</field> |
188 | + <field name="view_id" ref="view_nc_product_tax_tree"/> |
189 | + <field name="search_view_id" ref="view_nc_product_tax_search"/> |
190 | + <field name="help">Configurar los productos utilizados por cada impuesto en las notas de credito para descuentos financieros en ventas.</field> |
191 | + </record> |
192 | + <menuitem id="menu_action_nc_product_tax_desc_fin_form" name="Impuestos y productos para descuentos financieros" parent="account.menu_finance_configuration"/> |
193 | + <menuitem action="action_nc_product_tax_form" id="menu_action_nc_product_tax_form" parent="menu_action_nc_product_tax_desc_fin_form"/> |
194 | + </data> |
195 | +</openerp> |
196 | |
197 | === added directory 'notas_de_credito/wizard' |
198 | === added file 'notas_de_credito/wizard/__init__.py' |
199 | --- notas_de_credito/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
200 | +++ notas_de_credito/wizard/__init__.py 2013-04-26 02:38:26 +0000 |
201 | @@ -0,0 +1,21 @@ |
202 | +#!/usr/bin/python |
203 | +# -*- encoding: utf-8 -*- |
204 | +###############Credits######################################################### |
205 | +# Finance by: Industrias Diana, C.A. http://www.industriasdiana.gob.ve |
206 | +############################################################################### |
207 | +# This program is free software: you can redistribute it and/or modify |
208 | +# it under the terms of the GNU Affero General Public License as published by |
209 | +# the Free Software Foundation, either version 3 of the License, or |
210 | +# (at your option) any later version. |
211 | +# |
212 | +# This program is distributed in the hope that it will be useful, |
213 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
214 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
215 | +# GNU Affero General Public License for more details. |
216 | +# |
217 | +# You should have received a copy of the GNU Affero General Public License |
218 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
219 | +############################################################################### |
220 | + |
221 | + |
222 | +import nota_credito_1_x_100_wizard |
223 | |
224 | === added file 'notas_de_credito/wizard/nota_credito_1_x_100_wizard.py' |
225 | --- notas_de_credito/wizard/nota_credito_1_x_100_wizard.py 1970-01-01 00:00:00 +0000 |
226 | +++ notas_de_credito/wizard/nota_credito_1_x_100_wizard.py 2013-04-26 02:38:26 +0000 |
227 | @@ -0,0 +1,235 @@ |
228 | +# -*- encoding: utf-8 -*- |
229 | +############################################################################## |
230 | +# Copyright (c) 2012 Industrias Diana C.A. |
231 | +# All Rights Reserved. |
232 | +# |
233 | +# WARNING: This program as such is intended to be used by professional |
234 | +# programmers who take the whole responsability of assessing all potential |
235 | +# consequences resulting from its eventual inadequacies and bugs |
236 | +# End users who are looking for a ready-to-use solution with commercial |
237 | +# garantees and support are strongly adviced to contract a Free Software |
238 | +# Service Company |
239 | +# |
240 | +# This program is Free Software; you can redistribute it and/or |
241 | +# modify it under the terms of the GNU General Public License |
242 | +# as published by the Free Software Foundation; either version 2 |
243 | +# of the License, or (at your option) any later version. |
244 | +# |
245 | +# This program is distributed in the hope that it will be useful, |
246 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
247 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
248 | +# GNU General Public License for more details. |
249 | +# |
250 | +# You should have received a copy of the GNU General Public License |
251 | +# along with this program; if not, write to the Free Software |
252 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
253 | +############################################################################### |
254 | +from datetime import datetime, timedelta |
255 | +from dateutil.relativedelta import relativedelta |
256 | +import time |
257 | + |
258 | +from osv import osv |
259 | +from osv import fields |
260 | +import sys |
261 | +from tools.translate import _ |
262 | +import decimal_precision as dp |
263 | +import netsvc |
264 | + |
265 | +class nota_credito_1_x_100_wizard(osv.osv_memory): |
266 | + """ |
267 | + Forzar la confirmación del presupuesto para convertirse en un pedido de venta. |
268 | + """ |
269 | + _name = "nota.credito.1_x_100.wizard" |
270 | + |
271 | + _description = "Nota de Credito por Descuento Financiero" |
272 | + _columns = { |
273 | + 'descuento': fields.integer('Descuento (%)', digits_compute= dp.get_precision('Account')), |
274 | + } |
275 | + |
276 | + _defaults = { |
277 | + 'descuento': 1 |
278 | + } |
279 | + |
280 | + def _make_invoice(self, cr, uid, cabecera, lines, descuento, context=None): |
281 | + journal_obj = self.pool.get('account.journal') |
282 | + inv_obj = self.pool.get('account.invoice') |
283 | + obj_invoice_line = self.pool.get('account.invoice.line') |
284 | + if context is None: |
285 | + context = {} |
286 | + |
287 | + journal_id = cabecera.journal_id.sale_shop_id and cabecera.journal_id.sale_shop_id.refund_journal_id and cabecera.journal_id.sale_shop_id.refund_journal_id.id or False |
288 | + if not journal_id: |
289 | + raise osv.except_osv(_('Error !'), |
290 | + _('There is no sales journal defined for this return: "%s"') % (cabecera.name)) |
291 | + |
292 | + a = cabecera.partner_id.property_account_receivable.id |
293 | + |
294 | + inv = { |
295 | + 'name': 'RECTIFICA A ' + cabecera.number + ' DESCONTANDO EL ' + str(descuento) + '%', |
296 | + 'origin': cabecera.origin, |
297 | + 'type': 'out_refund', |
298 | + 'reference': cabecera.number, |
299 | + 'account_id': a, |
300 | + 'partner_id': cabecera.partner_id.id, |
301 | + 'journal_id': journal_id, |
302 | + 'address_invoice_id': cabecera.address_invoice_id.id, |
303 | + 'address_contact_id': cabecera.address_contact_id and cabecera.address_contact_id.id or False, |
304 | + 'invoice_line': [(6, 0, lines)], |
305 | + 'currency_id': cabecera.currency_id.id, |
306 | + 'comment': 'Descuento financiero al ' + str(descuento) + '%', |
307 | + 'fiscal_position': cabecera.partner_id.property_account_position.id, |
308 | + 'date_invoice': time.strftime('%Y-%m-%d'), |
309 | + 'company_id': cabecera.company_id.id, |
310 | + 'user_id': cabecera.user_id and cabecera.user_id.id or False, |
311 | + 'parent_id': cabecera.id, |
312 | + 'address_shipping_id': cabecera.address_shipping_id.id, |
313 | + } |
314 | + |
315 | + inv_id = inv_obj.create(cr, uid, inv) |
316 | + inv_obj.button_compute(cr, uid, [inv_id]) |
317 | + |
318 | + return inv_id |
319 | + |
320 | + def action_invoice_create(self, cr, uid, ids, res_ids, descuento, context=None): |
321 | + if context is None: |
322 | + context = {} |
323 | + |
324 | + invoice_ids_refund = [] |
325 | + |
326 | + invoice = self.pool.get('account.invoice') |
327 | + obj_invoice_tax_ids = self.pool.get('account.invoice.tax') |
328 | + if context is None: |
329 | + context = {} |
330 | + |
331 | + for out_inv in invoice.browse(cr, uid, res_ids, context=context): |
332 | + invoices = {} |
333 | + inv_line_id = False |
334 | + create_ids = [] |
335 | + #Buscar los impuesto de donde se van a sacar las lineas de la factura |
336 | + ait_ids = obj_invoice_tax_ids.search(cr, uid, [('invoice_id','=',out_inv.id)],context=context) |
337 | + #Por cada linea de impuesto crear una linea de la factura rectificativa |
338 | + for line in obj_invoice_tax_ids.browse(cr, uid, ait_ids, context=context): |
339 | + product_tax_id = self.pool.get('nota.credito.product_tax').search(cr, uid, [('tax_id','=',line.tax_id.id)], context=context) |
340 | + |
341 | + if not product_tax_id: |
342 | + raise osv.except_osv(_('Error !'), |
343 | + _('There is no product for invoice refund defined ' \ |
344 | + 'for this tax: "%s" ') % \ |
345 | + (line.tax_id.name)) |
346 | + |
347 | + product_tax = self.pool.get('nota.credito.product_tax').browse(cr, uid, product_tax_id[0], context=context) |
348 | + |
349 | + #La cuenta de ingreso del producto |
350 | + a = product_tax.product_id.product_tmpl_id.property_account_expense.id |
351 | + if not a: |
352 | + a = product_tax.product_id.categ_id.property_account_expense_categ.id |
353 | + if not a: |
354 | + a = self.get_product_category_account(cr,uid,product_tax.product_id.categ_id.id,"property_account_expense_categ",context=context) |
355 | + if not a: |
356 | + raise osv.except_osv(_('Error !'), |
357 | + _('There is no income account defined ' \ |
358 | + 'for this product: "%s" (id:%d)') % \ |
359 | + (product_tax.product_id.name, product_tax.product_id.id,)) |
360 | + |
361 | + inv_line_id = self.pool.get('account.invoice.line').create(cr, uid, { |
362 | + 'name': self.pool.get('product.product').name_get(cr, uid, [product_tax.product_id.id])[0][1][:128], |
363 | + 'origin': out_inv.origin, |
364 | + 'account_id': a, |
365 | + 'price_unit': line.base * descuento/100, |
366 | + 'quantity': 1, |
367 | + 'discount': 0.00, |
368 | + 'uos_id': product_tax.product_id.uom_id.id, |
369 | + 'product_id': product_tax.product_id.id, |
370 | + 'invoice_line_tax_id': [(6, 0, [product_tax.tax_id.id])], |
371 | + 'note': 'Descuento financiero al ' + str(descuento) + '%', |
372 | + 'account_analytic_id': out_inv.journal_id.sale_shop_id and out_inv.journal_id.sale_shop_id.project_id and out_inv.journal_id.sale_shop_id.project_id.id or False, |
373 | + 'accion_especifica_id': out_inv.journal_id.sale_shop_id and out_inv.journal_id.sale_shop_id.accion_especifica_id and out_inv.journal_id.sale_shop_id.accion_especifica_id.id or False, |
374 | + 'partida_presupuesto': product_tax.product_id.partida_egreso and product_tax.product_id.partida_egreso.id or False, |
375 | + }) |
376 | + create_ids.append(inv_line_id) |
377 | + |
378 | + #Se crea la factura rectificativa |
379 | + if create_ids: |
380 | + inv_id = self._make_invoice(cr, uid, out_inv, create_ids, descuento, context=context) |
381 | + invoice_ids_refund.append(inv_id) |
382 | + else: |
383 | + inv_id = 0 |
384 | + |
385 | + return invoice_ids_refund |
386 | + |
387 | + def crear_nc(self, cr, uid, ids, context=None): |
388 | + if context is None: |
389 | + context = {} |
390 | + |
391 | + aml_obj = self.pool.get('account.move.line') |
392 | + wf_service = netsvc.LocalService("workflow") |
393 | + |
394 | + act_obj = self.pool.get('ir.actions.act_window') |
395 | + mod_obj = self.pool.get('ir.model.data') |
396 | + model = context.get('active_model') |
397 | + |
398 | + descuento_data_obj = self.read(cr, uid, ids, ['descuento']) |
399 | + |
400 | + if not model or model != 'account.invoice': |
401 | + return [] |
402 | + |
403 | + if descuento_data_obj[0]['descuento'] < 1 or descuento_data_obj[0]['descuento'] > 100: |
404 | + raise osv.except_osv(_('Mensaje !'), _('No se puede aplicar a una factura un descuento menor a 1% o mayor a 100% por este modulo!')) |
405 | + |
406 | + res_ids = context and context.get('active_ids', []) |
407 | + model_pool = self.pool.get(model) |
408 | + browse_inv = model_pool.browse(cr, uid, res_ids, context=context) |
409 | + #Proceso de validacion |
410 | + validar_grupo_ok = True |
411 | + number_inv = '' |
412 | + for inv_disc in browse_inv: |
413 | + if inv_disc.type != 'out_invoice' or inv_disc.state not in ('open') \ |
414 | + or abs(inv_disc.residual - inv_disc.amount_total) > 0.01: |
415 | + validar_grupo_ok = False |
416 | + |
417 | + if not validar_grupo_ok: |
418 | + number_inv = inv_disc.number or inv_disc.origin or inv_disc.state |
419 | + break |
420 | + |
421 | + #Se recomienda a futuro validar por fecha de vencimiento |
422 | + |
423 | + #Si todas las facturas son de ventas |
424 | + if validar_grupo_ok: |
425 | + #crear las facturas |
426 | + refund_invoice_ids = self.action_invoice_create(cr, uid, ids, res_ids, descuento_data_obj[0]['descuento'], context=context) |
427 | + |
428 | + #procesar las facturas |
429 | + for invoice in refund_invoice_ids: |
430 | + wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_open', cr) |
431 | + |
432 | + """ Se concilian los asientos de la factura rectificativa y la factura padre """ |
433 | + reconcil_ids = [] |
434 | + for invoice in refund_invoice_ids: |
435 | + reconcil_ids = [] |
436 | + inv_refund = model_pool.browse(cr, uid, invoice, context=context) |
437 | + for line_m_r in inv_refund.move_id.line_id: |
438 | + if line_m_r.account_id == inv_refund.account_id: |
439 | + reconcil_ids.append(line_m_r.id) |
440 | + break |
441 | + |
442 | + for line_m_i in inv_refund.parent_id.move_id.line_id: |
443 | + if line_m_i.account_id == inv_refund.account_id: |
444 | + reconcil_ids.append(line_m_i.id) |
445 | + break |
446 | + |
447 | + """ Se concilian los asientos de la factura """ |
448 | + if reconcil_ids: |
449 | + isok = aml_obj.reconcile_partial(cr, uid, reconcil_ids,'manual', context) |
450 | + |
451 | + else: |
452 | + raise osv.except_osv(_('Mensaje !'), _('Hay facturas seleccionadas que no se les puede aplicar nota de credito para descuento financieros. Por favor revise para empezar la factura %s!')%number_inv) |
453 | + |
454 | + result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree3') |
455 | + id = result and result[1] or False |
456 | + result = act_obj.read(cr, uid, id, context=context) |
457 | + invoice_domain = eval(result['domain']) |
458 | + invoice_domain.append(('id', 'in', refund_invoice_ids)) |
459 | + result['domain'] = invoice_domain |
460 | + return result |
461 | + |
462 | +nota_credito_1_x_100_wizard() |
463 | |
464 | === added file 'notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml' |
465 | --- notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml 1970-01-01 00:00:00 +0000 |
466 | +++ notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml 2013-04-26 02:38:26 +0000 |
467 | @@ -0,0 +1,32 @@ |
468 | +<?xml version="1.0" encoding="utf-8"?> |
469 | +<openerp> |
470 | + <data> |
471 | + <record id="view_nota_credito_1_x_100_wizard" model="ir.ui.view"> |
472 | + <field name="name">Nota de Credito de 1 Porciento</field> |
473 | + <field name="model">nota.credito.1_x_100.wizard</field> |
474 | + <field name="type">form</field> |
475 | + <field name="arch" type="xml"> |
476 | + <form string="Crear Nota de Credito por descuento Financiero"> |
477 | + <separator colspan="4" string="Crear Nota de Credito" /> |
478 | + <group colspan="2" col="2"> |
479 | + <field name="descuento"/> |
480 | + </group> |
481 | + <separator string="" colspan="4" /> |
482 | + <button special="cancel" string="Cancelar" icon='gtk-cancel'/> |
483 | + <button name="crear_nc" string="Crear" type="object" icon="terp-gtk-go-back-rtl"/> |
484 | + </form> |
485 | + </field> |
486 | + </record> |
487 | + |
488 | + |
489 | + <act_window name="Nota de Credito por Descuento Financiero" |
490 | + res_model="nota.credito.1_x_100.wizard" |
491 | + src_model="account.invoice" |
492 | + key2="client_action_multi" |
493 | + multi="True" |
494 | + view_mode="form" |
495 | + view_type="form" |
496 | + target="new" |
497 | + id="action_nota_credito_1_x_100"/> |
498 | + </data> |
499 | +</openerp> |