Merge lp:~inddiana/diana-addons/edgar_diana_addons_anulacion_factura into lp:diana-addons
- edgar_diana_addons_anulacion_factura
- Merge into trunk
Proposed by
[SISB] Edgar Rivero
Status: | Needs review |
---|---|
Proposed branch: | lp:~inddiana/diana-addons/edgar_diana_addons_anulacion_factura |
Merge into: | lp:diana-addons |
Diff against target: |
1926 lines (+1846/-0) 13 files modified
anular_factura/__init__.py (+3/-0) anular_factura/__openerp__.py (+48/-0) anular_factura/i18n/es_VE.po (+369/-0) anular_factura/model/__init__.py (+4/-0) anular_factura/model/cancel_invoice.py (+920/-0) anular_factura/model/herencia_retencion.py (+87/-0) anular_factura/report_cancel_invoice.xml (+8/-0) anular_factura/secuence/cancel_invoice_sequence.xml (+46/-0) anular_factura/security/cancel_invoice_security.xml (+37/-0) anular_factura/security/ir.model.access.csv (+5/-0) anular_factura/view/cancel_invoice.xml (+142/-0) anular_factura/view/log_cancel_invoice.xml (+77/-0) anular_factura/workflow/invoice_wh_workflow.xml (+100/-0) |
To merge this branch: | bzr merge lp:~inddiana/diana-addons/edgar_diana_addons_anulacion_factura |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
[SISB] Yennifer Santiago Z | Pending | ||
Review via email: mp+235847@code.launchpad.net |
Commit message
Description of the change
[IMP] Se agrega modulo de anulacion de factura.
To post a comment you must log in.
- 44. By [SISB] Edgar Rivero
-
[FIX] Se corrige error con direccion de modulo.
- 45. By [SISB] Edgar Rivero
-
[FIX] Corregido nombre de funcion.
- 46. By [SISB] Edgar Rivero
-
[IMP] Se edita traduccion.
Unmerged revisions
- 46. By [SISB] Edgar Rivero
-
[IMP] Se edita traduccion.
- 45. By [SISB] Edgar Rivero
-
[FIX] Corregido nombre de funcion.
- 44. By [SISB] Edgar Rivero
-
[FIX] Se corrige error con direccion de modulo.
- 43. By [SISB] Edgar Rivero
-
[IMP] Se ajusta traduccion al cambio del nombre del modulo.
- 42. By [SISB] Edgar Rivero
-
[IMP] Se agrega modulo de anulacion de factura.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'anular_factura' |
2 | === added file 'anular_factura/__init__.py' |
3 | --- anular_factura/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ anular_factura/__init__.py 2014-10-13 21:29:58 +0000 |
5 | @@ -0,0 +1,3 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | + |
8 | +import model |
9 | |
10 | === added file 'anular_factura/__openerp__.py' |
11 | --- anular_factura/__openerp__.py 1970-01-01 00:00:00 +0000 |
12 | +++ anular_factura/__openerp__.py 2014-10-13 21:29:58 +0000 |
13 | @@ -0,0 +1,48 @@ |
14 | +# -*- encoding: utf-8 -*- |
15 | +############################################################################## |
16 | +# |
17 | +# This program is Free Software; you can redistribute it and/or |
18 | +# modify it under the terms of the GNU General Public License |
19 | +# as published by the Free Software Foundation; either version 2 |
20 | +# of the License, or (at your option) any later version. |
21 | +# |
22 | +# This program is distributed in the hope that it will be useful, |
23 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | +# GNU General Public License for more details. |
26 | +# |
27 | +# You should have received a copy of the GNU General Public License |
28 | +# along with this program; if not, write to the Free Software |
29 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
30 | +# |
31 | +############################################################################## |
32 | + |
33 | +{ |
34 | + 'name': 'Anular Factura', |
35 | + 'version': '0.1', |
36 | + 'category': 'Accounting/Account', |
37 | + 'description':'Modulo para la anulacion de facturas', |
38 | + 'author': 'Industrias Diana, C.A.', |
39 | + 'website': 'http://www.industriasdiana.gob.ve', |
40 | + 'depends': ['account', |
41 | + 'l10n_ve_fiscal_requirements', |
42 | + 'l10n_ve_withholding_src', |
43 | + 'l10n_ve_withholding_muni', |
44 | + 'l10n_ve_withholding_iva', |
45 | + 'l10n_ve_withholding_islr', |
46 | + 'l10n_ve_presupuesto', |
47 | + ], |
48 | + 'update_xml': [ |
49 | + 'security/cancel_invoice_security.xml', |
50 | + 'security/ir.model.access.csv', |
51 | + 'view/log_cancel_invoice.xml', |
52 | + 'view/cancel_invoice.xml', |
53 | + 'secuence/cancel_invoice_sequence.xml', |
54 | + #~ 'report_cancel_invoice.xml', |
55 | + 'workflow/invoice_wh_workflow.xml', |
56 | + ], |
57 | + 'data': [ |
58 | + ], |
59 | + 'installable': True, |
60 | + 'active': False, |
61 | +} |
62 | |
63 | === added directory 'anular_factura/i18n' |
64 | === added file 'anular_factura/i18n/es_VE.mo' |
65 | Binary files anular_factura/i18n/es_VE.mo 1970-01-01 00:00:00 +0000 and anular_factura/i18n/es_VE.mo 2014-10-13 21:29:58 +0000 differ |
66 | === added file 'anular_factura/i18n/es_VE.po' |
67 | --- anular_factura/i18n/es_VE.po 1970-01-01 00:00:00 +0000 |
68 | +++ anular_factura/i18n/es_VE.po 2014-10-13 21:29:58 +0000 |
69 | @@ -0,0 +1,369 @@ |
70 | +# Translation of OpenERP Server. |
71 | +# This file contains the translation of the following modules: |
72 | +# * anular_factura |
73 | +# |
74 | +msgid "" |
75 | +msgstr "" |
76 | +"Project-Id-Version: OpenERP Server 6.0.4\n" |
77 | +"Report-Msgid-Bugs-To: support@openerp.com\n" |
78 | +"POT-Creation-Date: 2014-10-13 21:22+0000\n" |
79 | +"PO-Revision-Date: 2014-10-13 16:58-0400\n" |
80 | +"Last-Translator: Edgar Rivero <edgarrivero@gmail.com>\n" |
81 | +"Language-Team: \n" |
82 | +"MIME-Version: 1.0\n" |
83 | +"Content-Type: text/plain; charset=UTF-8\n" |
84 | +"Content-Transfer-Encoding: 8bit\n" |
85 | +"Plural-Forms: \n" |
86 | + |
87 | +#. module: anular_factura |
88 | +#: field:account.invoice,sisb_picking_ids:0 |
89 | +msgid "Pickings" |
90 | +msgstr "Albaranes" |
91 | + |
92 | +#. module: anular_factura |
93 | +#: code:addons/anular_factura/model/cancel_invoice.py:303 |
94 | +#, python-format |
95 | +msgid "La retencion de ISLR pertenece a diferentes facturas. No puede ser anulado" |
96 | +msgstr "La retencion de ISLR pertenece a diferentes facturas. No puede ser anulado" |
97 | + |
98 | +#. module: anular_factura |
99 | +#: code:addons/anular_factura/model/cancel_invoice.py:537 |
100 | +#, python-format |
101 | +msgid "The account move wasn't created, process aborted." |
102 | +msgstr "The account move wasn't created, process aborted." |
103 | + |
104 | +#. module: anular_factura |
105 | +#: field:log.cancel.invoice,res_id:0 |
106 | +msgid "Object ID" |
107 | +msgstr "ID Objeto" |
108 | + |
109 | +#. module: anular_factura |
110 | +#: code:addons/anular_factura/model/cancel_invoice.py:383 |
111 | +#, python-format |
112 | +msgid "La retencion Municipal pertenece a diferentes facturas. No puede ser anulado" |
113 | +msgstr "La retencion Municipal pertenece a diferentes facturas. No puede ser anulado" |
114 | + |
115 | +#. module: anular_factura |
116 | +#: selection:cancel.invoice,state:0 |
117 | +msgid "Ratified" |
118 | +msgstr "Ratificado" |
119 | + |
120 | +#. module: anular_factura |
121 | +#: field:cancel.invoice,period_id:0 |
122 | +msgid "Period" |
123 | +msgstr "Periodo" |
124 | + |
125 | +#. module: anular_factura |
126 | +#: view:cancel.invoice:0 |
127 | +#: view:log.cancel.invoice:0 |
128 | +msgid "Group By..." |
129 | +msgstr "Agrupar Por..." |
130 | + |
131 | +#. module: anular_factura |
132 | +#: field:cancel.invoice,state:0 |
133 | +msgid "State" |
134 | +msgstr "Estado" |
135 | + |
136 | +#. module: anular_factura |
137 | +#: view:cancel.invoice:0 |
138 | +#: selection:cancel.invoice,state:0 |
139 | +msgid "Draft" |
140 | +msgstr "Borrador" |
141 | + |
142 | +#. module: anular_factura |
143 | +#: sql_constraint:cancel.invoice:0 |
144 | +msgid "The invoice is already in another document!" |
145 | +msgstr "La factura ya está en otro documento!" |
146 | + |
147 | +#. module: anular_factura |
148 | +#: field:cancel.invoice,move_cancel_ids:0 |
149 | +msgid "Journal Entries Canceled" |
150 | +msgstr "Asientos" |
151 | + |
152 | +#. module: anular_factura |
153 | +#: field:cancel.invoice,name:0 |
154 | +msgid "Sequence Cancel" |
155 | +msgstr "Secuencia de Anulación" |
156 | + |
157 | +#. module: anular_factura |
158 | +#: field:cancel.invoice,date_invoice:0 |
159 | +msgid "Date Invoice" |
160 | +msgstr "Fecha de Factura" |
161 | + |
162 | +#. module: anular_factura |
163 | +#: field:cancel.invoice,partner_id:0 |
164 | +msgid "Partner" |
165 | +msgstr "Empresa" |
166 | + |
167 | +#. module: anular_factura |
168 | +#: field:cancel.invoice,reference:0 |
169 | +msgid "Reference Invoice" |
170 | +msgstr "Referencia de Factura" |
171 | + |
172 | +#. module: anular_factura |
173 | +#: code:addons/anular_factura/model/cancel_invoice.py:249 |
174 | +#: code:addons/anular_factura/model/cancel_invoice.py:253 |
175 | +#: code:addons/anular_factura/model/cancel_invoice.py:276 |
176 | +#: code:addons/anular_factura/model/cancel_invoice.py:297 |
177 | +#: code:addons/anular_factura/model/cancel_invoice.py:303 |
178 | +#: code:addons/anular_factura/model/cancel_invoice.py:324 |
179 | +#: code:addons/anular_factura/model/cancel_invoice.py:331 |
180 | +#: code:addons/anular_factura/model/cancel_invoice.py:351 |
181 | +#: code:addons/anular_factura/model/cancel_invoice.py:357 |
182 | +#: code:addons/anular_factura/model/cancel_invoice.py:377 |
183 | +#: code:addons/anular_factura/model/cancel_invoice.py:383 |
184 | +#: code:addons/anular_factura/model/herencia_retencion.py:28 |
185 | +#: code:addons/anular_factura/model/herencia_retencion.py:44 |
186 | +#, python-format |
187 | +msgid "Error !" |
188 | +msgstr "Error !" |
189 | + |
190 | +#. module: anular_factura |
191 | +#: field:log.cancel.invoice,date_create:0 |
192 | +msgid "Creation Date" |
193 | +msgstr "Fecha de Creacion" |
194 | + |
195 | +#. module: anular_factura |
196 | +#: view:cancel.invoice:0 |
197 | +#: field:cancel.invoice,company_id:0 |
198 | +#: view:log.cancel.invoice:0 |
199 | +#: field:log.cancel.invoice,company_id:0 |
200 | +msgid "Company" |
201 | +msgstr "Compañia" |
202 | + |
203 | +#. module: anular_factura |
204 | +#: field:log.cancel.invoice,res_model:0 |
205 | +msgid "Object" |
206 | +msgstr "Objeto" |
207 | + |
208 | +#. module: anular_factura |
209 | +#: field:cancel.invoice,log_lines:0 |
210 | +msgid "Log Cancel" |
211 | +msgstr "Registro de Anulación" |
212 | + |
213 | +#. module: anular_factura |
214 | +#: model:ir.model,name:anular_factura.model_islr_wh_doc |
215 | +msgid "Document Withholding Income" |
216 | +msgstr "Documento de Retención de ISLR" |
217 | + |
218 | +#. module: anular_factura |
219 | +#: field:log.cancel.invoice,user_id:0 |
220 | +msgid "User" |
221 | +msgstr "Usuario" |
222 | + |
223 | +#. module: anular_factura |
224 | +#: model:ir.model,name:anular_factura.model_log_cancel_invoice |
225 | +msgid "Log de anulacion de facturas" |
226 | +msgstr "Registro de anulación de facturas" |
227 | + |
228 | +#. module: anular_factura |
229 | +#: code:addons/anular_factura/model/cancel_invoice.py:537 |
230 | +#, python-format |
231 | +msgid "Alert !" |
232 | +msgstr "Alerta !" |
233 | + |
234 | +#. module: anular_factura |
235 | +#: view:cancel.invoice:0 |
236 | +#: selection:cancel.invoice,state:0 |
237 | +msgid "Approved" |
238 | +msgstr "Aprobado" |
239 | + |
240 | +#. module: anular_factura |
241 | +#: field:cancel.invoice,user_ratify:0 |
242 | +msgid "Ratification of User" |
243 | +msgstr "Ratificado por" |
244 | + |
245 | +#. module: anular_factura |
246 | +#: field:cancel.invoice,user_request:0 |
247 | +msgid "Requesting User" |
248 | +msgstr "Requerido por" |
249 | + |
250 | +#. module: anular_factura |
251 | +#: view:cancel.invoice:0 |
252 | +msgid "Execute" |
253 | +msgstr "Ejecutar" |
254 | + |
255 | +#. module: anular_factura |
256 | +#: code:addons/anular_factura/model/cancel_invoice.py:297 |
257 | +#, python-format |
258 | +msgid "La retencion de ISLR se encuentra fuera de periodo. No puede ser anulado" |
259 | +msgstr "La retencion de ISLR se encuentra fuera de periodo. No puede ser anulado" |
260 | + |
261 | +#. module: anular_factura |
262 | +#: constraint:account.invoice:0 |
263 | +msgid "The Document you have been entering for this Partner has already been recorded" |
264 | +msgstr "El documento que esta registrando para este Cliente ya ha sido registrada" |
265 | + |
266 | +#. module: anular_factura |
267 | +#: field:cancel.invoice,date:0 |
268 | +msgid "Date of Request" |
269 | +msgstr "Fecha de Petición" |
270 | + |
271 | +#. module: anular_factura |
272 | +#: view:cancel.invoice:0 |
273 | +#: view:log.cancel.invoice:0 |
274 | +msgid "Search Log" |
275 | +msgstr "Registro Busqueda" |
276 | + |
277 | +#. module: anular_factura |
278 | +#: field:account.invoice,cancel_invoice_id:0 |
279 | +#: view:cancel.invoice:0 |
280 | +#: model:ir.actions.act_window,name:anular_factura.action_cancel_invoice_act_window |
281 | +#: model:ir.ui.menu,name:anular_factura.menu_cancel_invoice |
282 | +msgid "Cancel Invoice" |
283 | +msgstr "Anulación de Factura" |
284 | + |
285 | +#. module: anular_factura |
286 | +#: code:addons/anular_factura/model/cancel_invoice.py:331 |
287 | +#, python-format |
288 | +msgid "La retencion de IVA pertenece a diferentes facturas. No puede ser anulado" |
289 | +msgstr "La retencion de IVA pertenece a diferentes facturas. No puede ser anulado" |
290 | + |
291 | +#. module: anular_factura |
292 | +#: model:ir.model,name:anular_factura.model_cancel_invoice |
293 | +msgid "Anulacion de Factura" |
294 | +msgstr "Anulación de Factura" |
295 | + |
296 | +#. module: anular_factura |
297 | +#: code:addons/anular_factura/model/cancel_invoice.py:249 |
298 | +#, python-format |
299 | +msgid "La factura se encuentra fuera de periodo. No puede ser anulado" |
300 | +msgstr "La factura se encuentra fuera de periodo. No puede ser anulado" |
301 | + |
302 | +#. module: anular_factura |
303 | +#: code:addons/anular_factura/model/cancel_invoice.py:324 |
304 | +#, python-format |
305 | +msgid "La retencion de IVA se encuentra fuera de periodo impositivo. No puede ser anulado" |
306 | +msgstr "La retencion de IVA se encuentra fuera de periodo impositivo. No puede ser anulado" |
307 | + |
308 | +#. module: anular_factura |
309 | +#: code:addons/anular_factura/model/cancel_invoice.py:70 |
310 | +#, python-format |
311 | +msgid "It is not allowed to duplicate" |
312 | +msgstr "No se permite duplicar" |
313 | + |
314 | +#. module: anular_factura |
315 | +#: field:cancel.invoice,date_document_invoice:0 |
316 | +msgid "Date Document Invoice" |
317 | +msgstr "Fecha del Documento Factura" |
318 | + |
319 | +#. module: anular_factura |
320 | +#: view:cancel.invoice:0 |
321 | +msgid "Journal Entry Canceled" |
322 | +msgstr "Asientos Anulados" |
323 | + |
324 | +#. module: anular_factura |
325 | +#: view:cancel.invoice:0 |
326 | +msgid "Approve" |
327 | +msgstr "Aprobar" |
328 | + |
329 | +#. module: anular_factura |
330 | +#: field:log.cancel.invoice,name:0 |
331 | +msgid "Message" |
332 | +msgstr "Mensaje" |
333 | + |
334 | +#. module: anular_factura |
335 | +#: code:addons/anular_factura/model/herencia_retencion.py:44 |
336 | +#, python-format |
337 | +msgid "La retencion posee un documento de anulacion, no puede ser pasado a borrador" |
338 | +msgstr "La retencion posee un documento de anulacion, no puede ser pasado a borrador" |
339 | + |
340 | +#. module: anular_factura |
341 | +#: code:addons/anular_factura/model/cancel_invoice.py:351 |
342 | +#, python-format |
343 | +msgid "La retencion de Responsabilidad Social se encuentra fuera de periodo. No puede ser anulado" |
344 | +msgstr "La retencion de Responsabilidad Social se encuentra fuera de periodo. No puede ser anulado" |
345 | + |
346 | +#. module: anular_factura |
347 | +#: code:addons/anular_factura/model/cancel_invoice.py:70 |
348 | +#, python-format |
349 | +msgid "Action Denied!" |
350 | +msgstr "Acceso Denegado!" |
351 | + |
352 | +#. module: anular_factura |
353 | +#: view:cancel.invoice:0 |
354 | +#: model:ir.actions.act_window,name:anular_factura.action_log_cancel_invoice_act_window |
355 | +#: model:ir.ui.menu,name:anular_factura.menu_log_cancel_invoice |
356 | +#: view:log.cancel.invoice:0 |
357 | +msgid "Log Cancel Invoice" |
358 | +msgstr "Registro de Anulación de Factura" |
359 | + |
360 | +#. module: anular_factura |
361 | +#: view:cancel.invoice:0 |
362 | +#: field:cancel.invoice,reason:0 |
363 | +msgid "Reason for the cancellation" |
364 | +msgstr "Motivo de la cancelación" |
365 | + |
366 | +#. module: anular_factura |
367 | +#: view:cancel.invoice:0 |
368 | +msgid "Ratify" |
369 | +msgstr "Ratificar" |
370 | + |
371 | +#. module: anular_factura |
372 | +#: code:addons/anular_factura/model/cancel_invoice.py:377 |
373 | +#, python-format |
374 | +msgid "La retencion Municipal se encuentra fuera de periodo. No puede ser anulado" |
375 | +msgstr "La retencion Municipal se encuentra fuera de periodo. No puede ser anulado" |
376 | + |
377 | +#. module: anular_factura |
378 | +#: code:addons/anular_factura/model/cancel_invoice.py:276 |
379 | +#, python-format |
380 | +msgid "La factura posee pagos distintos a retenciones, debe cancelar estos pagos antes de continuar." |
381 | +msgstr "La factura posee pagos distintos a retenciones, debe cancelar estos pagos antes de continuar." |
382 | + |
383 | +#. module: anular_factura |
384 | +#: view:cancel.invoice:0 |
385 | +#: selection:cancel.invoice,state:0 |
386 | +msgid "Done" |
387 | +msgstr "Ejecutado" |
388 | + |
389 | +#. module: anular_factura |
390 | +#: model:ir.model,name:anular_factura.model_account_wh_muni |
391 | +#: model:ir.model,name:anular_factura.model_account_wh_src |
392 | +msgid "Social Responsibility Commitment Withholding" |
393 | +msgstr "Comentario de Retenciones de Responsabilidad Social" |
394 | + |
395 | +#. module: anular_factura |
396 | +#: field:cancel.invoice,invoice_id:0 |
397 | +#: model:ir.model,name:anular_factura.model_account_invoice |
398 | +msgid "Invoice" |
399 | +msgstr "Facturas" |
400 | + |
401 | +#. module: anular_factura |
402 | +#: code:addons/anular_factura/model/herencia_retencion.py:28 |
403 | +#, python-format |
404 | +msgid "La factura posee un documento de anulacion, no puede ser pasado a borrador" |
405 | +msgstr "La factura posee un documento de anulacion, no puede ser pasado a borrador" |
406 | + |
407 | +#. module: anular_factura |
408 | +#: code:addons/anular_factura/model/cancel_invoice.py:357 |
409 | +#, python-format |
410 | +msgid "La retencion de Responsabilidad Social pertenece a diferentes facturas. No puede ser anulado" |
411 | +msgstr "La retencion de Responsabilidad Social pertenece a diferentes facturas. No puede ser anulado" |
412 | + |
413 | +#. module: anular_factura |
414 | +#: code:addons/anular_factura/model/cancel_invoice.py:253 |
415 | +#, python-format |
416 | +msgid "La factura posee notas de credito o debito, no puede ser anulada." |
417 | +msgstr "La factura posee notas de credito o debito, no puede ser anulada." |
418 | + |
419 | +#. module: anular_factura |
420 | +#: field:cancel.invoice,user_approve:0 |
421 | +msgid "Approbation User" |
422 | +msgstr "Aprobado por" |
423 | + |
424 | +#. module: anular_factura |
425 | +#: field:cancel.invoice,move_id:0 |
426 | +msgid "Journal Entry" |
427 | +msgstr "Asiento de Anulación" |
428 | + |
429 | +#. module: anular_factura |
430 | +#: view:cancel.invoice:0 |
431 | +msgid "Check" |
432 | +msgstr "Comprobar" |
433 | + |
434 | +#. module: anular_factura |
435 | +#: field:account.invoice,sisb_purchase_ids:0 |
436 | +msgid "Purchases" |
437 | +msgstr "Ordenes de Compra" |
438 | + |
439 | |
440 | === added directory 'anular_factura/images' |
441 | === added file 'anular_factura/images/caja_chica.png' |
442 | Binary files anular_factura/images/caja_chica.png 1970-01-01 00:00:00 +0000 and anular_factura/images/caja_chica.png 2014-10-13 21:29:58 +0000 differ |
443 | === added file 'anular_factura/images/caja_chica_hover.png' |
444 | Binary files anular_factura/images/caja_chica_hover.png 1970-01-01 00:00:00 +0000 and anular_factura/images/caja_chica_hover.png 2014-10-13 21:29:58 +0000 differ |
445 | === added directory 'anular_factura/model' |
446 | === added file 'anular_factura/model/__init__.py' |
447 | --- anular_factura/model/__init__.py 1970-01-01 00:00:00 +0000 |
448 | +++ anular_factura/model/__init__.py 2014-10-13 21:29:58 +0000 |
449 | @@ -0,0 +1,4 @@ |
450 | +# -*- coding: utf-8 -*- |
451 | + |
452 | +import cancel_invoice |
453 | +import herencia_retencion |
454 | |
455 | === added file 'anular_factura/model/cancel_invoice.py' |
456 | --- anular_factura/model/cancel_invoice.py 1970-01-01 00:00:00 +0000 |
457 | +++ anular_factura/model/cancel_invoice.py 2014-10-13 21:29:58 +0000 |
458 | @@ -0,0 +1,920 @@ |
459 | +#!/usr/bin/python |
460 | +# -*- encoding: utf-8 -*- |
461 | +########################################################################### |
462 | +# Copyright (C) Industrias Diana, C.A. (www.industriasdiana.gob.ve) |
463 | +# All Rights Reserved |
464 | +###############Credits###################################################### |
465 | +# Developed by: Industrias Diana, C.A. |
466 | +############################################################################## |
467 | + |
468 | +from osv import fields, osv |
469 | +import netsvc |
470 | +import time |
471 | +from tools.translate import _ |
472 | +import unicodedata |
473 | + |
474 | +""" |
475 | +Object writing Values |
476 | +One2many - Many2many |
477 | +Argument: |
478 | + [(op, id, values)] |
479 | +Where |
480 | + op: the type of operation (link, create, remove, ...) |
481 | + id: the ID of the resource (in case of a modification or unlink) |
482 | + values: a dictionary of values for the distant record |
483 | +Possible values for op: |
484 | + 0: create |
485 | + 1: write |
486 | + 2: unlink |
487 | + 6: set the link to a list of IDs given in the third argument (values) |
488 | + (0, 0, { values }) link to a new record that needs to be created with the given values dictionary |
489 | + (1, ID, { values }) update the linked record with id = ID (write *values* on it) |
490 | + (2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well) |
491 | + (3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself) |
492 | + (4, ID) link to existing record with id = ID (adds a relationship) |
493 | + (5) unlink all (like using (3,ID) for all linked records) |
494 | + (6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs) |
495 | + |
496 | +Ej: 'taxes_id':[(6,0,[1])] |
497 | +""" |
498 | + |
499 | +def elimina_tildes(s): |
500 | + """ |
501 | + Funcion para eliminar las tildes de algun texto utilizando el modulo unicodedata. |
502 | + """ |
503 | + return ''.join((c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')).replace("'","") |
504 | + |
505 | + |
506 | +class log_cancel_invoice(osv.osv): |
507 | + _name = 'log.cancel.invoice' |
508 | + _description = 'Log de anulacion de facturas' |
509 | + _order = "id desc" |
510 | + |
511 | + _columns = { |
512 | + 'name': fields.char('Message', size=256, readonly=True, required=True), |
513 | + 'user_id': fields.many2one('res.users', 'User', readonly=True, required=True), |
514 | + 'res_model': fields.char('Object', size=56, readonly=True, required=True), |
515 | + 'res_id': fields.integer('Object ID', readonly=True, required=True), |
516 | + 'date_create': fields.date('Creation Date', readonly=True, required=True), |
517 | + 'company_id': fields.many2one('res.company', 'Company', readonly=True, required=True), |
518 | + } |
519 | + |
520 | + _defaults = { |
521 | + 'user_id': lambda obj, cr, uid, context: uid, |
522 | + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, |
523 | + 'date_create': lambda *a: time.strftime('%Y-%m-%d'), |
524 | + } |
525 | + |
526 | + |
527 | + def copy(self, cr, uid, id, default=None, context=None): |
528 | + raise osv.except_osv(_('Action Denied!'),_('It is not allowed to duplicate')) |
529 | + return False |
530 | + |
531 | +log_cancel_invoice() |
532 | + |
533 | + |
534 | +class cancel_invoice(osv.osv): |
535 | + _name = 'cancel.invoice' |
536 | + _description = 'Anulacion de Factura' |
537 | + _order = "id desc" |
538 | + |
539 | + |
540 | + def _get_period(self, cr, uid, context=None): |
541 | + periods = self.pool.get('account.period').find(cr, uid) |
542 | + if periods: |
543 | + return periods[0] |
544 | + return False |
545 | + |
546 | + |
547 | + def _get_logs(self, cr, uid, ids, name, arg, context=None): |
548 | + obj_log = self.pool.get('log.cancel.invoice') |
549 | + if context is None: |
550 | + context = {} |
551 | + |
552 | + res = {} |
553 | + for cancel_brw in self.browse(cr, uid, ids, context=context): |
554 | + id = cancel_brw.id |
555 | + res[id] = [] |
556 | + if cancel_brw.state == 'draft': |
557 | + continue |
558 | + |
559 | + log_search = obj_log.search(cr, uid, [('res_model','=','cancel.invoice'),('res_id','=',id)]) |
560 | + res[id] = log_search |
561 | + |
562 | + return res |
563 | + |
564 | + |
565 | + _columns = { |
566 | + 'name': fields.char('Sequence Cancel', size=256, required=True), |
567 | + 'reason': fields.char('Reason for the cancellation', size=256, required=True), |
568 | + 'invoice_id': fields.many2one('account.invoice', 'Invoice', required=True), |
569 | + 'date': fields.date('Date of Request', required=True), |
570 | + 'user_request': fields.many2one('res.users', 'Requesting User', readonly=True), |
571 | + 'user_approve': fields.many2one('res.users', 'Approbation User', readonly=True), |
572 | + 'user_ratify': fields.many2one('res.users', 'Ratification of User', readonly=True), |
573 | + 'state': fields.selection([('draft', 'Draft'),('approved', 'Approved'), |
574 | + ('ratified', 'Ratified'),('done', 'Done')], 'State', readonly=True), |
575 | + 'company_id': fields.many2one('res.company', 'Company', required=True), |
576 | + 'period_id': fields.many2one('account.period', 'Period', required=True), |
577 | + 'partner_id': fields.many2one('res.partner', 'Partner', required=True), |
578 | + 'move_id': fields.many2one('account.move', 'Journal Entry'), |
579 | + 'move_cancel_ids': fields.many2many('account.move', 'cancel_invoice_move_rel', 'cancel_id', 'move_id', 'Journal Entries Canceled'), |
580 | + 'reference': fields.related('invoice_id', 'reference', type='char', size=128, string='Reference Invoice', store=True, readonly=True), |
581 | + 'date_invoice': fields.related('invoice_id', 'date_invoice', type='date', string='Date Invoice', readonly=True), |
582 | + 'date_document_invoice': fields.related('invoice_id', 'date_document', type='date', string='Date Document Invoice', readonly=True), |
583 | + 'log_lines': fields.function(_get_logs, method=True, type='many2many', relation='log.cancel.invoice', string='Log Cancel'), |
584 | + } |
585 | + |
586 | + _defaults = { |
587 | + 'state': 'draft', |
588 | + 'user_request': lambda obj, cr, uid, context: uid, |
589 | + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, |
590 | + 'date': lambda *a: time.strftime('%Y-%m-%d'), |
591 | + 'period_id': _get_period, |
592 | + 'name': '/', |
593 | + } |
594 | + |
595 | + _sql_constraints = [ |
596 | + ('code_invoice_uniq', 'unique (invoice_id)', 'The invoice is already in another document!') |
597 | + ] |
598 | + |
599 | + |
600 | + #~ def onchange_fecha_periodo(self, cr, uid, ids, fecha, context=None): |
601 | + #~ """ |
602 | + #~ On change para modificar el periodo, al momento de insertar una fecha |
603 | + #~ """ |
604 | + #~ period_obj = self.pool.get('account.period') |
605 | + #~ if not ids: |
606 | + #~ ids = context.get('active_id', False) |
607 | + #~ if fecha and ids: |
608 | + #~ periodo = period_obj.find(cr, uid, fecha) |
609 | + #~ periodo = period_obj.search(cr, uid, [('date_start', '<=', fecha), ('date_stop', '>=', fecha), ('state', '=', 'draft')]) |
610 | + #~ if not periodo: |
611 | + #~ return {'value': {'periodo': None}, 'warning': {'message': 'El periodo para la fecha esta cerrado o no existe'}} |
612 | + #~ return {'value': {'periodo': periodo}} |
613 | + #~ else: |
614 | + #~ return {'value': {'periodo': None}} |
615 | + |
616 | + |
617 | + def create(self, cr, user, vals, context=None): |
618 | + if context is None: |
619 | + context = {} |
620 | + |
621 | + vals['name'] = self.pool.get('ir.sequence').get(cr, user, 'anular.factura.seq') |
622 | + new_id = super(cancel_invoice, self).create(cr, user, vals, context) |
623 | + |
624 | + return new_id |
625 | + |
626 | + |
627 | + def crear_log(self, cr, uid, ids, modif, text_m=False, context=None): |
628 | + if context is None: |
629 | + context = {} |
630 | + |
631 | + obj_log_invoice = self.pool.get('log.cancel.invoice') |
632 | + |
633 | + dict_state = { |
634 | + 'draft': 'Borrador', |
635 | + 'approved': 'Aprobado', |
636 | + 'ratified': 'Ratificado', |
637 | + 'done': 'Ejecutado', |
638 | + 'vacio': 'Error', |
639 | + } |
640 | + |
641 | + if isinstance(ids, list): |
642 | + id = ids[0] |
643 | + else: |
644 | + id = ids |
645 | + |
646 | + obj_cancel = self.browse(cr, uid, id, context=context) |
647 | + if text_m: |
648 | + text = text_m |
649 | + else: |
650 | + text = "Documento: %s, Factura: %s, se ha %s"%(obj_cancel.name, obj_cancel.invoice_id.reference, dict_state[modif.get('state', 'vacio')]) |
651 | + |
652 | + log_dict = { |
653 | + 'name': text, |
654 | + 'res_model': 'cancel.invoice', |
655 | + 'res_id': id, |
656 | + } |
657 | + obj_log_invoice.create(cr, uid, log_dict, context=context) |
658 | + return True |
659 | + |
660 | + |
661 | + def aprobar_cancelacion(self, cr, uid, ids, context=None): |
662 | + if context is None: |
663 | + context = {} |
664 | + |
665 | + modif = {'state': 'approved', 'user_approve': uid} |
666 | + self.crear_log(cr, uid, ids, modif, False, context=context) |
667 | + self.write(cr, uid, ids, modif, context=context) |
668 | + return True |
669 | + |
670 | + |
671 | + def ratificar_cancelacion(self, cr, uid, ids, context=None): |
672 | + if context is None: |
673 | + context = {} |
674 | + |
675 | + modif = {'state': 'ratified', 'user_ratify': uid} |
676 | + self.crear_log(cr, uid, ids, modif, False, context=context) |
677 | + self.write(cr, uid, ids, modif, context=context) |
678 | + return True |
679 | + |
680 | + |
681 | + def ejecutar_cancelacion(self, cr, uid, ids, context=None): |
682 | + if context is None: |
683 | + context = {} |
684 | + |
685 | + if self.validar_factura(cr, uid, ids, context=context): |
686 | + self.create_account_move_reverse(cr, uid, ids, context=context) |
687 | + self.anular_imputaciones(cr, uid, ids, context=context) |
688 | + modif = {'state': 'done'} |
689 | + self.crear_log(cr, uid, ids, modif, False, context=context) |
690 | + self.write(cr, uid, ids, modif, context=context) |
691 | + return True |
692 | + else: |
693 | + return False |
694 | + |
695 | + |
696 | + def validar_factura(self, cr, uid, ids, context=None): |
697 | + obj_wh_src_line = self.pool.get("account.wh.src.line") |
698 | + obj_wh_muni_line = self.pool.get("account.wh.muni.line") |
699 | + obj_wh_iva_line = self.pool.get("account.wh.iva.line") |
700 | + obj_wh_islr_line = self.pool.get("islr.wh.doc.line") |
701 | + |
702 | + cancel_brw = self.browse(cr, uid, ids, context=context)[0] |
703 | + invoice = cancel_brw.invoice_id |
704 | + |
705 | + """ Se valida que se encuentre en el mismo periodo la factura """ |
706 | + if invoice.period_id.id != cancel_brw.period_id.id: |
707 | + raise osv.except_osv(_('Error !'), _('La factura se encuentra fuera de periodo. No puede ser anulado')) |
708 | + |
709 | + """ Se valida que la factura no posea notas de credito/debito """ |
710 | + if invoice.child_ids: |
711 | + raise osv.except_osv(_('Error !'), _('La factura posee notas de credito o debito, no puede ser anulada.')) |
712 | + |
713 | + """ Verificar retenciones """ |
714 | + move_wh_list = [] |
715 | + if invoice.islr_wh_doc_id or obj_wh_islr_line.search(cr, uid, [('invoice_id','=',invoice.id)]): |
716 | + """ Impuestos ISLR""" |
717 | + move_wh_list += self.validar_islr(cr, uid, ids, context=context) |
718 | + |
719 | + if invoice.wh_iva_id or obj_wh_iva_line.search(cr, uid, [('invoice_id','=',invoice.id)]): |
720 | + """ Impuestos IVA""" |
721 | + move_wh_list += self.validar_iva(cr, uid, ids, context=context) |
722 | + |
723 | + if invoice.wh_src_id or obj_wh_src_line.search(cr, uid, [('invoice_id','=',invoice.id)]): |
724 | + """ Impuestos SRC""" |
725 | + move_wh_list += self.validar_src(cr, uid, ids, context=context) |
726 | + |
727 | + if invoice.wh_muni_id or obj_wh_muni_line.search(cr, uid, [('invoice_id','=',invoice.id)]): |
728 | + """ Impuestos MUNI""" |
729 | + move_wh_list += self.validar_muni(cr, uid, ids, context=context) |
730 | + |
731 | + """ Validar Pagos """ |
732 | + move_ids = [x.move_id.id for x in invoice.move_lines] |
733 | + if len(list(set(move_ids)-set(move_wh_list))) > 0: |
734 | + raise osv.except_osv(_('Error !'), _('La factura posee pagos distintos a retenciones, debe cancelar estos pagos antes de continuar.')) |
735 | + |
736 | + return True |
737 | + |
738 | + |
739 | + def validar_islr(self, cr, uid, ids, context=None): |
740 | + """ Funcion para validar impuestos islr """ |
741 | + obj_wh_islr_line = self.pool.get("islr.wh.doc.line") |
742 | + |
743 | + cancel_brw = self.browse(cr, uid, ids, context=context)[0] |
744 | + invoice = cancel_brw.invoice_id |
745 | + |
746 | + moves_wh_list = [] |
747 | + |
748 | + wh_islr = invoice.islr_wh_doc_id |
749 | + if not invoice.islr_wh_doc_id: |
750 | + line_ids = obj_wh_islr_line.search(cr, uid, [('invoice_id','=',invoice.id)]) |
751 | + wh_islr = obj_wh_islr_line.browse(cr, uid, line_ids)[0].islr_wh_doc_id |
752 | + |
753 | + if wh_islr.state == 'done': |
754 | + if wh_islr.period_id.id != cancel_brw.period_id.id: |
755 | + raise osv.except_osv(_('Error !'), _('La retencion de ISLR se encuentra fuera de periodo. No puede ser anulado')) |
756 | + |
757 | + for islr_line in wh_islr.concept_ids: |
758 | + if islr_line.move_id: |
759 | + moves_wh_list.append(islr_line.move_id.id) |
760 | + if islr_line.invoice_id.id != invoice.id: |
761 | + raise osv.except_osv(_('Error !'), _('La retencion de ISLR pertenece a diferentes facturas. No puede ser anulado')) |
762 | + |
763 | + return moves_wh_list |
764 | + |
765 | + |
766 | + def validar_iva(self, cr, uid, ids, context=None): |
767 | + """ Funcion para validar impuestos iva """ |
768 | + txt_iva_line = self.pool.get('txt.iva.line') |
769 | + obj_wh_iva_line = self.pool.get("account.wh.iva.line") |
770 | + cancel_brw = self.browse(cr, uid, ids, context=context)[0] |
771 | + invoice = cancel_brw.invoice_id |
772 | + |
773 | + moves_wh_list = [] |
774 | + |
775 | + wh_iva = invoice.wh_iva_id |
776 | + if not invoice.wh_iva_id: |
777 | + line_ids = obj_wh_iva_line.search(cr, uid, [('invoice_id','=',invoice.id)]) |
778 | + wh_iva = obj_wh_iva_line.browse(cr, uid, line_ids)[0].retention_id |
779 | + |
780 | + txt_lines = txt_iva_line.search(cr, uid, [('invoice_id','=',invoice.id)]) |
781 | + if len(txt_lines) > 0: |
782 | + raise osv.except_osv(_('Error !'), _('La retencion de IVA se encuentra fuera de periodo impositivo. No puede ser anulado')) |
783 | + |
784 | + #if wh_iva.state == 'done': |
785 | + for iva_line in wh_iva.wh_lines: |
786 | + if iva_line.move_id: |
787 | + moves_wh_list.append(iva_line.move_id.id) |
788 | + if iva_line.invoice_id.id != invoice.id: |
789 | + raise osv.except_osv(_('Error !'), _('La retencion de IVA pertenece a diferentes facturas. No puede ser anulado')) |
790 | + |
791 | + return moves_wh_list |
792 | + |
793 | + |
794 | + def validar_src(self, cr, uid, ids, context=None): |
795 | + """ Funcion para validar impuestos src """ |
796 | + obj_wh_src_line = self.pool.get("account.wh.src.line") |
797 | + cancel_brw = self.browse(cr, uid, ids, context=context)[0] |
798 | + invoice = cancel_brw.invoice_id |
799 | + |
800 | + moves_wh_list = [] |
801 | + |
802 | + wh_src = invoice.wh_src_id |
803 | + if not invoice.wh_src_id: |
804 | + line_ids = obj_wh_src_line.search(cr, uid, [('invoice_id','=',invoice.id)]) |
805 | + wh_src = obj_wh_src_line.browse(cr, uid, line_ids)[0].wh_id |
806 | + |
807 | + if wh_src.state == 'done': |
808 | + if wh_src.period_id.id != cancel_brw.period_id.id: |
809 | + raise osv.except_osv(_('Error !'), _('La retencion de Responsabilidad Social se encuentra fuera de periodo. No puede ser anulado')) |
810 | + |
811 | + for src_line in wh_src.line_ids: |
812 | + if src_line.move_id: |
813 | + moves_wh_list.append(src_line.move_id.id) |
814 | + if src_line.invoice_id.id != invoice.id: |
815 | + raise osv.except_osv(_('Error !'), _('La retencion de Responsabilidad Social pertenece a diferentes facturas. No puede ser anulado')) |
816 | + |
817 | + return moves_wh_list |
818 | + |
819 | + |
820 | + def validar_muni(self, cr, uid, ids, context=None): |
821 | + """ Funcion para validar impuestos muni """ |
822 | + obj_wh_muni_line = self.pool.get("account.wh.muni.line") |
823 | + cancel_brw = self.browse(cr, uid, ids, context=context)[0] |
824 | + invoice = cancel_brw.invoice_id |
825 | + |
826 | + moves_wh_list = [] |
827 | + |
828 | + wh_muni = invoice.wh_muni_id |
829 | + if not invoice.wh_muni_id: |
830 | + line_ids = obj_wh_muni_line.search(cr, uid, [('invoice_id','=',invoice.id)]) |
831 | + wh_muni = obj_wh_muni_line.browse(cr, uid, line_ids)[0].wh_id |
832 | + |
833 | + if wh_muni.state == 'done': |
834 | + if wh_muni.period_id.id != cancel_brw.period_id.id: |
835 | + raise osv.except_osv(_('Error !'), _('La retencion Municipal se encuentra fuera de periodo. No puede ser anulado')) |
836 | + |
837 | + for muni_line in wh_muni.line_ids: |
838 | + if muni_line.move_id: |
839 | + moves_wh_list.append(muni_line.move_id.id) |
840 | + if muni_line.invoice_id.id != invoice.id: |
841 | + raise osv.except_osv(_('Error !'), _('La retencion Municipal pertenece a diferentes facturas. No puede ser anulado')) |
842 | + |
843 | + return moves_wh_list |
844 | + |
845 | + |
846 | + def create_account_move_reverse(self, cr, uid, ids, context=None): |
847 | + obj_acc_move = self.pool.get("account.move") |
848 | + obj_acc_move_line = self.pool.get("account.move.line") |
849 | + obj_analityc_line = self.pool.get("account.analytic.line") |
850 | + obj_inv = self.pool.get("account.invoice") |
851 | + obj_data = self.pool.get('ir.model.data') |
852 | + obj_period = self.pool.get('account.period') |
853 | + obj_journal = self.pool.get('account.journal') |
854 | + obj_picking = self.pool.get('stock.picking') |
855 | + obj_purchase = self.pool.get('purchase.order') |
856 | + |
857 | + data_id = obj_data.search(cr, uid, [('model','=','account.journal'), ('name','=','sisb_journal_invoice_cancel')]) |
858 | + data = obj_data.browse(cr, uid, data_id[0], context=context) |
859 | + |
860 | + obj_cancel = self.browse(cr, uid, ids, context=context)[0] |
861 | + |
862 | + invoice_id = obj_cancel.invoice_id |
863 | + move_inv_ids = invoice_id.move_id and [invoice_id.move_id.id] or [] |
864 | + |
865 | + brw_move = obj_acc_move.browse(cr, uid, move_inv_ids, context) |
866 | + |
867 | + reconcil_ids = [] |
868 | + unreconcil_ids = [] |
869 | + journal_id = data.res_id or False |
870 | + date = time.strftime('%Y-%m-%d') |
871 | + period_id = obj_period.find(cr, uid, date, context=context) |
872 | + if isinstance(period_id, list): |
873 | + period_id = period_id[0] |
874 | + |
875 | + journal_brw = obj_journal.browse(cr, uid, journal_id, context=context) |
876 | + |
877 | + company_currency = journal_brw.company_id.currency_id.id |
878 | + current_currency = invoice_id.currency_id.id |
879 | + ref_anulado = 'anulado-'+invoice_id.reference |
880 | + |
881 | + info_move = { |
882 | + 'cancel_invoice': obj_cancel, |
883 | + 'journal_id': journal_id, |
884 | + 'period_id': period_id, |
885 | + 'date': date, |
886 | + 'currency_id': company_currency <> current_currency and current_currency or False, |
887 | + } |
888 | + |
889 | + if invoice_id.move_id: |
890 | + move = invoice_id.move_id |
891 | + #Creando asiento para reverso |
892 | + move_dict = { |
893 | + #~ 'name': obj.name, |
894 | + 'ref': move.name, |
895 | + 'to_check': 1, |
896 | + 'journal_id': journal_id, |
897 | + 'period_id': period_id, |
898 | + 'date': date, |
899 | + 'company_id': move.company_id.id, |
900 | + } |
901 | + |
902 | + move_id = obj_acc_move.create(cr, uid, move_dict, context) |
903 | + total_amount = 0.0 |
904 | + obj_acc_move.write(cr, uid, [invoice_id.move_id.id], {'ref': ref_anulado}, context=context) |
905 | + |
906 | + brw_move_reverse = obj_acc_move.browse(cr, uid, move_id, context) |
907 | + text_m = "Documento: %s, Factura: %s, Se crea Asiento Reverso"%(obj_cancel.name, obj_cancel.invoice_id.reference) |
908 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
909 | + |
910 | + if move_id: |
911 | + unreconcil_ids = [x.id for x in move.line_id if x.account_id.id == invoice_id.account_id.id] |
912 | + #Creando reverso de apuntes |
913 | + for line in move.line_id: |
914 | + credit = line.debit or 0.0 |
915 | + debit = line.credit or 0.0 |
916 | + move_line = { |
917 | + 'journal_id': journal_id, |
918 | + 'credit': credit, |
919 | + 'debit': debit, |
920 | + 'account_id': line.account_id.id, |
921 | + 'period_id': period_id, |
922 | + 'move_id': move_id, |
923 | + 'name': line.name, |
924 | + 'partner_id': line.partner_id and line.partner_id.id or False, |
925 | + 'date': date, |
926 | + 'currency_id': info_move['currency_id'], |
927 | + 'analytic_account_id': line.analytic_account_id and line.analytic_account_id.id or False, |
928 | + 'tax_amount': line.tax_amount, |
929 | + 'amount_currency': line.amount_currency, |
930 | + 'product_id': line.product_id and line.product_id.id or False, |
931 | + 'product_uom_id': line.product_uom_id and line.product_uom_id.id or False, |
932 | + 'quantity': line.quantity, |
933 | + } |
934 | + move_line_id = obj_acc_move_line.create(cr, uid, move_line, context) |
935 | + if line.account_id.id == invoice_id.account_id.id: |
936 | + reconcil_ids.append(move_line_id) |
937 | + |
938 | + """ Modificando referencias """ |
939 | + obj_acc_move_line.write(cr, uid, [line.id], {'ref': ref_anulado}, context=context) |
940 | + |
941 | + """ Se agrega informacion de la eliminacion """ |
942 | + name_inv = invoice_id.name or '' |
943 | + self.write(cr, uid, ids, {'move_cancel_ids': [(4, invoice_id.move_id.id)], 'move_id': move_id}, context=context) |
944 | + obj_inv.write(cr, uid, [invoice_id.id], {'name': ref_anulado+' '+name_inv, 'reference': ref_anulado, 'nro_ctrl': 'anulado-'+invoice_id.nro_ctrl,'cancel_invoice_id': obj_cancel.id, 'move_id': False}, context=context) |
945 | + text_m = "Documento: %s, Factura: %s, Se modifican datos de la factura y se desvincula asiento %s de la factura"%(obj_cancel.name, obj_cancel.invoice_id.reference, move.name) |
946 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
947 | + |
948 | + """ Eliminar otros documentos """ |
949 | + reconcil_wh_ids, unreconcil_wh_ids = self.borrar_retenciones(cr, uid, ids, move_id, info_move, context=context) |
950 | + |
951 | + if unreconcil_wh_ids: |
952 | + unreconcil_ids += unreconcil_wh_ids |
953 | + |
954 | + if reconcil_wh_ids: |
955 | + reconcil_ids += reconcil_wh_ids |
956 | + |
957 | + reconcil_ids += unreconcil_ids |
958 | + |
959 | + """ Desconciliar Apuntes usados en la factura """ |
960 | + obj_acc_move_line._remove_move_reconcile(cr, uid, unreconcil_ids, context=context) |
961 | + text_m = "Documento: %s, Factura: %s, Se desconcilian asientos asociados a la factura"%(obj_cancel.name, obj_cancel.invoice_id.reference) |
962 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
963 | + |
964 | + """ Aprobar asiento """ |
965 | + isok = obj_acc_move.button_validate(cr, uid, [move_id], context) |
966 | + |
967 | + """ Se concilian los apuntes de la factura del reverso """ |
968 | + isok = obj_acc_move_line.reconcile_partial(cr, uid, reconcil_ids, 'manual', context) |
969 | + text_m = "Documento: %s, Factura: %s, Se concilian asientos con asiento reverso"%(obj_cancel.name, obj_cancel.invoice_id.reference) |
970 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
971 | + |
972 | + """ Se activa el workflow de la factura para reinicio del workflow del documento y luego cancelar """ |
973 | + wf_service = netsvc.LocalService("workflow") |
974 | + wf_service.trg_delete(uid, 'account.invoice', invoice_id.id, cr) |
975 | + wf_service.trg_create(uid, 'account.invoice', invoice_id.id, cr) |
976 | + wf_service.trg_validate(uid, 'account.invoice', invoice_id.id, 'anular_factura', cr) |
977 | + text_m = "Documento: %s, Factura: %s, Se cancela factura"%(obj_cancel.name, obj_cancel.invoice_id.reference) |
978 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
979 | + |
980 | + if invoice_id.sisb_picking_ids: |
981 | + """ Colocar albaranes para facturar """ |
982 | + for picking in invoice_id.sisb_picking_ids: |
983 | + obj_picking.write(cr, uid, [picking.id], {'invoice_state': '2binvoiced'}, context=context) |
984 | + obj_inv.write(cr, uid, [invoice_id.id], {'sisb_picking_ids': [(3, picking.id)]}) |
985 | + text_m = "Documento: %s, Factura: %s, Se coloca Albaran %s para facturar"%(obj_cancel.name, obj_cancel.invoice_id.reference, picking.name) |
986 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
987 | + else: |
988 | + """ No hay albaranes crear otra vez factura con metodo desde compra""" |
989 | + for purchase in invoice_id.sisb_purchase_ids: |
990 | + #~ obj_purchase.wkf_confirm_order(cr, uid, [purchase.id], context=context) |
991 | + obj_purchase.action_invoice_create(cr, uid, [purchase.id], context) |
992 | + #~ wf_service.trg_validate(uid, 'purchase.order', purchase.id, 'purchase_confirm', cr) |
993 | + |
994 | + else: |
995 | + raise osv.except_osv(_('Alert !'), _('The account move wasn\'t created, process aborted.')) |
996 | + |
997 | + return True |
998 | + |
999 | + |
1000 | + def borrar_retenciones(self, cr, uid, ids, move_id, info_move, context=None): |
1001 | + obj_wh_islr_line = self.pool.get("islr.wh.doc.line") |
1002 | + obj_wh_iva_line = self.pool.get("account.wh.iva.line") |
1003 | + obj_wh_src_line = self.pool.get("account.wh.src.line") |
1004 | + obj_wh_muni_line = self.pool.get("account.wh.muni.line") |
1005 | + |
1006 | + reconcil_wh_ids_total = [] |
1007 | + unreconcil_wh_ids_total = [] |
1008 | + reconcil_wh_ids = [] |
1009 | + unreconcil_wh_ids = [] |
1010 | + cancel_invoice = info_move['cancel_invoice'] |
1011 | + |
1012 | + """ Eliminar Retencion de ISLR """ |
1013 | + if cancel_invoice.invoice_id.islr_wh_doc_id or obj_wh_islr_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]): |
1014 | + wh_name = cancel_invoice.invoice_id.islr_wh_doc_id |
1015 | + if wh_name: |
1016 | + wh_name = wh_name.name |
1017 | + else: |
1018 | + line_ids = obj_wh_islr_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]) |
1019 | + wh_name = obj_wh_islr_line.browse(cr, uid, line_ids)[0].islr_wh_doc_id.name |
1020 | + text_m = "Documento: %s, Factura: %s, Se inicia cancelacion de retencion de ISLR %s"%(cancel_invoice.name, cancel_invoice.invoice_id.reference, wh_name) |
1021 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1022 | + reconcil_wh_ids, unreconcil_wh_ids = self.anular_retencion_islr(cr, uid, ids, move_id, info_move, context=context) |
1023 | + reconcil_wh_ids_total += reconcil_wh_ids |
1024 | + unreconcil_wh_ids_total += unreconcil_wh_ids |
1025 | + |
1026 | + reconcil_wh_ids = [] |
1027 | + unreconcil_wh_ids = [] |
1028 | + """ Eliminar Retencion de IVA """ |
1029 | + if cancel_invoice.invoice_id.wh_iva_id or obj_wh_iva_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]): |
1030 | + wh_name = cancel_invoice.invoice_id.wh_iva_id |
1031 | + if wh_name: |
1032 | + wh_name = wh_name.name |
1033 | + else: |
1034 | + line_ids = obj_wh_iva_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]) |
1035 | + wh_name = obj_wh_iva_line.browse(cr, uid, line_ids)[0].retention_id.name |
1036 | + text_m = "Documento: %s, Factura: %s, Se inicia cancelacion de retencion de IVA %s"%(cancel_invoice.name, cancel_invoice.invoice_id.reference, wh_name) |
1037 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1038 | + reconcil_wh_ids, unreconcil_wh_ids = self.anular_retencion_iva(cr, uid, ids, move_id, info_move, context=context) |
1039 | + reconcil_wh_ids_total += reconcil_wh_ids |
1040 | + unreconcil_wh_ids_total += unreconcil_wh_ids |
1041 | + |
1042 | + reconcil_wh_ids = [] |
1043 | + unreconcil_wh_ids = [] |
1044 | + """ Eliminar Retencion de Responsabilidad Social """ |
1045 | + if cancel_invoice.invoice_id.wh_src_id or obj_wh_src_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]): |
1046 | + wh_name = cancel_invoice.invoice_id.wh_src_id |
1047 | + if wh_name: |
1048 | + wh_name = wh_name.number |
1049 | + else: |
1050 | + line_ids = obj_wh_src_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]) |
1051 | + wh_name = obj_wh_src_line.browse(cr, uid, line_ids)[0].wh_id.number |
1052 | + text_m = "Documento: %s, Factura: %s, Se inicia cancelacion de retencion de SRC %s"%(cancel_invoice.name, cancel_invoice.invoice_id.reference, wh_name) |
1053 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1054 | + reconcil_wh_ids, unreconcil_wh_ids = self.anular_retencion_src(cr, uid, ids, move_id, info_move, context=context) |
1055 | + reconcil_wh_ids_total += reconcil_wh_ids |
1056 | + unreconcil_wh_ids_total += unreconcil_wh_ids |
1057 | + |
1058 | + reconcil_wh_ids = [] |
1059 | + unreconcil_wh_ids = [] |
1060 | + """ Eliminar Retencion de Municipal """ |
1061 | + if cancel_invoice.invoice_id.wh_muni_id or obj_wh_muni_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]): |
1062 | + wh_name = cancel_invoice.invoice_id.wh_muni_id |
1063 | + if wh_name: |
1064 | + wh_name = wh_name.name |
1065 | + else: |
1066 | + line_ids = obj_wh_muni_line.search(cr, uid, [('invoice_id','=',cancel_invoice.invoice_id.id)]) |
1067 | + wh_name = obj_wh_muni_line.browse(cr, uid, line_ids)[0].wh_id.name |
1068 | + text_m = "Documento: %s, Factura: %s, Se inicia cancelacion de retencion de Municipal %s"%(cancel_invoice.name, cancel_invoice.invoice_id.reference, wh_name) |
1069 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1070 | + reconcil_wh_ids, unreconcil_wh_ids = self.anular_retencion_muni(cr, uid, ids, move_id, info_move, context=context) |
1071 | + reconcil_wh_ids_total += reconcil_wh_ids |
1072 | + unreconcil_wh_ids_total += unreconcil_wh_ids |
1073 | + |
1074 | + return reconcil_wh_ids_total, unreconcil_wh_ids_total |
1075 | + |
1076 | + |
1077 | + def anular_retencion_islr(self, cr, uid, ids, move_id, info_move, context=None): |
1078 | + """ Funcion para eliminar retencion de impuestos sobre la renta |
1079 | + y anular el documento. """ |
1080 | + obj_acc_move = self.pool.get("account.move") |
1081 | + obj_acc_move_line = self.pool.get("account.move.line") |
1082 | + obj_inv = self.pool.get("account.invoice") |
1083 | + obj_xml_doc_line = self.pool.get("islr.wh.doc.line") |
1084 | + obj_xml_wh_line = self.pool.get("islr.xml.wh.line") |
1085 | + |
1086 | + reconcil_ids = [] |
1087 | + unreconcil_ids = [] |
1088 | + |
1089 | + cancel_invoice = info_move['cancel_invoice'] |
1090 | + invoice_id = cancel_invoice.invoice_id |
1091 | + wh_islr = invoice_id.islr_wh_doc_id |
1092 | + if not invoice_id.islr_wh_doc_id: |
1093 | + line_ids = obj_xml_doc_line.search(cr, uid, [('invoice_id','=',invoice_id.id)]) |
1094 | + wh_islr = obj_xml_doc_line.browse(cr, uid, line_ids)[0].islr_wh_doc_id |
1095 | + |
1096 | + for concept in wh_islr.concept_ids: |
1097 | + if concept.move_id: |
1098 | + unreconcil_ids = [x.id for x in concept.move_id.line_id if x.account_id.id == invoice_id.account_id.id] |
1099 | + for line in concept.move_id.line_id: |
1100 | + credit = line.debit or 0.0 |
1101 | + debit = line.credit or 0.0 |
1102 | + move_line = { |
1103 | + 'journal_id': info_move['journal_id'], |
1104 | + 'credit': credit, |
1105 | + 'debit': debit, |
1106 | + 'account_id': line.account_id.id, |
1107 | + 'period_id': info_move['period_id'], |
1108 | + 'move_id': move_id, |
1109 | + 'name': line.name, |
1110 | + 'partner_id': line.partner_id and line.partner_id.id or False, |
1111 | + 'date': info_move['date'], |
1112 | + 'currency_id': info_move['currency_id'], |
1113 | + 'analytic_account_id': line.analytic_account_id and line.analytic_account_id.id or False, |
1114 | + 'tax_amount': line.tax_amount, |
1115 | + 'amount_currency': line.amount_currency, |
1116 | + 'product_id': line.product_id and line.product_id.id or False, |
1117 | + 'product_uom_id': line.product_uom_id and line.product_uom_id.id or False, |
1118 | + 'quantity': line.quantity, |
1119 | + } |
1120 | + move_line_id = obj_acc_move_line.create(cr, uid, move_line, context) |
1121 | + if line.account_id.id == invoice_id.account_id.id: |
1122 | + reconcil_ids.append(move_line_id) |
1123 | + |
1124 | + obj_acc_move_line.write(cr, uid, [line.id], {'name': 'ANULADO-'+line.name}, context=context) |
1125 | + |
1126 | + self.write(cr, uid, ids, {'move_cancel_ids': [(4, concept.move_id.id)]}, context=context) |
1127 | + text_m = "Documento: %s, Factura: %s, Se desvincula asiento %s de la retencion de ISLR %s"%(cancel_invoice.name, invoice_id.reference, concept.move_id.name, wh_islr.name) |
1128 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1129 | + obj_xml_doc_line.write(cr, uid, [concept.id], {'move_id': False}, context=context) |
1130 | + |
1131 | + if concept.xml_ids: |
1132 | + del_xml = [x.id for x in concept.xml_ids] |
1133 | + obj_xml_wh_line.unlink(cr, uid, del_xml) |
1134 | + text_m = "Documento: %s, Factura: %s, Se eliminan lineas xml de la retencion de ISLR %s"%(cancel_invoice.name, invoice_id.reference, wh_islr.name) |
1135 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1136 | + |
1137 | + """ Se activa el workflow de la retencion islr para reinicio del workflow del documento y luego cancelar """ |
1138 | + wf_service = netsvc.LocalService("workflow") |
1139 | + wf_service.trg_delete(uid, 'islr.wh.doc', wh_islr.id, cr) |
1140 | + wf_service.trg_create(uid, 'islr.wh.doc', wh_islr.id, cr) |
1141 | + wf_service.trg_validate(uid, 'islr.wh.doc', wh_islr.id, 'anular_factura', cr) |
1142 | + text_m = "Documento: %s, Factura: %s, Se cancela retencion de ISLR %s"%(cancel_invoice.name, invoice_id.reference, wh_islr.name) |
1143 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1144 | + |
1145 | + return reconcil_ids, unreconcil_ids |
1146 | + |
1147 | + |
1148 | + def anular_retencion_iva(self, cr, uid, ids, move_id, info_move, context=None): |
1149 | + """ Funcion para eliminar retencion de impuestos al valor agregado |
1150 | + y anular el documento. """ |
1151 | + obj_acc_move_line = self.pool.get("account.move.line") |
1152 | + obj_inv = self.pool.get("account.invoice") |
1153 | + obj_wh_iva_line = self.pool.get("account.wh.iva.line") |
1154 | + obj_wh_iva_line_tax = self.pool.get("account.wh.iva.line.tax") |
1155 | + |
1156 | + reconcil_ids = [] |
1157 | + unreconcil_ids = [] |
1158 | + |
1159 | + cancel_invoice = info_move['cancel_invoice'] |
1160 | + invoice_id = cancel_invoice.invoice_id |
1161 | + wh_iva = invoice_id.wh_iva_id |
1162 | + if not invoice_id.wh_iva_id: |
1163 | + line_ids = obj_wh_iva_line.search(cr, uid, [('invoice_id','=',invoice_id.id)]) |
1164 | + wh_iva = obj_wh_iva_line.browse(cr, uid, line_ids)[0].retention_id |
1165 | + |
1166 | + for iva_line in wh_iva.wh_lines: |
1167 | + if iva_line.move_id: |
1168 | + unreconcil_ids = [x.id for x in iva_line.move_id.line_id if x.account_id.id == invoice_id.account_id.id] |
1169 | + for line in iva_line.move_id.line_id: |
1170 | + credit = line.debit or 0.0 |
1171 | + debit = line.credit or 0.0 |
1172 | + move_line = { |
1173 | + 'journal_id': info_move['journal_id'], |
1174 | + 'credit': credit, |
1175 | + 'debit': debit, |
1176 | + 'account_id': line.account_id.id, |
1177 | + 'period_id': info_move['period_id'], |
1178 | + 'move_id': move_id, |
1179 | + 'name': line.name, |
1180 | + 'partner_id': line.partner_id and line.partner_id.id or False, |
1181 | + 'date': info_move['date'], |
1182 | + 'currency_id': info_move['currency_id'], |
1183 | + 'analytic_account_id': line.analytic_account_id and line.analytic_account_id.id or False, |
1184 | + 'tax_amount': line.tax_amount, |
1185 | + 'amount_currency': line.amount_currency, |
1186 | + 'product_id': line.product_id and line.product_id.id or False, |
1187 | + 'product_uom_id': line.product_uom_id and line.product_uom_id.id or False, |
1188 | + 'quantity': line.quantity, |
1189 | + } |
1190 | + move_line_id = obj_acc_move_line.create(cr, uid, move_line, context) |
1191 | + if line.account_id.id == invoice_id.account_id.id: |
1192 | + reconcil_ids.append(move_line_id) |
1193 | + |
1194 | + obj_acc_move_line.write(cr, uid, [line.id], {'name': 'ANULADO-'+line.name}, context=context) |
1195 | + |
1196 | + self.write(cr, uid, ids, {'move_cancel_ids': [(4, iva_line.move_id.id)]}, context=context) |
1197 | + text_m = "Documento: %s, Factura: %s, Se desvincula asiento %s de la retencion de IVA %s"%(cancel_invoice.name, invoice_id.reference, iva_line.move_id.name, wh_iva.name) |
1198 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1199 | + obj_wh_iva_line.write(cr, uid, [iva_line.id], {'move_id': False}, context=context) |
1200 | + |
1201 | + #~ if iva_line.tax_line: |
1202 | + #~ del_tax = [x.id for x in iva_line.tax_line] |
1203 | + #~ obj_wh_iva_line_tax.unlink(cr, uid, del_tax) |
1204 | + #~ text_m = "Documento: %s, Factura: %s, Se eliminan lineas de impuesto de la retencion de IVA %s"%(cancel_invoice.name, invoice_id.reference, wh_iva.name) |
1205 | + #~ self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1206 | + |
1207 | + """ Se activa el workflow de la retencion iva para reinicio del workflow del documento y luego cancelar """ |
1208 | + wf_service = netsvc.LocalService("workflow") |
1209 | + wf_service.trg_delete(uid, 'account.wh.iva', wh_iva.id, cr) |
1210 | + wf_service.trg_create(uid, 'account.wh.iva', wh_iva.id, cr) |
1211 | + wf_service.trg_validate(uid, 'account.wh.iva', wh_iva.id, 'anular_factura', cr) |
1212 | + text_m = "Documento: %s, Factura: %s, Se cancela retencion de IVA %s"%(cancel_invoice.name, invoice_id.reference, wh_iva.name) |
1213 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1214 | + |
1215 | + return reconcil_ids, unreconcil_ids |
1216 | + |
1217 | + |
1218 | + def anular_retencion_src(self, cr, uid, ids, move_id, info_move, context=None): |
1219 | + """ Funcion para eliminar retencion de impuestos de responsabilidad social |
1220 | + y anular el documento. """ |
1221 | + obj_acc_move_line = self.pool.get("account.move.line") |
1222 | + obj_inv = self.pool.get("account.invoice") |
1223 | + obj_wh_src_line = self.pool.get("account.wh.src.line") |
1224 | + |
1225 | + reconcil_ids = [] |
1226 | + unreconcil_ids = [] |
1227 | + |
1228 | + cancel_invoice = info_move['cancel_invoice'] |
1229 | + invoice_id = cancel_invoice.invoice_id |
1230 | + wh_src = invoice_id.wh_src_id |
1231 | + if not invoice_id.wh_src_id: |
1232 | + line_ids = obj_wh_src_line.search(cr, uid, [('invoice_id','=',invoice_id.id)]) |
1233 | + wh_src = obj_wh_src_line.browse(cr, uid, line_ids)[0].wh_id |
1234 | + |
1235 | + for src_line in wh_src.line_ids: |
1236 | + if src_line.move_id: |
1237 | + unreconcil_ids = [x.id for x in src_line.move_id.line_id if x.account_id.id == invoice_id.account_id.id] |
1238 | + for line in src_line.move_id.line_id: |
1239 | + credit = line.debit or 0.0 |
1240 | + debit = line.credit or 0.0 |
1241 | + move_line = { |
1242 | + 'journal_id': info_move['journal_id'], |
1243 | + 'credit': credit, |
1244 | + 'debit': debit, |
1245 | + 'account_id': line.account_id.id, |
1246 | + 'period_id': info_move['period_id'], |
1247 | + 'move_id': move_id, |
1248 | + 'name': line.name, |
1249 | + 'partner_id': line.partner_id and line.partner_id.id or False, |
1250 | + 'date': info_move['date'], |
1251 | + 'currency_id': info_move['currency_id'], |
1252 | + 'analytic_account_id': line.analytic_account_id and line.analytic_account_id.id or False, |
1253 | + 'tax_amount': line.tax_amount, |
1254 | + 'amount_currency': line.amount_currency, |
1255 | + 'product_id': line.product_id and line.product_id.id or False, |
1256 | + 'product_uom_id': line.product_uom_id and line.product_uom_id.id or False, |
1257 | + 'quantity': line.quantity, |
1258 | + } |
1259 | + move_line_id = obj_acc_move_line.create(cr, uid, move_line, context) |
1260 | + if line.account_id.id == invoice_id.account_id.id: |
1261 | + reconcil_ids.append(move_line_id) |
1262 | + |
1263 | + obj_acc_move_line.write(cr, uid, [line.id], {'name': 'ANULADO-'+line.name}, context=context) |
1264 | + |
1265 | + self.write(cr, uid, ids, {'move_cancel_ids': [(4, src_line.move_id.id)]}, context=context) |
1266 | + text_m = "Documento: %s, Factura: %s, Se desvincula asiento %s de la retencion de SRC %s"%(cancel_invoice.name, invoice_id.reference, src_line.move_id.name, wh_src.number) |
1267 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1268 | + obj_wh_src_line.write(cr, uid, [src_line.id], {'move_id': False}, context=context) |
1269 | + |
1270 | + """ Se activa el workflow de la retencion src para reinicio del workflow del documento y luego cancelar """ |
1271 | + wf_service = netsvc.LocalService("workflow") |
1272 | + wf_service.trg_delete(uid, 'account.wh.src', wh_src.id, cr) |
1273 | + wf_service.trg_create(uid, 'account.wh.src', wh_src.id, cr) |
1274 | + wf_service.trg_validate(uid, 'account.wh.src', wh_src.id, 'anular_factura', cr) |
1275 | + text_m = "Documento: %s, Factura: %s, Se cancela retencion de SRC %s"%(cancel_invoice.name, invoice_id.reference, wh_src.number) |
1276 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1277 | + |
1278 | + return reconcil_ids, unreconcil_ids |
1279 | + |
1280 | + |
1281 | + def anular_retencion_muni(self, cr, uid, ids, move_id, info_move, context=None): |
1282 | + """ Funcion para eliminar retencion de impuestos municipales |
1283 | + y anular el documento. """ |
1284 | + obj_acc_move_line = self.pool.get("account.move.line") |
1285 | + obj_inv = self.pool.get("account.invoice") |
1286 | + obj_wh_muni_line = self.pool.get("account.wh.muni.line") |
1287 | + |
1288 | + reconcil_ids = [] |
1289 | + unreconcil_ids = [] |
1290 | + |
1291 | + cancel_invoice = info_move['cancel_invoice'] |
1292 | + invoice_id = cancel_invoice.invoice_id |
1293 | + wh_muni = invoice_id.wh_muni_id |
1294 | + if not invoice_id.wh_muni_id: |
1295 | + line_ids = obj_wh_muni_line.search(cr, uid, [('invoice_id','=',invoice_id.id)]) |
1296 | + wh_muni = obj_wh_muni_line.browse(cr, uid, line_ids)[0].wh_id |
1297 | + |
1298 | + for muni_line in wh_muni.line_ids: |
1299 | + if muni_line.move_id: |
1300 | + unreconcil_ids = [x.id for x in muni_line.move_id.line_id if x.account_id.id == invoice_id.account_id.id] |
1301 | + for line in muni_line.move_id.line_id: |
1302 | + credit = line.debit or 0.0 |
1303 | + debit = line.credit or 0.0 |
1304 | + move_line = { |
1305 | + 'journal_id': info_move['journal_id'], |
1306 | + 'credit': credit, |
1307 | + 'debit': debit, |
1308 | + 'account_id': line.account_id.id, |
1309 | + 'period_id': info_move['period_id'], |
1310 | + 'move_id': move_id, |
1311 | + 'name': line.name, |
1312 | + 'partner_id': line.partner_id and line.partner_id.id or False, |
1313 | + 'date': info_move['date'], |
1314 | + 'currency_id': info_move['currency_id'], |
1315 | + 'analytic_account_id': line.analytic_account_id and line.analytic_account_id.id or False, |
1316 | + 'tax_amount': line.tax_amount, |
1317 | + 'amount_currency': line.amount_currency, |
1318 | + 'product_id': line.product_id and line.product_id.id or False, |
1319 | + 'product_uom_id': line.product_uom_id and line.product_uom_id.id or False, |
1320 | + 'quantity': line.quantity, |
1321 | + } |
1322 | + move_line_id = obj_acc_move_line.create(cr, uid, move_line, context) |
1323 | + if line.account_id.id == invoice_id.account_id.id: |
1324 | + reconcil_ids.append(move_line_id) |
1325 | + |
1326 | + obj_acc_move_line.write(cr, uid, [line.id], {'name': 'ANULADO-'+line.name}, context=context) |
1327 | + |
1328 | + self.write(cr, uid, ids, {'move_cancel_ids': [(4, muni_line.move_id.id)]}, context=context) |
1329 | + text_m = "Documento: %s, Factura: %s, Se desvincula asiento %s de la retencion de Municipal %s"%(cancel_invoice.name, invoice_id.reference, muni_line.move_id.name, wh_muni.name) |
1330 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1331 | + obj_wh_muni_line.write(cr, uid, [muni_line.id], {'move_id': False}, context=context) |
1332 | + |
1333 | + """ Se activa el workflow de la retencion src para reinicio del workflow del documento y luego cancelar """ |
1334 | + wf_service = netsvc.LocalService("workflow") |
1335 | + wf_service.trg_delete(uid, 'account.wh.muni', wh_muni.id, cr) |
1336 | + wf_service.trg_create(uid, 'account.wh.muni', wh_muni.id, cr) |
1337 | + wf_service.trg_validate(uid, 'account.wh.muni', wh_muni.id, 'anular_factura', cr) |
1338 | + text_m = "Documento: %s, Factura: %s, Se cancela retencion de Municipal %s"%(cancel_invoice.name, invoice_id.reference, wh_muni.name) |
1339 | + self.crear_log(cr, uid, ids, {}, text_m, context=context) |
1340 | + |
1341 | + return reconcil_ids, unreconcil_ids |
1342 | + |
1343 | + |
1344 | + def anular_imputaciones(self, cr, uid, ids, context=None): |
1345 | + obj_inv = self.pool.get("account.invoice") |
1346 | + obj_imputacion = self.pool.get('presupuesto.imputacion.linea') |
1347 | + |
1348 | + obj_cancel = self.browse(cr, uid, ids, context=context)[0] |
1349 | + |
1350 | + invoice_id = obj_cancel.invoice_id |
1351 | + |
1352 | + imp_ids = obj_imputacion.search(cr, uid, [('ref','like',invoice_id.internal_number)]) |
1353 | + imp_brw = obj_imputacion.browse(cr, uid, imp_ids, context=context) |
1354 | + for imp in imp_brw: |
1355 | + amount = imp.amount * -1 |
1356 | + imp_dict = { |
1357 | + 'ref': imp.ref, |
1358 | + 'partida': imp.partida, |
1359 | + 'partida_id': imp.partida_id.id, |
1360 | + 'enlace_id': imp.enlace_id, |
1361 | + 'model': imp.model, |
1362 | + 'res_id': imp.res_id, |
1363 | + 'fecha_imp': imp.fecha_imp, |
1364 | + 'amount': amount, |
1365 | + 'periodo': imp.periodo.id, |
1366 | + 'accion_especifica_id': imp.accion_especifica_id.id, |
1367 | + 'status': imp.status, |
1368 | + 'state': imp.state, |
1369 | + 'type': imp.type, |
1370 | + 'type_create': imp.type_create, |
1371 | + 'company_id': imp.company_id.id, |
1372 | + 'checkear': imp.checkear |
1373 | + } |
1374 | + |
1375 | + obj_imputacion.create(cr, uid, imp_dict, context=context) |
1376 | + |
1377 | + |
1378 | +cancel_invoice() |
1379 | |
1380 | === added file 'anular_factura/model/herencia_retencion.py' |
1381 | --- anular_factura/model/herencia_retencion.py 1970-01-01 00:00:00 +0000 |
1382 | +++ anular_factura/model/herencia_retencion.py 2014-10-13 21:29:58 +0000 |
1383 | @@ -0,0 +1,87 @@ |
1384 | +#!/usr/bin/python |
1385 | +# -*- encoding: utf-8 -*- |
1386 | +########################################################################### |
1387 | +# Copyright (C) Industrias Diana, C.A. (www.industriasdiana.gob.ve) |
1388 | +# All Rights Reserved |
1389 | +###############Credits###################################################### |
1390 | +# Developed by: Industrias Diana, C.A. |
1391 | +############################################################################## |
1392 | + |
1393 | +from osv import fields, osv |
1394 | +import netsvc |
1395 | +import time |
1396 | +from tools.translate import _ |
1397 | + |
1398 | + |
1399 | +class account_invoice(osv.osv): |
1400 | + _inherit = 'account.invoice' |
1401 | + |
1402 | + _columns = { |
1403 | + 'cancel_invoice_id': fields.many2one('cancel.invoice', 'Cancel Invoice', readonly=True), |
1404 | + 'sisb_picking_ids': fields.many2many('stock.picking', 'hoja_carga_picking_invoice_rel', 'invoice_id', 'picking_id', 'Pickings'), |
1405 | + 'sisb_purchase_ids': fields.many2many('purchase.order', 'purchase_invoice_rel', 'invoice_id', 'purchase_id', 'Purchases'), |
1406 | + } |
1407 | + |
1408 | + |
1409 | + def action_cancel_draft(self, cr, uid, ids, *args): |
1410 | + if self.browse(cr, uid, ids)[0].cancel_invoice_id: |
1411 | + raise osv.except_osv(_('Error !'), _('La factura posee un documento de anulacion, no puede ser pasado a borrador')) |
1412 | + return False |
1413 | + else: |
1414 | + return super(account_invoice, self).action_cancel_draft(cr, uid, ids, args) |
1415 | + |
1416 | + |
1417 | +account_invoice() |
1418 | + |
1419 | + |
1420 | +class islr_wh_doc(osv.osv): |
1421 | + _inherit = "islr.wh.doc" |
1422 | + |
1423 | + def action_cancel_draft(self,cr,uid,ids, *args): |
1424 | + """ Se implementa la funcion mas no es usado por el modulo de l10n_ve_withholding_islr. |
1425 | + El workflow jamas se cambia de cancel a dratf """ |
1426 | + if self.browse(cr, uid, ids)[0].invoice_id.cancel_invoice_id: |
1427 | + raise osv.except_osv(_('Error !'), _('La retencion posee un documento de anulacion, no puede ser pasado a borrador')) |
1428 | + return False |
1429 | + else: |
1430 | + return super(islr_wh_doc, self).action_cancel_draft(cr, uid, ids, args) |
1431 | + |
1432 | +islr_wh_doc() |
1433 | + |
1434 | + |
1435 | +class account_wh_src(osv.osv): |
1436 | + _inherit = "account.wh.src" |
1437 | + |
1438 | + def action_draft(self, cr, uid, ids, context={}): |
1439 | + """ Se implementa funcion para que el workflow no se cambie de cancel a dratf |
1440 | + si pertenece a un documento de anulacion""" |
1441 | + if context is None: |
1442 | + context={} |
1443 | + brw = self.browse(cr,uid,ids[0],context) |
1444 | + inv_ids = [i.invoice_id.id for i in brw.line_ids if i.invoice_id.cancel_invoice_id] |
1445 | + if len(inv_ids) > 0: |
1446 | + return False |
1447 | + else: |
1448 | + return super(account_wh_src, self).action_draft(cr, uid, ids, context=context) |
1449 | + |
1450 | + |
1451 | +account_wh_src() |
1452 | + |
1453 | + |
1454 | +class account_wh_muni(osv.osv): |
1455 | + _inherit = "account.wh.muni" |
1456 | + |
1457 | + def action_draft(self, cr, uid, ids, context={}): |
1458 | + """ Se implementa funcion para que el workflow no se cambie de cancel a dratf |
1459 | + si pertenece a un documento de anulacion""" |
1460 | + if context is None: |
1461 | + context={} |
1462 | + brw = self.browse(cr,uid,ids[0],context) |
1463 | + inv_ids = [i.invoice_id.id for i in brw.line_ids if i.invoice_id.cancel_invoice_id] |
1464 | + if len(inv_ids) > 0: |
1465 | + return False |
1466 | + else: |
1467 | + return super(account_wh_muni, self).action_draft(cr, uid, ids, context=context) |
1468 | + |
1469 | + |
1470 | +account_wh_muni() |
1471 | |
1472 | === added directory 'anular_factura/report' |
1473 | === added file 'anular_factura/report_cancel_invoice.xml' |
1474 | --- anular_factura/report_cancel_invoice.xml 1970-01-01 00:00:00 +0000 |
1475 | +++ anular_factura/report_cancel_invoice.xml 2014-10-13 21:29:58 +0000 |
1476 | @@ -0,0 +1,8 @@ |
1477 | +<?xml version="1.0" encoding="utf-8"?> |
1478 | +<openerp> |
1479 | + <data> |
1480 | +<!-- |
1481 | + attachment="(object.state in ('confirm','done','paid','final')) and ((object.name or '')+'/'+(object.ref or '').strip()+'.pdf')" |
1482 | +--> |
1483 | + </data> |
1484 | +</openerp> |
1485 | |
1486 | === added directory 'anular_factura/secuence' |
1487 | === added file 'anular_factura/secuence/cancel_invoice_sequence.xml' |
1488 | --- anular_factura/secuence/cancel_invoice_sequence.xml 1970-01-01 00:00:00 +0000 |
1489 | +++ anular_factura/secuence/cancel_invoice_sequence.xml 2014-10-13 21:29:58 +0000 |
1490 | @@ -0,0 +1,46 @@ |
1491 | +<?xml version="1.0" encoding="utf-8"?> |
1492 | +<openerp> |
1493 | + <data noupdate="0"> |
1494 | + |
1495 | + <!-- Sequences for anular factura --> |
1496 | + |
1497 | + <record id="seq_type_ref_anular_factura" model="ir.sequence.type"> |
1498 | + <field name="name">Referencia Anular Factura</field> |
1499 | + <field name="code">anular.factura.seq</field> |
1500 | + </record> |
1501 | + |
1502 | + <record id="seq_ref_anular_factura" model="ir.sequence"> |
1503 | + <field name="name">Sequencia Anular Factura</field> |
1504 | + <field name="code">anular.factura.seq</field> |
1505 | + <field name="padding">5</field> |
1506 | + <field name="prefix">anulo/</field> |
1507 | + </record> |
1508 | + |
1509 | + <!-- |
1510 | + Journal |
1511 | + --> |
1512 | + |
1513 | + <record id="seq_type_journal_anular_factura" model="ir.sequence.type"> |
1514 | + <field name="name">Referencia Diario Anulacion</field> |
1515 | + <field name="code">journal.anular.factura.seq</field> |
1516 | + </record> |
1517 | + |
1518 | + <record id="seq_journal_anular_factura" model="ir.sequence"> |
1519 | + <field name="name">Sequencia Diario Anulacion</field> |
1520 | + <field name="code">journal.anular.factura.seq</field> |
1521 | + <field name="padding">5</field> |
1522 | + <field name="prefix">D-ANIN/</field> |
1523 | + </record> |
1524 | + |
1525 | + <record forcecreate="1" id="sisb_journal_invoice_cancel" model="account.journal"> |
1526 | + <field name="name">Diario de Anulacion Factura</field> |
1527 | + <field name="code">D-Anul</field> |
1528 | + <field name="type">general</field> |
1529 | + <field name="view_id" ref="account.account_journal_view"/> |
1530 | + <field name="sequence_id" ref="seq_journal_anular_factura"/> |
1531 | + <field name="user_id" ref="base.user_root"/> |
1532 | + <field name="allow_date">True</field> |
1533 | + </record> |
1534 | + |
1535 | + </data> |
1536 | +</openerp> |
1537 | |
1538 | === added directory 'anular_factura/security' |
1539 | === added file 'anular_factura/security/cancel_invoice_security.xml' |
1540 | --- anular_factura/security/cancel_invoice_security.xml 1970-01-01 00:00:00 +0000 |
1541 | +++ anular_factura/security/cancel_invoice_security.xml 2014-10-13 21:29:58 +0000 |
1542 | @@ -0,0 +1,37 @@ |
1543 | +<?xml version="1.0" encoding="utf-8"?> |
1544 | +<openerp> |
1545 | + <data noupdate="0"> |
1546 | + |
1547 | +<!-- |
1548 | + Grupos de Anulacion de Factura |
1549 | +--> |
1550 | + <record id="group_cancel_invoice_request" model="res.groups"> |
1551 | + <field name="name">Anular Factura / Solicitar</field> |
1552 | + </record> |
1553 | + |
1554 | + <record id="group_cancel_invoice_approve" model="res.groups"> |
1555 | + <field name="name">Anular Factura / Aprobar</field> |
1556 | + </record> |
1557 | + |
1558 | + <record id="group_cancel_invoice_ratify" model="res.groups"> |
1559 | + <field name="name">Anular Factura / Ratifica</field> |
1560 | + </record> |
1561 | + |
1562 | + <record id="group_log_cancel_invoice" model="res.groups"> |
1563 | + <field name="name">Log Anular Factura</field> |
1564 | + </record> |
1565 | + |
1566 | +<!-- |
1567 | + Menu de Anulacion de Factura |
1568 | +--> |
1569 | + |
1570 | + <record model="ir.ui.menu" id="menu_cancel_invoice"> |
1571 | + <field eval="[(4, ref('group_cancel_invoice_request'))]" name="groups_id"/> |
1572 | + </record> |
1573 | + |
1574 | +<!-- |
1575 | + Reglas de Anulacion de Factura |
1576 | +--> |
1577 | + |
1578 | + </data> |
1579 | +</openerp> |
1580 | |
1581 | === added file 'anular_factura/security/ir.model.access.csv' |
1582 | --- anular_factura/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
1583 | +++ anular_factura/security/ir.model.access.csv 2014-10-13 21:29:58 +0000 |
1584 | @@ -0,0 +1,5 @@ |
1585 | +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
1586 | +"access_cancel_invoice_request","cancel.invoice.request","model_cancel_invoice","group_cancel_invoice_request",1,1,1,0 |
1587 | +"access_log_cancel_invoice_request","log.cancel.invoice.request","model_log_cancel_invoice","group_cancel_invoice_request",1,1,1,0 |
1588 | +"access_log_cancel_invoice_approve","log.cancel.invoice.approve","model_log_cancel_invoice","group_cancel_invoice_approve",1,1,1,0 |
1589 | +"access_log_cancel_invoice_ratify","log.cancel.invoice.ratify","model_log_cancel_invoice","group_cancel_invoice_ratify",1,1,1,0 |
1590 | |
1591 | === added directory 'anular_factura/view' |
1592 | === added file 'anular_factura/view/cancel_invoice.xml' |
1593 | --- anular_factura/view/cancel_invoice.xml 1970-01-01 00:00:00 +0000 |
1594 | +++ anular_factura/view/cancel_invoice.xml 2014-10-13 21:29:58 +0000 |
1595 | @@ -0,0 +1,142 @@ |
1596 | +<?xml version="1.0" encoding="utf-8"?> |
1597 | +<openerp> |
1598 | + <data> |
1599 | + |
1600 | +<!-- |
1601 | + Vistas de anulacion de factura |
1602 | +--> |
1603 | + |
1604 | + <record id="view_cancel_invoice_filter" model="ir.ui.view"> |
1605 | + <field name="name">Cancel Invoice Search</field> |
1606 | + <field name="model">cancel.invoice</field> |
1607 | + <field name="type">search</field> |
1608 | + <field name="priority">1</field> |
1609 | + <field name="arch" type="xml"> |
1610 | + <search string="Search Log"> |
1611 | + <group col='8' colspan='4'> |
1612 | + <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Solicitudes de Anulacion"/> |
1613 | + <filter icon="gtk-find-and-replace" string="Approved" domain="[('state','=','approved')]" help="Anulaciones Aprobadas"/> |
1614 | + <filter icon="gtk-paste" string="Ratify" domain="[('state','=','ratify')]" help="Anulaciones Ratificadas"/> |
1615 | + <filter icon="gtk-index" string="Done" domain="[('state','=','done')]" help="Anulaciones Ejecutadas"/> |
1616 | + <separator orientation="vertical"/> |
1617 | + <field name="invoice_id"/> |
1618 | + <field name="partner_id"/> |
1619 | + <field name="period_id"/> |
1620 | + <field name="date"/> |
1621 | + </group> |
1622 | + <newline/> |
1623 | + <group expand="0" string="Group By..." colspan="4" col="10" groups="base.group_multi_company"> |
1624 | + <filter string="Company" icon="terp-partner" domain="[]" context="{'group_by':'company_id'}"/> |
1625 | + </group> |
1626 | + </search> |
1627 | + </field> |
1628 | + </record> |
1629 | + |
1630 | + <record model="ir.ui.view" id="view_cancel_invoice_tree"> |
1631 | + <field name="name">Cancel Invoice Tree</field> |
1632 | + <field name="model">cancel.invoice</field> |
1633 | + <field name="type">tree</field> |
1634 | + <field name="arch" type="xml"> |
1635 | + <tree string="Cancel Invoice"> |
1636 | + <field name="name"/> |
1637 | + <field name="partner_id"/> |
1638 | + <field name="period_id"/> |
1639 | + <field name="invoice_id"/> |
1640 | + <field name="date"/> |
1641 | + <field name="state"/> |
1642 | + <field name='company_id' groups="base.group_multi_company"/> |
1643 | + </tree> |
1644 | + </field> |
1645 | + </record> |
1646 | + |
1647 | + <record model="ir.ui.view" id="view_cancel_invoice_form"> |
1648 | + <field name="name">Cancel Invoice Form</field> |
1649 | + <field name="model">cancel.invoice</field> |
1650 | + <field name="type">form</field> |
1651 | + <field name="arch" type="xml"> |
1652 | + <form string="Cancel Invoice"> |
1653 | + <group col='8' colspan='4'> |
1654 | + <field name="name" readonly='True'/> |
1655 | + <field name="partner_id" attrs="{'readonly':[('state','!=','draft')]}"/> |
1656 | + <field name="period_id" readonly='True' domain="[('state','<>','done')]"/> |
1657 | +<!-- |
1658 | + <field name="period_id" domain="[('state','<>','done')]"/> |
1659 | +--> |
1660 | + <field name="date" readonly='True'/> |
1661 | + <field name="invoice_id" domain="[('type','=','in_invoice'),('period_id','=',period_id),('partner_id','=',partner_id),('state','=','open'),('parent_id','=',False)]" attrs="{'readonly':[('state','!=','draft')]}"/> |
1662 | + <field name="reference"/> |
1663 | + <field name="date_invoice"/> |
1664 | + <field name="date_document_invoice"/> |
1665 | + <field name='company_id' groups="base.group_multi_company" attrs="{'readonly':[('state','!=','draft')]}"/> |
1666 | + </group> |
1667 | + <notebook colspan="4"> |
1668 | + <page string="Reason for the cancellation"> |
1669 | +<!-- |
1670 | + <label colspan="4" nolabel="1" string=""/> |
1671 | +--> |
1672 | + <field name="reason" widget="text" nolabel="1" attrs="{'readonly':[('state','!=','draft')]}"/> |
1673 | + </page> |
1674 | + <page string="Journal Entry Canceled"> |
1675 | + <group col='2' colspan='2'> |
1676 | + <field name="move_id" readonly="True"/> |
1677 | + </group> |
1678 | + <newline/> |
1679 | + <group col='1' colspan='1'> |
1680 | + <field name="move_cancel_ids" nolabel="1" readonly="True"/> |
1681 | + </group> |
1682 | + </page> |
1683 | + <page string="Log Cancel Invoice"> |
1684 | + <group col='1' colspan='1'> |
1685 | +<!-- |
1686 | + <field name="log_lines" nolabel="1" readonly="True"/> |
1687 | +--> |
1688 | + <field name="log_lines" nolabel="1"> |
1689 | + <tree string="Log Cancel Invoice"> |
1690 | + <field name="date_create"/> |
1691 | + <field name="user_id"/> |
1692 | + <field name="name"/> |
1693 | + <field name='company_id' groups="base.group_multi_company"/> |
1694 | + </tree> |
1695 | + </field> |
1696 | + </group> |
1697 | + </page> |
1698 | + </notebook> |
1699 | + <group col='10' colspan='4'> |
1700 | +<!-- |
1701 | + <separator orientation="vertical" colspan="3"/> |
1702 | +--> |
1703 | + <group colspan="2" col="8"> |
1704 | + </group> |
1705 | + <button name="validar_factura" colspan="2" states="draft,approved,ratified" string="Check" type="object" icon="gtk-find"/> |
1706 | + <button name="aprobar_cancelacion" colspan="2" states="draft" string="Approve" type="object" icon="gtk-convert" groups="anular_factura.group_cancel_invoice_approve"/> |
1707 | + <button name="ratificar_cancelacion" colspan="2" states="approved" string="Ratify" type="object" icon="gtk-apply" groups="anular_factura.group_cancel_invoice_ratify"/> |
1708 | + <button name="ejecutar_cancelacion" colspan="2" states="ratified" string="Execute" type="object" icon="gtk-execute" groups="anular_factura.group_cancel_invoice_ratify"/> |
1709 | + </group> |
1710 | + <group col='6' colspan='4'> |
1711 | + <field name="user_request"/> |
1712 | + <field name="user_approve"/> |
1713 | + <field name="user_ratify"/> |
1714 | + <field name="state"/> |
1715 | + </group> |
1716 | + </form> |
1717 | + </field> |
1718 | + </record> |
1719 | + |
1720 | + <record model='ir.actions.act_window' id='action_cancel_invoice_act_window'> |
1721 | + <field name='name'>Cancel Invoice</field> |
1722 | + <field name='res_model'>cancel.invoice</field> |
1723 | + <field name='view_type'>form</field> |
1724 | + <field name='view_mode'>tree,form</field> |
1725 | + <field name="view_id" eval="view_cancel_invoice_tree"/> |
1726 | + <field name="search_view_id" ref="view_cancel_invoice_filter"/> |
1727 | + </record> |
1728 | + |
1729 | +<!-- |
1730 | + <menuitem id="menu_cancel_invoice" name="Cancel Invoice" parent="account.menu_finance_periodical_processing" sequence="1"/> |
1731 | +--> |
1732 | + |
1733 | + <menuitem id="menu_cancel_invoice" name="Cancel Invoice" parent="account.menu_finance_periodical_processing" sequence="99" |
1734 | + action="action_cancel_invoice_act_window"/> |
1735 | + |
1736 | + </data> |
1737 | +</openerp> |
1738 | |
1739 | === added file 'anular_factura/view/log_cancel_invoice.xml' |
1740 | --- anular_factura/view/log_cancel_invoice.xml 1970-01-01 00:00:00 +0000 |
1741 | +++ anular_factura/view/log_cancel_invoice.xml 2014-10-13 21:29:58 +0000 |
1742 | @@ -0,0 +1,77 @@ |
1743 | +<?xml version="1.0" encoding="utf-8"?> |
1744 | +<openerp> |
1745 | + <data> |
1746 | + |
1747 | +<!-- |
1748 | + Vistas del log de anulacion de factura |
1749 | +--> |
1750 | + |
1751 | + <record id="view_log_cancel_invoice_filter" model="ir.ui.view"> |
1752 | + <field name="name">Log Cancel Invoice Search</field> |
1753 | + <field name="model">log.cancel.invoice</field> |
1754 | + <field name="type">search</field> |
1755 | + <field name="priority">1</field> |
1756 | + <field name="arch" type="xml"> |
1757 | + <search string="Search Log"> |
1758 | + <group col='8' colspan='4'> |
1759 | + <field name="name"/> |
1760 | + <field name="user_id"/> |
1761 | + <field name="date_create"/> |
1762 | + <field name="res_model"/> |
1763 | + </group> |
1764 | + <newline/> |
1765 | + <group expand="0" string="Group By..." colspan="4" col="10" groups="base.group_multi_company"> |
1766 | + <filter string="Company" icon="terp-partner" domain="[]" context="{'group_by':'company_id'}"/> |
1767 | + </group> |
1768 | + </search> |
1769 | + </field> |
1770 | + </record> |
1771 | + |
1772 | + <record model="ir.ui.view" id="view_log_cancel_invoice_tree"> |
1773 | + <field name="name">Log Cancel Invoice Tree</field> |
1774 | + <field name="model">log.cancel.invoice</field> |
1775 | + <field name="type">tree</field> |
1776 | + <field name="arch" type="xml"> |
1777 | + <tree string="Log Cancel Invoice"> |
1778 | + <field name="date_create"/> |
1779 | + <field name="user_id"/> |
1780 | + <field name="name"/> |
1781 | + <field name="res_model"/> |
1782 | + <field name="res_id"/> |
1783 | + <field name='company_id' groups="base.group_multi_company"/> |
1784 | + </tree> |
1785 | + </field> |
1786 | + </record> |
1787 | + |
1788 | + <record model="ir.ui.view" id="view_log_cancel_invoice_form"> |
1789 | + <field name="name">Log Cancel Invoice Form</field> |
1790 | + <field name="model">log.cancel.invoice</field> |
1791 | + <field name="type">form</field> |
1792 | + <field name="arch" type="xml"> |
1793 | + <form string="Log Cancel Invoice"> |
1794 | + <group col='6' colspan='4'> |
1795 | + <field name="name"/> |
1796 | + <field name="date_create"/> |
1797 | + <field name="user_id"/> |
1798 | + <field name="res_model"/> |
1799 | + <field name="res_id"/> |
1800 | + <field name='company_id' groups="base.group_multi_company"/> |
1801 | + </group> |
1802 | + </form> |
1803 | + </field> |
1804 | + </record> |
1805 | + |
1806 | + <record model='ir.actions.act_window' id='action_log_cancel_invoice_act_window'> |
1807 | + <field name='name'>Log Cancel Invoice</field> |
1808 | + <field name='res_model'>log.cancel.invoice</field> |
1809 | + <field name='view_type'>form</field> |
1810 | + <field name='view_mode'>tree,form</field> |
1811 | + <field name="view_id" eval="view_log_cancel_invoice_tree"/> |
1812 | + <field name="search_view_id" ref="view_log_cancel_invoice_filter"/> |
1813 | + </record> |
1814 | + |
1815 | + <menuitem id="menu_log_cancel_invoice" name="Log Cancel Invoice" parent="base.menu_audit" sequence="99" |
1816 | + action="action_log_cancel_invoice_act_window"/> |
1817 | + |
1818 | + </data> |
1819 | +</openerp> |
1820 | |
1821 | === added directory 'anular_factura/wizard' |
1822 | === added directory 'anular_factura/workflow' |
1823 | === added file 'anular_factura/workflow/invoice_wh_workflow.xml' |
1824 | --- anular_factura/workflow/invoice_wh_workflow.xml 1970-01-01 00:00:00 +0000 |
1825 | +++ anular_factura/workflow/invoice_wh_workflow.xml 2014-10-13 21:29:58 +0000 |
1826 | @@ -0,0 +1,100 @@ |
1827 | +<?xml version="1.0" encoding="utf-8"?> |
1828 | +<openerp> |
1829 | + <data> |
1830 | + #---------------------------------------------- |
1831 | + # Activity |
1832 | + #---------------------------------------------- |
1833 | + |
1834 | + # Factura |
1835 | + <record id="anular_factura_invoice" model="workflow.activity"> |
1836 | + <field name="wkf_id" ref="account.wkf"/> |
1837 | + <field name="name">anular</field> |
1838 | + <field name="action">write({'state':'cancel'})</field> |
1839 | + <field name="kind">function</field> |
1840 | + <field name="flow_stop">True</field> |
1841 | + </record> |
1842 | + |
1843 | + # Impuestos sobre la renta |
1844 | + <record id="anular_factura_islr" model="workflow.activity"> |
1845 | + <field name="wkf_id" ref="l10n_ve_withholding_islr.wh_islr_order"/> |
1846 | + <field name="action">write({'state':'cancel'})</field> |
1847 | + <field name="kind">function</field> |
1848 | + <field name="name">anular</field> |
1849 | + <field name="flow_stop">True</field> |
1850 | + </record> |
1851 | + |
1852 | + # Impuestos al valor agregado |
1853 | + <record id="anular_factura_iva" model="workflow.activity"> |
1854 | + <field name="wkf_id" ref="l10n_ve_withholding_iva.wh_iva_order"/> |
1855 | + <field name="action">write({'state':'cancel'})</field> |
1856 | + <field name="kind">function</field> |
1857 | + <field name="name">anular</field> |
1858 | + <field name="flow_stop">True</field> |
1859 | + </record> |
1860 | + |
1861 | + # Impuestos municipales |
1862 | + <record id="anular_factura_muni" model="workflow.activity"> |
1863 | + <field name="wkf_id" ref="l10n_ve_withholding_muni.wh_muni_wkf"/> |
1864 | + <field name="action">write({'state':'cancel'})</field> |
1865 | + <field name="kind">function</field> |
1866 | + <field name="name">anular</field> |
1867 | + <field name="flow_stop">True</field> |
1868 | + </record> |
1869 | + |
1870 | + # Impuestos de responsabilidad social |
1871 | + <record id="anular_factura_src" model="workflow.activity"> |
1872 | + <field name="wkf_id" ref="l10n_ve_withholding_src.wh_src_wkf"/> |
1873 | + <field name="action">write({'state':'cancel'})</field> |
1874 | + <field name="kind">function</field> |
1875 | + <field name="name">anular</field> |
1876 | + <field name="flow_stop">True</field> |
1877 | + </record> |
1878 | + |
1879 | + |
1880 | + #---------------------------------------------- |
1881 | + # Transitions |
1882 | + #---------------------------------------------- |
1883 | + |
1884 | + # Factura |
1885 | + <record id="invoice_draft_anular_cancel" model="workflow.transition"> |
1886 | + <field name="act_from" ref="account.act_draft"/> |
1887 | + <field name="act_to" ref="anular_factura_invoice"/> |
1888 | + <field name="signal">anular_factura</field> |
1889 | + <field name="condition">True</field> |
1890 | + </record> |
1891 | + |
1892 | + # Impuestos sobre la renta |
1893 | + <record id="islr_draft_anular_cancel" model="workflow.transition"> |
1894 | + <field name="act_from" ref="l10n_ve_withholding_islr.act_draft"/> |
1895 | + <field name="act_to" ref="anular_factura_islr"/> |
1896 | + <field name="signal">anular_factura</field> |
1897 | + <field name="condition">True</field> |
1898 | + </record> |
1899 | + |
1900 | + # Impuestos al valor agregado |
1901 | + <record id="iva_draft_anular_cancel" model="workflow.transition"> |
1902 | + <field name="act_from" ref="l10n_ve_withholding_iva.act_draft"/> |
1903 | + <field name="act_to" ref="anular_factura_iva"/> |
1904 | + <field name="signal">anular_factura</field> |
1905 | + <field name="condition">True</field> |
1906 | + </record> |
1907 | + |
1908 | + # Impuestos municipales |
1909 | + <record id="muni_draft_anular_cancel" model="workflow.transition"> |
1910 | + <field name="act_from" ref="l10n_ve_withholding_muni.act_draft"/> |
1911 | + <field name="act_to" ref="anular_factura_muni"/> |
1912 | + <field name="signal">anular_factura</field> |
1913 | + <field name="condition">True</field> |
1914 | + </record> |
1915 | + |
1916 | + # Impuestos de responsabilidad social |
1917 | + <record id="src_draft_anular_cancel" model="workflow.transition"> |
1918 | + <field name="act_from" ref="l10n_ve_withholding_src.act_draft"/> |
1919 | + <field name="act_to" ref="anular_factura_src"/> |
1920 | + <field name="signal">anular_factura</field> |
1921 | + <field name="condition">True</field> |
1922 | + </record> |
1923 | + |
1924 | + |
1925 | + </data> |
1926 | +</openerp> |