Merge lp:~inddiana/diana-addons/nota_credito_desc_financieros into lp:diana-addons/6.0

Proposed by [SISB] Aryrosa Fuentes
Status: Needs review
Proposed branch: lp:~inddiana/diana-addons/nota_credito_desc_financieros
Merge into: lp:diana-addons/6.0
Diff against target: 163 lines (+49/-16)
2 files modified
notas_de_credito/wizard/nota_credito_1_x_100_wizard.py (+42/-13)
notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml (+7/-3)
To merge this branch: bzr merge lp:~inddiana/diana-addons/nota_credito_desc_financieros
Reviewer Review Type Date Requested Status
Aristóbulo Meneses Pending
Review via email: mp+165184@code.launchpad.net

Description of the change

18. By [SISB] Aryrosa Fuentes 8 minutes ago

    [MOD] Se ajusta el registro de la referencia de la factura rectificativa.
17. By [SISB] Aryrosa Fuentes on 2013-05-07

    [MOD] Eliminado los print
16. By [SISB] Aryrosa Fuentes on 2013-05-07

    [MOD] Se incluye el tipo de descuento especial para indicar un porcentaje diferente al descuento financiero del 1%
15. By [SISB] Aryrosa Fuentes on 2013-04-29

    [FIX] En la concatenacion en el origen se toma en cuenta si viene vacio (False).
14. By [SISB] Aryrosa Fuentes on 2013-04-26

    [MOD] En el menu se muestra un nombre mas corto.
    Se incluye en el origen de la factura rectificativa la frase DESCUENTO FINANCIERO.

To post a comment you must log in.

Unmerged revisions

18. By [SISB] Aryrosa Fuentes

[MOD] Se ajusta el registro de la referencia de la factura rectificativa.

17. By [SISB] Aryrosa Fuentes

[MOD] Eliminado los print

16. By [SISB] Aryrosa Fuentes

[MOD] Se incluye el tipo de descuento especial para indicar un porcentaje diferente al descuento financiero del 1%

15. By [SISB] Aryrosa Fuentes

[FIX] En la concatenacion en el origen se toma en cuenta si viene vacio (False).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'notas_de_credito/wizard/nota_credito_1_x_100_wizard.py'
2--- notas_de_credito/wizard/nota_credito_1_x_100_wizard.py 2013-04-26 16:40:14 +0000
3+++ notas_de_credito/wizard/nota_credito_1_x_100_wizard.py 2013-05-22 15:50:30 +0000
4@@ -43,14 +43,20 @@
5
6 _description = "Nota de Credito por Descuento Financiero"
7 _columns = {
8- 'descuento': fields.integer('Descuento (%)', digits_compute= dp.get_precision('Account')),
9+ 'descuento': fields.integer('Descuento (%)', digits_compute= dp.get_precision('Account'), required=True),
10+ "type": fields.selection([
11+ ("financiero", _("Descuento Financiero")),
12+ ("especial", _("Descuento Especial")),
13+ ],"Tipo", required=True,
14+ ),
15 }
16
17 _defaults = {
18- 'descuento': 1
19+ 'descuento': 1,
20+ 'type': 'financiero',
21 }
22
23- def _make_invoice(self, cr, uid, cabecera, lines, descuento, context=None):
24+ def _make_invoice(self, cr, uid, cabecera, lines, descuento, tipo, context=None):
25 journal_obj = self.pool.get('account.journal')
26 inv_obj = self.pool.get('account.invoice')
27 obj_invoice_line = self.pool.get('account.invoice.line')
28@@ -63,12 +69,19 @@
29 _('There is no sales journal defined for this return: "%s"') % (cabecera.name))
30
31 a = cabecera.partner_id.property_account_receivable.id
32+
33+ cabecera_origen = cabecera.origin or ''
34+ #tipo de descuento
35+ if tipo == 'financiero':
36+ origen = cabecera_origen + ' - DESCUENTO FINANCIERO DE ' + str(descuento) + '%'
37+ else:
38+ origen = cabecera_origen + ' - DESCUENTO ESPECIAL DE ' + str(descuento) + '%'
39
40 inv = {
41 'name': 'RECTIFICA A ' + cabecera.number + ' DESCONTANDO EL ' + str(descuento) + '%',
42- 'origin': cabecera.origin + ' - DESCUENTO FINANCIERO',
43+ 'origin': origen,
44 'type': 'out_refund',
45- 'reference': cabecera.number,
46+ 'reference': cabecera.name or cabecera.number,
47 'account_id': a,
48 'partner_id': cabecera.partner_id.id,
49 'journal_id': journal_id,
50@@ -90,7 +103,7 @@
51
52 return inv_id
53
54- def action_invoice_create(self, cr, uid, ids, res_ids, descuento, context=None):
55+ def action_invoice_create(self, cr, uid, ids, res_ids, descuento, tipo, context=None):
56 if context is None:
57 context = {}
58
59@@ -130,9 +143,18 @@
60 _('There is no income account defined ' \
61 'for this product: "%s" (id:%d)') % \
62 (product_tax.product_id.name, product_tax.product_id.id,))
63-
64+
65+ #tipo de descuento
66+ if tipo == 'financiero':
67+ nombre_linea = self.pool.get('product.product').name_get(cr, uid, [product_tax.product_id.id])[0][1][:128]
68+ nota_linea = 'DESCUENTO FINANCIERO AL ' + str(descuento) + '%'
69+ else:
70+ product_code = self.pool.get('product.product').browse(cr, uid,product_tax.product_id.id).default_code or ''
71+ nombre_linea = '[' + product_code + '] ' + 'DESCUENTO ESPECIAL DE ' + str(descuento) + '%'
72+ nota_linea = 'DESCUENTO ESPECIAL DE ' + str(descuento) + '%'
73+
74 inv_line_id = self.pool.get('account.invoice.line').create(cr, uid, {
75- 'name': self.pool.get('product.product').name_get(cr, uid, [product_tax.product_id.id])[0][1][:128],
76+ 'name': nombre_linea,
77 'origin': out_inv.origin,
78 'account_id': a,
79 'price_unit': line.base * descuento/100,
80@@ -141,7 +163,7 @@
81 'uos_id': product_tax.product_id.uom_id.id,
82 'product_id': product_tax.product_id.id,
83 'invoice_line_tax_id': [(6, 0, [product_tax.tax_id.id])],
84- 'note': 'Descuento financiero al ' + str(descuento) + '%',
85+ 'note': nota_linea,
86 '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,
87 '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,
88 'partida_presupuesto': product_tax.product_id.partida_egreso and product_tax.product_id.partida_egreso.id or False,
89@@ -150,13 +172,20 @@
90
91 #Se crea la factura rectificativa
92 if create_ids:
93- inv_id = self._make_invoice(cr, uid, out_inv, create_ids, descuento, context=context)
94+ inv_id = self._make_invoice(cr, uid, out_inv, create_ids, descuento, tipo, context=context)
95 invoice_ids_refund.append(inv_id)
96 else:
97 inv_id = 0
98
99 return invoice_ids_refund
100
101+ def on_change_type(self, cr, uid, ids, tipo):
102+ result = {}
103+ if tipo == 'financiero':
104+ result.update({'value': {'descuento': 1,}})
105+
106+ return result
107+
108 def crear_nc(self, cr, uid, ids, context=None):
109 if context is None:
110 context = {}
111@@ -168,8 +197,7 @@
112 mod_obj = self.pool.get('ir.model.data')
113 model = context.get('active_model')
114
115- descuento_data_obj = self.read(cr, uid, ids, ['descuento'])
116-
117+ descuento_data_obj = self.read(cr, uid, ids, ['descuento','type'])
118 if not model or model != 'account.invoice':
119 return []
120
121@@ -196,7 +224,7 @@
122 #Si todas las facturas son de ventas
123 if validar_grupo_ok:
124 #crear las facturas
125- refund_invoice_ids = self.action_invoice_create(cr, uid, ids, res_ids, descuento_data_obj[0]['descuento'], context=context)
126+ refund_invoice_ids = self.action_invoice_create(cr, uid, ids, res_ids, descuento_data_obj[0]['descuento'], descuento_data_obj[0]['type'], context=context)
127
128 #procesar las facturas
129 for invoice in refund_invoice_ids:
130@@ -230,6 +258,7 @@
131 invoice_domain = eval(result['domain'])
132 invoice_domain.append(('id', 'in', refund_invoice_ids))
133 result['domain'] = invoice_domain
134+
135 return result
136
137 nota_credito_1_x_100_wizard()
138
139=== modified file 'notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml'
140--- notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml 2013-04-26 02:23:18 +0000
141+++ notas_de_credito/wizard/nota_credito_1_x_100_wizard.xml 2013-05-22 15:50:30 +0000
142@@ -6,14 +6,18 @@
143 <field name="model">nota.credito.1_x_100.wizard</field>
144 <field name="type">form</field>
145 <field name="arch" type="xml">
146- <form string="Crear Nota de Credito por descuento Financiero">
147+ <form string="Crear nota de credito por descuento financiero o descuento especial">
148 <separator colspan="4" string="Crear Nota de Credito" />
149 <group colspan="2" col="2">
150- <field name="descuento"/>
151+ <field name="type" on_change="on_change_type(type)"/>
152+ <field name="descuento" attrs="{'readonly':[('type','=','financiero')]}"/>
153 </group>
154 <separator string="" colspan="4" />
155+ <group colspan="2" col="2">
156 <button special="cancel" string="Cancelar" icon='gtk-cancel'/>
157- <button name="crear_nc" string="Crear" type="object" icon="terp-gtk-go-back-rtl"/>
158+ <button name="crear_nc" string="Crear" type="object" icon="terp-gtk-go-back-rtl"
159+ confirm="¿Desea aplicar el descuento indicado a las facturas selecionadas?"/>
160+ </group>
161 </form>
162 </field>
163 </record>

Subscribers

People subscribed via source and target branches