Merge lp:~vauxoo/openerp-mexico-localization/7.0-l10n_mx_ir_attachment_facturae-savepoint-dev_carlos into lp:openerp-mexico-localization/7.0
- 7.0-l10n_mx_ir_attachment_facturae-savepoint-dev_carlos
- Merge into 7.0
Status: | Needs review |
---|---|
Proposed branch: | lp:~vauxoo/openerp-mexico-localization/7.0-l10n_mx_ir_attachment_facturae-savepoint-dev_carlos |
Merge into: | lp:openerp-mexico-localization/7.0 |
Diff against target: |
920 lines (+369/-369) 5 files modified
l10n_mx_facturae_pac_sf/demo/l10n_mx_facturae_seq_demo.xml (+1/-0) l10n_mx_facturae_pac_sf/ir_attachment_facturae.py (+3/-1) l10n_mx_ir_attachment_facturae/invoice.py (+11/-5) l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py (+353/-363) l10n_mx_ir_attachment_facturae/ir_attachment_facturae_view.xml (+1/-0) |
To merge this branch: | bzr merge lp:~vauxoo/openerp-mexico-localization/7.0-l10n_mx_ir_attachment_facturae-savepoint-dev_carlos |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juan Carlos Hernandez (community) | Needs Resubmitting | ||
Jorge Angel Naranjo Rogel - http://www.vauxoo.com | Needs Resubmitting | ||
Moisés López - http://www.vauxoo.com | Pending | ||
Review via email: mp+201489@code.launchpad.net |
Commit message
The following is made:
Try except for the particular functions (confirm, sign, printable, sent_customer, backup and done) were deleted
Savepoint was added to the global function called "create_
This was done to correct the cancellation from both models (account.invoice and "ir.attachment.
from the bill and from the attachment, including any state already is in the attached invoice and also to check that no error RunBot is for this reason that I did with the save point and try except is removed.
Description of the change
Se quitaron los try except de las funciones particulares(
Se agregó savepoint a cada función particular llamada por la función global llamada "create_
También se corrigió la cancelación desde ambos modelos (account.invoice y "ir.attachment.
- 348. By Launchpad Translations on behalf of openerp-mexico-maintainer
-
Launchpad automatic translations update.
Jorge Angel Naranjo Rogel - http://www.vauxoo.com (jorge-nr) wrote : | # |
Moisés López - http://www.vauxoo.com (moylop260) wrote : | # |
La puedes mezclar pero en trunk por favor
El ene 14, 2014 4:39 PM, "Jorge Angel Naranjo Rogel" <email address hidden>
escribió:
> Review: Resubmit
>
> @Moy
>
> Ya revise esta propuesta de merge funcionalmente. Falta en cuestiones
> técnicas no se si tu le puedas dar una revisada para proceder con su mergeo.
> --
>
> https:/
> You are requested to review the proposed merge of
> lp:~vauxoo/openerp-mexico-localization/7.0-l10n_mx_ir_attachment_facturae-savepoint-dev_carlos
> into lp:openerp-mexico-localization/7.0.
>
Juan Carlos Hernandez (openerp1) wrote : | # |
@Moy
Esta propuesta ya la revisó jorge y yo también. Por favor le podrias dar una revisada para proceder con su mergeo.
- 349. By Juan Carlos Hernandez
-
[MERGE]add savepoint for attachment
- 350. By Juan Carlos Hernandez
-
[MERGE]
Unmerged revisions
- 350. By Juan Carlos Hernandez
-
[MERGE]
- 349. By Juan Carlos Hernandez
-
[MERGE]add savepoint for attachment
Preview Diff
1 | === modified file 'l10n_mx_facturae_pac_sf/demo/l10n_mx_facturae_seq_demo.xml' |
2 | --- l10n_mx_facturae_pac_sf/demo/l10n_mx_facturae_seq_demo.xml 2013-08-25 01:09:20 +0000 |
3 | +++ l10n_mx_facturae_pac_sf/demo/l10n_mx_facturae_seq_demo.xml 2014-08-28 21:29:50 +0000 |
4 | @@ -28,6 +28,7 @@ |
5 | <field name="name">MX CFDI SF Journal</field> |
6 | <field name="code">CFDI</field> |
7 | <field name="type">sale</field> |
8 | + <field name="update_posted">1</field> |
9 | </record> |
10 | </data> |
11 | </openerp> |
12 | |
13 | === modified file 'l10n_mx_facturae_pac_sf/ir_attachment_facturae.py' |
14 | --- l10n_mx_facturae_pac_sf/ir_attachment_facturae.py 2013-12-10 01:11:31 +0000 |
15 | +++ l10n_mx_facturae_pac_sf/ir_attachment_facturae.py 2014-08-28 21:29:50 +0000 |
16 | @@ -192,6 +192,7 @@ |
17 | file = False |
18 | msg = '' |
19 | cfdi_xml = False |
20 | + status = False |
21 | pac_params_ids = pac_params_obj.search(cr, uid, [ |
22 | ('method_type', '=', 'pac_sf_firmar'), ( |
23 | 'company_id', '=', invoice.company_emitter_id.id), ( |
24 | @@ -293,6 +294,7 @@ |
25 | if cfdi_xml: |
26 | invoice_obj.write(cr, uid, [invoice.id], cfdi_data) |
27 | cfdi_data['cfdi_xml'] = cfdi_xml |
28 | + status = True |
29 | else: |
30 | msg += _(u"Can't extract the file XML of PAC") |
31 | else: |
32 | @@ -302,6 +304,6 @@ |
33 | msg += 'Not found information from web services of PAC, verify that the configuration of PAC is correct' |
34 | raise osv.except_osv(_('Warning'), _( |
35 | 'Not found information from web services of PAC, verify that the configuration of PAC is correct')) |
36 | - return {'file': file, 'msg': msg, 'cfdi_xml': cfdi_xml} |
37 | + return {'file': file, 'msg': msg, 'cfdi_xml': cfdi_xml, 'status': status} |
38 | |
39 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
40 | |
41 | === modified file 'l10n_mx_ir_attachment_facturae/invoice.py' |
42 | --- l10n_mx_ir_attachment_facturae/invoice.py 2013-11-07 01:13:05 +0000 |
43 | +++ l10n_mx_ir_attachment_facturae/invoice.py 2014-08-28 21:29:50 +0000 |
44 | @@ -34,6 +34,7 @@ |
45 | def action_cancel(self, cr, uid, ids, context=None): |
46 | if context is None: |
47 | context = {} |
48 | + res = False |
49 | ids = isinstance(ids, (int, long)) and [ids] or ids |
50 | ir_attach_facturae_mx_obj = self.pool.get('ir.attachment.facturae.mx') |
51 | inv_type_facturae = { |
52 | @@ -45,11 +46,16 @@ |
53 | if inv_type_facturae.get(inv.type, False): |
54 | ir_attach_facturae_mx_ids = ir_attach_facturae_mx_obj.search( |
55 | cr, uid, [('invoice_id', '=', inv.id)], context=context) |
56 | - for attach in ir_attach_facturae_mx_obj.browse(cr, uid, ir_attach_facturae_mx_ids, context=context): |
57 | - if attach.state <> 'cancel': |
58 | - ir_attach_facturae_mx_obj.signal_cancel(cr, uid, [attach.id], context=context) |
59 | - res = super(account_invoice, self).action_cancel(cr, uid, ids, context=context) |
60 | - self.write(cr, uid, ids, {'date_invoice_cancel': time.strftime('%Y-%m-%d %H:%M:%S')}) |
61 | + if ir_attach_facturae_mx_ids: |
62 | + for attach in ir_attach_facturae_mx_obj.browse(cr, uid, ir_attach_facturae_mx_ids, context=context): |
63 | + if attach.state <> 'cancel': |
64 | + res = super(account_invoice, self).action_cancel(cr, uid, ids, context=context) |
65 | + if res: |
66 | + attach = ir_attach_facturae_mx_obj.signal_cancel(cr, uid, [attach.id], context=context) |
67 | + if attach: |
68 | + self.write(cr, uid, ids, {'date_invoice_cancel': time.strftime('%Y-%m-%d %H:%M:%S')}) |
69 | + else: |
70 | + res = super(account_invoice, self).action_cancel(cr, uid, ids, context=context) |
71 | return res |
72 | |
73 | def create_ir_attachment_facturae(self, cr, uid, ids, context=None): |
74 | |
75 | === modified file 'l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py' |
76 | --- l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py 2013-12-19 00:40:37 +0000 |
77 | +++ l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py 2014-08-28 21:29:50 +0000 |
78 | @@ -34,7 +34,8 @@ |
79 | _logger = logging.getLogger(__name__) |
80 | import traceback |
81 | import sys |
82 | - |
83 | +from xml.dom import minidom |
84 | +import xml.dom.minidom |
85 | |
86 | class ir_attachment_facturae_mx(osv.Model): |
87 | _name = 'ir.attachment.facturae.mx' |
88 | @@ -104,19 +105,33 @@ |
89 | def create_ir_attachment_facturae(self, cr, uid, ids, context=None): |
90 | if context is None: |
91 | context = {} |
92 | - if not self.signal_confirm(cr, uid, ids, context=context): |
93 | - return False |
94 | - if not self.signal_sign(cr, uid, ids, context=context): |
95 | - return False |
96 | - if not self.signal_printable(cr, uid, ids, context=context): |
97 | - return False |
98 | - if not self.signal_send_customer(cr, uid, ids, context=context): |
99 | - return False |
100 | - if not self.signal_send_backup(cr, uid, ids, context=context): |
101 | - return False |
102 | - if not self.signal_done(cr, uid, ids, context=context): |
103 | - return False |
104 | - return True |
105 | + status = False |
106 | + try: |
107 | + cr.execute("SAVEPOINT ir_attachment_facturae_mx_savepoint") |
108 | + status = self.signal_confirm(cr, uid, ids, context=context) |
109 | + cr.execute("RELEASE SAVEPOINT ir_attachment_facturae_mx_savepoint") |
110 | + cr.execute("SAVEPOINT ir_attachment_facturae_mx_savepoint") |
111 | + self.signal_sign(cr, uid, ids, context=context) |
112 | + cr.execute("RELEASE SAVEPOINT ir_attachment_facturae_mx_savepoint") |
113 | + cr.execute("SAVEPOINT ir_attachment_facturae_mx_savepoint") |
114 | + self.signal_printable(cr, uid, ids, context=context) |
115 | + cr.execute("RELEASE SAVEPOINT ir_attachment_facturae_mx_savepoint") |
116 | + cr.execute("SAVEPOINT ir_attachment_facturae_mx_savepoint") |
117 | + self.signal_send_customer(cr, uid, ids, context=context) |
118 | + cr.execute("RELEASE SAVEPOINT ir_attachment_facturae_mx_savepoint") |
119 | + cr.execute("SAVEPOINT ir_attachment_facturae_mx_savepoint") |
120 | + self.signal_send_backup(cr, uid, ids, context=context) |
121 | + cr.execute("RELEASE SAVEPOINT ir_attachment_facturae_mx_savepoint") |
122 | + cr.execute("SAVEPOINT ir_attachment_facturae_mx_savepoint") |
123 | + self.signal_done(cr, uid, ids, context=context) |
124 | + cr.execute("RELEASE SAVEPOINT ir_attachment_facturae_mx_savepoint") |
125 | + status = True |
126 | + except Exception, e: |
127 | + cr.execute("ROLLBACK TO SAVEPOINT ir_attachment_facturae_mx_savepoint") |
128 | + error = tools.ustr(traceback.format_exc()) |
129 | + self.write(cr, uid, ids, {'msj': error}, context=context) |
130 | + _logger.error(error) |
131 | + return status |
132 | |
133 | def signal_confirm(self, cr, uid, ids, context=None): |
134 | if context is None: |
135 | @@ -125,70 +140,63 @@ |
136 | msj, app_xsltproc_fullpath, app_openssl_fullpath, app_xmlstarlet_fullpath = facturae_lib.library_openssl_xsltproc_xmlstarlet(cr, uid, ids, context) |
137 | if msj: |
138 | raise osv.except_osv(_('Warning'),_(msj)) |
139 | - try: |
140 | - if context is None: |
141 | - context = {} |
142 | - ids = isinstance(ids, (int, long)) and [ids] or ids |
143 | - invoice_obj = self.pool.get('account.invoice') |
144 | - attach = '' |
145 | - msj = '' |
146 | - index_xml = '' |
147 | - attach = self.browse(cr, uid, ids[0]) |
148 | - invoice = attach.invoice_id |
149 | - type = attach.type |
150 | - wf_service = netsvc.LocalService("workflow") |
151 | - save_attach = None |
152 | - if 'cbb' in type: |
153 | - msj = _("Confirmed") |
154 | - save_attach = False |
155 | - elif 'cfdi' in type: |
156 | - fname_invoice = invoice.fname_invoice and invoice.fname_invoice + \ |
157 | - '_V3_2.xml' or '' |
158 | - fname, xml_data = invoice_obj._get_facturae_invoice_xml_data( |
159 | - cr, uid, [invoice.id], context=context) |
160 | - attach = self.pool.get('ir.attachment').create(cr, uid, { |
161 | - 'name': fname_invoice, |
162 | - 'datas': base64.encodestring(xml_data), |
163 | - 'datas_fname': fname_invoice, |
164 | - 'res_model': 'account.invoice', |
165 | - 'res_id': invoice.id, |
166 | - }, context=None) |
167 | - msj = _("Attached Successfully XML CFDI 3.2\n") |
168 | - save_attach = True |
169 | - elif 'cfd' in type and not 'cfdi' in type: |
170 | - fname_invoice = invoice.fname_invoice and invoice.fname_invoice + \ |
171 | - '.xml' or '' |
172 | - fname, xml_data = invoice_obj._get_facturae_invoice_xml_data( |
173 | - cr, uid, [invoice.id], context=context) |
174 | - attach = self.pool.get('ir.attachment').create(cr, uid, { |
175 | - 'name': fname_invoice, |
176 | - 'datas': base64.encodestring(xml_data), |
177 | - 'datas_fname': fname_invoice, |
178 | - 'res_model': 'account.invoice', |
179 | - 'res_id': invoice.id, |
180 | - }, context=None) |
181 | - if attach: |
182 | - index_xml = self.pool.get('ir.attachment').browse( |
183 | - cr, uid, attach).index_content |
184 | - msj = _("Attached Successfully XML CFD 2.2") |
185 | - save_attach = True |
186 | - else: |
187 | - raise osv.except_osv(_("Type Electronic Invoice Unknow!"), _( |
188 | - "The Type Electronic Invoice:" + (type or ''))) |
189 | - if save_attach: |
190 | - self.write(cr, uid, ids, |
191 | - {'file_input': attach or False, |
192 | - 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), |
193 | - 'msj': msj, |
194 | - 'file_xml_sign_index': index_xml}, context=context) |
195 | - wf_service.trg_validate( |
196 | - uid, self._name, ids[0], 'action_confirm', cr) |
197 | - return True |
198 | - except Exception, e: |
199 | - error = tools.ustr(traceback.format_exc()) |
200 | - self.write(cr, uid, ids, {'msj': error}, context=context) |
201 | - _logger.error(error) |
202 | - return False |
203 | + if context is None: |
204 | + context = {} |
205 | + ids = isinstance(ids, (int, long)) and [ids] or ids |
206 | + invoice_obj = self.pool.get('account.invoice') |
207 | + attachment_obj = self.pool.get('ir.attachment') |
208 | + attach = '' |
209 | + msj = '' |
210 | + index_xml = '' |
211 | + attach = self.browse(cr, uid, ids[0]) |
212 | + invoice = attach.invoice_id |
213 | + type = attach.type |
214 | + wf_service = netsvc.LocalService("workflow") |
215 | + status = False |
216 | + if 'cbb' in type: |
217 | + msj = _("Confirmed") |
218 | + status = False |
219 | + elif 'cfdi' in type: |
220 | + fname_invoice = invoice.fname_invoice and invoice.fname_invoice + \ |
221 | + '_V3_2.xml' or '' |
222 | + fname, xml_data = invoice_obj._get_facturae_invoice_xml_data( |
223 | + cr, uid, [invoice.id], context=context) |
224 | + attach = attachment_obj.create(cr, uid, { |
225 | + 'name': fname_invoice, |
226 | + 'datas': base64.encodestring(xml_data), |
227 | + 'datas_fname': fname_invoice, |
228 | + 'res_model': 'account.invoice', |
229 | + 'res_id': invoice.id, |
230 | + }, context=None) |
231 | + msj = _("Attached Successfully XML CFDI 3.2\n") |
232 | + status = True |
233 | + elif 'cfd' in type and not 'cfdi' in type: |
234 | + fname_invoice = invoice.fname_invoice and invoice.fname_invoice + '.xml' or '' |
235 | + fname, xml_data = invoice_obj._get_facturae_invoice_xml_data( |
236 | + cr, uid, [invoice.id], context=context) |
237 | + attach = attachment_obj.create(cr, uid, { |
238 | + 'name': fname_invoice, |
239 | + 'datas': base64.encodestring(xml_data), |
240 | + 'datas_fname': fname_invoice, |
241 | + 'res_model': 'account.invoice', |
242 | + 'res_id': invoice.id, |
243 | + }, context=None) |
244 | + if attach: |
245 | + msj = _("Attached Successfully XML CFD 2.2") |
246 | + status = True |
247 | + else: |
248 | + raise osv.except_osv(_("Type Electronic Invoice Unknow!"), _( |
249 | + "The Type Electronic Invoice:" + (type or ''))) |
250 | + if status: |
251 | + doc_xml = xml.dom.minidom.parseString(xml_data) |
252 | + index_xml = doc_xml.toprettyxml() |
253 | + self.write(cr, uid, ids, |
254 | + {'file_input': attach or False, |
255 | + 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), |
256 | + 'msj': msj, |
257 | + 'file_input_index': index_xml}, context=context) |
258 | + wf_service.trg_validate(uid, self._name, ids[0], 'action_confirm', cr) |
259 | + return status |
260 | |
261 | def action_confirm(self, cr, uid, ids, context=None): |
262 | if context is None: |
263 | @@ -197,38 +205,40 @@ |
264 | return self.write(cr, uid, ids, {'state': 'confirmed'}, context=context) |
265 | |
266 | def signal_sign(self, cr, uid, ids, context=None): |
267 | - try: |
268 | - if context is None: |
269 | - context = {} |
270 | - ids = isinstance(ids, (int, long)) and [ids] or ids |
271 | - invoice_obj = self.pool.get('account.invoice') |
272 | - attachment_obj = self.pool.get('ir.attachment') |
273 | - attach = '' |
274 | - index_xml = '' |
275 | - msj = '' |
276 | - for data in self.browse(cr, uid, ids, context=context): |
277 | - invoice = data.invoice_id |
278 | - type = data.type |
279 | - wf_service = netsvc.LocalService("workflow") |
280 | - attach_v3_2 = data.file_input and data.file_input.id or False |
281 | - if 'cbb' in type: |
282 | - msj = _("Signed") |
283 | - if 'cfd' in type and not 'cfdi' in type: |
284 | - attach = data.file_input and data.file_input.id or False |
285 | - index_xml = data.file_xml_sign_index or False |
286 | - msj = _("Attached Successfully XML CFD 2.2\n") |
287 | - if 'cfdi' in type: |
288 | - # upload file in custom module for pac |
289 | - type__fc = self.get_driver_fc_sign() |
290 | - if type in type__fc.keys(): |
291 | - fname_invoice = invoice.fname_invoice and invoice.fname_invoice + \ |
292 | - '.xml' or '' |
293 | - fname, xml_data = invoice_obj._get_facturae_invoice_xml_data( |
294 | - cr, uid, [invoice.id], context=context) |
295 | - fdata = base64.encodestring(xml_data) |
296 | - res = type__fc[type](cr, uid, [data.id], fdata, context=context) |
297 | - msj = tools.ustr(res.get('msg', False)) |
298 | - index_xml = res.get('cfdi_xml', False) |
299 | + if context is None: |
300 | + context = {} |
301 | + ids = isinstance(ids, (int, long)) and [ids] or ids |
302 | + invoice_obj = self.pool.get('account.invoice') |
303 | + attachment_obj = self.pool.get('ir.attachment') |
304 | + attach = '' |
305 | + index_xml = '' |
306 | + msj = '' |
307 | + status = False |
308 | + for data in self.browse(cr, uid, ids, context=context): |
309 | + invoice = data.invoice_id |
310 | + type = data.type |
311 | + wf_service = netsvc.LocalService("workflow") |
312 | + attach_v3_2 = data.file_input and data.file_input.id or False |
313 | + index_content = data.file_input and data.file_input.index_content.encode('utf-8') or False |
314 | + if 'cbb' in type: |
315 | + msj = _("Signed") |
316 | + status = True |
317 | + if 'cfd' in type and not 'cfdi' in type: |
318 | + attach = data.file_input and data.file_input.id or False |
319 | + msj = _("Attached Successfully XML CFD 2.2\n") |
320 | + index_xml = index_content |
321 | + status = True |
322 | + if 'cfdi' in type: |
323 | + # upload file in custom module for pac |
324 | + type__fc = self.get_driver_fc_sign() |
325 | + if type in type__fc.keys(): |
326 | + fname_invoice = invoice.fname_invoice and invoice.fname_invoice + '.xml' or '' |
327 | + fdata = base64.encodestring(index_content) |
328 | + res = type__fc[type](cr, uid, [data.id], fdata, context=context) |
329 | + msj = tools.ustr(res.get('msg', False)) |
330 | + index_xml = res.get('cfdi_xml', False) |
331 | + status = res.get('status', False) |
332 | + if status: |
333 | data_attach = { |
334 | 'name': fname_invoice, |
335 | 'datas': base64.encodestring(res.get('cfdi_xml', False)), |
336 | @@ -237,281 +247,273 @@ |
337 | 'res_model': 'account.invoice', |
338 | 'res_id': invoice.id, |
339 | } |
340 | - # Context, because use a variable type of our code but we |
341 | - # dont need it. |
342 | + # Context, because use a variable type of our code but we |
343 | + # dont need it. |
344 | attach = attachment_obj.create(cr, uid, data_attach, context=None) |
345 | if attach_v3_2: |
346 | cr.execute("""UPDATE ir_attachment |
347 | SET res_id = Null |
348 | WHERE id = %s""", (attach_v3_2,)) |
349 | - else: |
350 | - msj += _("Unknow driver for %s" % (type)) |
351 | + status = True |
352 | + else: |
353 | + msj += _("Unknow driver for %s" % (type)) |
354 | + if status: |
355 | + if index_xml: |
356 | + doc_xml = xml.dom.minidom.parseString(index_xml) |
357 | + index_xml = doc_xml.toprettyxml() |
358 | self.write(cr, uid, ids, |
359 | - {'file_xml_sign': attach or False, |
360 | - 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), |
361 | - 'msj': msj, |
362 | - 'file_xml_sign_index': index_xml}, context=context) |
363 | + {'file_xml_sign': attach or False, |
364 | + 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), |
365 | + 'msj': msj, |
366 | + 'file_xml_sign_index': index_xml}, context=context) |
367 | wf_service.trg_validate(uid, self._name, data.id, 'action_sign', cr) |
368 | - return True |
369 | - except Exception, e: |
370 | - error = tools.ustr(traceback.format_exc()) |
371 | - self.write(cr, uid, ids, {'msj': error}, context=context) |
372 | - _logger.error(error) |
373 | - return False |
374 | + return status |
375 | |
376 | def action_sign(self, cr, uid, ids, context=None): |
377 | return self.write(cr, uid, ids, {'state': 'signed'}, context=context) |
378 | |
379 | def signal_printable(self, cr, uid, ids, context=None): |
380 | - try: |
381 | - if context is None: |
382 | - context = {} |
383 | - aids = '' |
384 | - msj = '' |
385 | - index_pdf = '' |
386 | - attachment_obj = self.pool.get('ir.attachment') |
387 | - invoice = self.browse(cr, uid, ids)[0].invoice_id |
388 | - invoice_obj = self.pool.get('account.invoice') |
389 | - type = self.browse(cr, uid, ids)[0].type |
390 | - wf_service = netsvc.LocalService("workflow") |
391 | - (fileno, fname) = tempfile.mkstemp( |
392 | - '.pdf', 'openerp_' + (invoice.fname_invoice or '') + '__facturae__') |
393 | - os.close(fileno) |
394 | - #~ report = invoice_obj.create_report(cr, uid, [invoice.id], |
395 | - #~ "account.invoice.facturae.webkit", |
396 | - #~ fname) |
397 | + if context is None: |
398 | + context = {} |
399 | + aids = '' |
400 | + msj = '' |
401 | + index_pdf = '' |
402 | + attachment_obj = self.pool.get('ir.attachment') |
403 | + invoice = self.browse(cr, uid, ids)[0].invoice_id |
404 | + invoice_obj = self.pool.get('account.invoice') |
405 | + type = self.browse(cr, uid, ids)[0].type |
406 | + wf_service = netsvc.LocalService("workflow") |
407 | + status = False |
408 | + (fileno, fname) = tempfile.mkstemp( |
409 | + '.pdf', 'openerp_' + (invoice.fname_invoice or '') + '__facturae__') |
410 | + os.close(fileno) |
411 | + #~ report = invoice_obj.create_report(cr, uid, [invoice.id], |
412 | + #~ "account.invoice.facturae.webkit", |
413 | + #~ fname) |
414 | |
415 | - report_multicompany_obj = self.pool.get('report.multicompany') |
416 | - report_ids = report_multicompany_obj.search( |
417 | - cr, uid, [('model', '=', 'account.invoice')], limit=1) or False |
418 | - report_name = "account.invoice.facturae.webkit" |
419 | - if report_ids: |
420 | - report_name = report_multicompany_obj.browse(cr, uid, report_ids[0]).report_name |
421 | - service = netsvc.LocalService("report."+report_name) |
422 | - (result, format) = service.create(cr, SUPERUSER_ID, [invoice.id], report_name, context=context) |
423 | - attachment_ids = attachment_obj.search(cr, uid, [ |
424 | - ('res_model', '=', 'account.invoice'), |
425 | - ('res_id', '=', invoice.id), |
426 | - ('datas_fname', '=', invoice.fname_invoice + '.pdf')]) |
427 | - for attachment in self.browse(cr, uid, attachment_ids, context=context): |
428 | - # TODO: aids.append( attachment.id ) but without error in last |
429 | - # write |
430 | - aids = attachment.id |
431 | - attachment_obj.write(cr, uid, [attachment.id], { |
432 | - 'name': invoice.fname_invoice + '.pdf', }, context=context) |
433 | - if aids: |
434 | - msj = _("Attached Successfully PDF\n") |
435 | - else: |
436 | - raise osv.except_osv(_('Warning'), _('Not Attached PDF\n')) |
437 | + report_multicompany_obj = self.pool.get('report.multicompany') |
438 | + report_ids = report_multicompany_obj.search( |
439 | + cr, uid, [('model', '=', 'account.invoice')], limit=1) or False |
440 | + report_name = "account.invoice.facturae.webkit" |
441 | + if report_ids: |
442 | + report_name = report_multicompany_obj.browse(cr, uid, report_ids[0]).report_name |
443 | + service = netsvc.LocalService("report."+report_name) |
444 | + (result, format) = service.create(cr, SUPERUSER_ID, [invoice.id], report_name, context=context) |
445 | + attachment_ids = attachment_obj.search(cr, uid, [ |
446 | + ('res_model', '=', 'account.invoice'), |
447 | + ('res_id', '=', invoice.id), |
448 | + ('datas_fname', '=', invoice.fname_invoice + '.pdf')]) |
449 | + for attachment in self.browse(cr, uid, attachment_ids, context=context): |
450 | + # TODO: aids.append( attachment.id ) but without error in last |
451 | + # write |
452 | + aids = attachment.id |
453 | + attachment_obj.write(cr, uid, [attachment.id], { |
454 | + 'name': invoice.fname_invoice + '.pdf', }, context=context) |
455 | + status = True |
456 | + if status and aids: |
457 | + msj = _("Attached Successfully PDF\n") |
458 | self.write(cr, uid, ids, { |
459 | 'file_pdf': aids or False, |
460 | 'msj': msj, |
461 | 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), |
462 | 'file_pdf_index': index_pdf}, context=context) |
463 | - wf_service.trg_validate( |
464 | - uid, self._name, ids[0], 'action_printable', cr) |
465 | - return True |
466 | - except Exception, e: |
467 | - error = tools.ustr(traceback.format_exc()) |
468 | - self.write(cr, uid, ids, {'msj': error}, context=context) |
469 | - _logger.error(error) |
470 | - return False |
471 | + wf_service.trg_validate(uid, self._name, ids[0], 'action_printable', cr) |
472 | + else: |
473 | + raise osv.except_osv(_('Warning'), _('Not Attached PDF\n')) |
474 | + return status |
475 | |
476 | def action_printable(self, cr, uid, ids, context=None): |
477 | return self.write(cr, uid, ids, {'state': 'printable'}, context=context) |
478 | |
479 | def signal_send_customer(self, cr, uid, ids, context=None): |
480 | - try: |
481 | - if context is None: |
482 | - context = {} |
483 | - attachments = [] |
484 | - msj = '' |
485 | - attach_name = '' |
486 | - state = '' |
487 | - partner_mail = '' |
488 | - user_mail = '' |
489 | - company_id = self.pool.get('res.users').browse( |
490 | - cr, uid, uid, context=context).company_id.id |
491 | - invoice = self.browse(cr, uid, ids)[0].invoice_id |
492 | - address_id = self.pool.get('res.partner').address_get( |
493 | - cr, uid, [invoice.partner_id.id], ['invoice'])['invoice'] |
494 | - partner_invoice_address = self.pool.get( |
495 | - 'res.partner').browse(cr, uid, address_id, context=context) |
496 | - type = self.browse(cr, uid, ids)[0].type |
497 | - wf_service = netsvc.LocalService("workflow") |
498 | - fname_invoice = invoice.fname_invoice and invoice.fname_invoice or '' |
499 | - adjuntos = self.pool.get('ir.attachment').search(cr, uid, [( |
500 | - 'res_model', '=', 'account.invoice'), ('res_id', '=', invoice)]) |
501 | - subject = 'Invoice ' + (invoice.number or '') |
502 | - for attach in self.pool.get('ir.attachment').browse(cr, uid, adjuntos): |
503 | - attachments.append(attach.id) |
504 | - attach_name += attach.name + ', ' |
505 | - if release.version >= '7': |
506 | - obj_ir_mail_server = self.pool.get('ir.mail_server') |
507 | - obj_mail_mail = self.pool.get('mail.mail') |
508 | - obj_users = self.pool.get('res.users') |
509 | - obj_partner = self.pool.get('res.partner') |
510 | - mail_server_id = obj_ir_mail_server.search(cr, uid, |
511 | - ['|', ('company_id', '=', company_id), ('company_id', '=', False)], limit=1, order='sequence', context=None) |
512 | - if mail_server_id: |
513 | - for smtp_server in obj_ir_mail_server.browse(cr, uid, |
514 | - mail_server_id, context=context): |
515 | - server_name = smtp_server.name |
516 | - smtp = False |
517 | - try: |
518 | - smtp = obj_ir_mail_server.connect( |
519 | - smtp_server.smtp_host, smtp_server.smtp_port, |
520 | - user=smtp_server.smtp_user, |
521 | - password=smtp_server.smtp_pass, |
522 | - encryption=smtp_server.smtp_encryption, |
523 | - smtp_debug=smtp_server.smtp_debug) |
524 | - except Exception, e: |
525 | - raise osv.except_osv(_("Connection test failed!"), _( |
526 | - "Configure outgoing mail server named FacturaE:\n %s") % tools.ustr(e)) |
527 | - mail_compose_message_pool = self.pool.get( |
528 | - 'mail.compose.message') |
529 | - email_pool = self.pool.get('email.template') |
530 | + if context is None: |
531 | + context = {} |
532 | + attachments = [] |
533 | + msj = '' |
534 | + attach_name = '' |
535 | + state = '' |
536 | + partner_mail = '' |
537 | + user_mail = '' |
538 | + status = False |
539 | + company_id = self.pool.get('res.users').browse( |
540 | + cr, uid, uid, context=context).company_id.id |
541 | + invoice = self.browse(cr, uid, ids)[0].invoice_id |
542 | + address_id = self.pool.get('res.partner').address_get( |
543 | + cr, uid, [invoice.partner_id.id], ['invoice'])['invoice'] |
544 | + partner_invoice_address = self.pool.get( |
545 | + 'res.partner').browse(cr, uid, address_id, context=context) |
546 | + type = self.browse(cr, uid, ids)[0].type |
547 | + wf_service = netsvc.LocalService("workflow") |
548 | + fname_invoice = invoice.fname_invoice and invoice.fname_invoice or '' |
549 | + adjuntos = self.pool.get('ir.attachment').search(cr, uid, [( |
550 | + 'res_model', '=', 'account.invoice'), ('res_id', '=', invoice)]) |
551 | + subject = 'Invoice ' + (invoice.number or '') |
552 | + for attach in self.pool.get('ir.attachment').browse(cr, uid, adjuntos): |
553 | + attachments.append(attach.id) |
554 | + attach_name += attach.name + ', ' |
555 | + if release.version >= '7': |
556 | + obj_ir_mail_server = self.pool.get('ir.mail_server') |
557 | + obj_mail_mail = self.pool.get('mail.mail') |
558 | + obj_users = self.pool.get('res.users') |
559 | + obj_partner = self.pool.get('res.partner') |
560 | + mail_server_id = obj_ir_mail_server.search(cr, uid, |
561 | + ['|', ('company_id', '=', company_id), ('company_id', '=', False)], limit=1, order='sequence', context=None) |
562 | + if mail_server_id: |
563 | + for smtp_server in obj_ir_mail_server.browse(cr, uid, |
564 | + mail_server_id, context=context): |
565 | + server_name = smtp_server.name |
566 | + smtp = False |
567 | + try: |
568 | + smtp = obj_ir_mail_server.connect( |
569 | + smtp_server.smtp_host, smtp_server.smtp_port, |
570 | + user=smtp_server.smtp_user, |
571 | + password=smtp_server.smtp_pass, |
572 | + encryption=smtp_server.smtp_encryption, |
573 | + smtp_debug=smtp_server.smtp_debug) |
574 | + except Exception, e: |
575 | + raise osv.except_osv(_("Connection test failed!"), _( |
576 | + "Configure outgoing mail server named FacturaE:\n %s") % tools.ustr(e)) |
577 | + mail_compose_message_pool = self.pool.get( |
578 | + 'mail.compose.message') |
579 | + email_pool = self.pool.get('email.template') |
580 | |
581 | - report_multicompany_obj = self.pool.get('report.multicompany') |
582 | - report_ids = report_multicompany_obj.search( |
583 | - cr, uid, [('model', '=', 'account.invoice')], limit=1) or False |
584 | - if report_ids: |
585 | - report_name = report_multicompany_obj.browse(cr, uid, report_ids[0]).report_name |
586 | - if report_name: |
587 | - tmp_id = email_pool.search( |
588 | - cr, uid, [( |
589 | - 'model_id.model', '=', 'account.invoice'), |
590 | - ('company_id', |
591 | - '=', company_id), |
592 | - ('mail_server_id', |
593 | - '=', smtp_server.id), |
594 | - ('report_template.report_name', '=', |
595 | - report_name) |
596 | - ], limit=1, context=context) |
597 | - else: |
598 | + report_multicompany_obj = self.pool.get('report.multicompany') |
599 | + report_ids = report_multicompany_obj.search( |
600 | + cr, uid, [('model', '=', 'account.invoice')], limit=1) or False |
601 | + if report_ids: |
602 | + report_name = report_multicompany_obj.browse(cr, uid, report_ids[0]).report_name |
603 | + if report_name: |
604 | tmp_id = email_pool.search( |
605 | cr, uid, [( |
606 | 'model_id.model', '=', 'account.invoice'), |
607 | - ('company_id', '=', company_id), |
608 | - ('mail_server_id', '=', smtp_server.id), |
609 | + ('company_id', |
610 | + '=', company_id), |
611 | + ('mail_server_id', |
612 | + '=', smtp_server.id), |
613 | ('report_template.report_name', '=', |
614 | - 'account.invoice.facturae.webkit') |
615 | + report_name) |
616 | ], limit=1, context=context) |
617 | + else: |
618 | + tmp_id = email_pool.search( |
619 | + cr, uid, [( |
620 | + 'model_id.model', '=', 'account.invoice'), |
621 | + ('company_id', '=', company_id), |
622 | + ('mail_server_id', '=', smtp_server.id), |
623 | + ('report_template.report_name', '=', |
624 | + 'account.invoice.facturae.webkit') |
625 | + ], limit=1, context=context) |
626 | |
627 | - if tmp_id: |
628 | - message = mail_compose_message_pool.onchange_template_id( |
629 | - cr, uid, [], template_id=tmp_id[ |
630 | - 0], composition_mode=None, |
631 | - model='account.invoice', res_id=invoice.id, context=context) |
632 | - mssg = message.get('value', False) |
633 | - user_mail = obj_users.browse( |
634 | - cr, uid, uid, context=None).email |
635 | - partner_id = mssg.get('partner_ids', False) |
636 | - partner_mail = obj_partner.browse( |
637 | - cr, uid, partner_id)[0].email |
638 | - partner_name = obj_partner.browse( |
639 | - cr, uid, partner_id)[0].name |
640 | - if partner_mail: |
641 | - if user_mail: |
642 | - if mssg.get('partner_ids', False) and tmp_id: |
643 | - mssg['partner_ids'] = [ |
644 | - (6, 0, mssg['partner_ids'])] |
645 | - mssg['attachment_ids'] = [ |
646 | - (6, 0, attachments)] |
647 | - mssg_id = self.pool.get( |
648 | - 'mail.compose.message').create(cr, uid, mssg, context=None) |
649 | - state = self.pool.get('mail.compose.message').send_mail( |
650 | - cr, uid, [mssg_id], context=context) |
651 | - asunto = mssg['subject'] |
652 | - id_mail = obj_mail_mail.search( |
653 | - cr, uid, [('subject', '=', asunto)]) |
654 | - if id_mail: |
655 | - for mail in obj_mail_mail.browse(cr, uid, id_mail, context=None): |
656 | - if mail.state == 'exception': |
657 | - msj = _( |
658 | - '\nNot correct email of the user or customer. Check in Menu Configuración\Tecnico\Email\Emails\n') |
659 | - else: |
660 | - msj = _('Email Send Successfully.Attached is sent to %s for Outgoing Mail Server %s') % ( |
661 | - partner_mail, server_name) |
662 | - self.write(cr, uid, ids, { |
663 | - 'msj': msj, |
664 | - 'last_date': time.strftime('%Y-%m-%d %H:%M:%S')}) |
665 | - wf_service.trg_validate( |
666 | - uid, self._name, ids[0], 'action_send_customer', cr) |
667 | - return True |
668 | - else: |
669 | - raise osv.except_osv( |
670 | - _('Warning'), _('This user does not have mail')) |
671 | + if tmp_id: |
672 | + message = mail_compose_message_pool.onchange_template_id( |
673 | + cr, uid, [], template_id=tmp_id[ |
674 | + 0], composition_mode=None, |
675 | + model='account.invoice', res_id=invoice.id, context=context) |
676 | + mssg = message.get('value', False) |
677 | + user_mail = obj_users.browse( |
678 | + cr, uid, uid, context=None).email |
679 | + partner_id = mssg.get('partner_ids', False) |
680 | + partner_mail = obj_partner.browse( |
681 | + cr, uid, partner_id)[0].email |
682 | + partner_name = obj_partner.browse( |
683 | + cr, uid, partner_id)[0].name |
684 | + if partner_mail: |
685 | + if user_mail: |
686 | + if mssg.get('partner_ids', False) and tmp_id: |
687 | + mssg['partner_ids'] = [ |
688 | + (6, 0, mssg['partner_ids'])] |
689 | + mssg['attachment_ids'] = [ |
690 | + (6, 0, attachments)] |
691 | + mssg_id = self.pool.get( |
692 | + 'mail.compose.message').create(cr, uid, mssg, context=None) |
693 | + state = self.pool.get('mail.compose.message').send_mail( |
694 | + cr, uid, [mssg_id], context=context) |
695 | + asunto = mssg['subject'] |
696 | + id_mail = obj_mail_mail.search( |
697 | + cr, uid, [('subject', '=', asunto)]) |
698 | + if id_mail: |
699 | + for mail in obj_mail_mail.browse(cr, uid, id_mail, context=None): |
700 | + if mail.state == 'exception': |
701 | + msj = _( |
702 | + '\nNot correct email of the user or customer. Check in Menu Configuración\Tecnico\Email\Emails\n') |
703 | + raise osv.except_osv(_('Warning'), _('Not correct email of the user or customer. Check in Menu Configuración\Tecnico\Email\Emails')) |
704 | + msj = _('Email Send Successfully.Attached is sent to %s for Outgoing Mail Server %s') % ( |
705 | + partner_mail, server_name) |
706 | + self.write(cr, uid, ids, { |
707 | + 'msj': msj, |
708 | + 'last_date': time.strftime('%Y-%m-%d %H:%M:%S')}) |
709 | + wf_service.trg_validate( |
710 | + uid, self._name, ids[0], 'action_send_customer', cr) |
711 | + status = True |
712 | + else: |
713 | + msj = _('Email Send Successfully.Attached is sent to %s for Outgoing Mail Server %s') % ( |
714 | + partner_mail, server_name) |
715 | + self.write(cr, uid, ids, { |
716 | + 'msj': msj, |
717 | + 'last_date': time.strftime('%Y-%m-%d %H:%M:%S')}) |
718 | + wf_service.trg_validate( |
719 | + uid, self._name, ids[0], 'action_send_customer', cr) |
720 | + status = True |
721 | else: |
722 | raise osv.except_osv( |
723 | - _('Warning'), _('The customer %s does not have mail') % (partner_name)) |
724 | + _('Warning'), _('This user does not have mail')) |
725 | else: |
726 | raise osv.except_osv( |
727 | - _('Warning'), _('Check that your template is assigned outgoing mail server named %s.\nAlso the field has report_template = Factura Electronica Report.\nTemplate is associated with the same company') % (server_name)) |
728 | + _('Warning'), _('The customer %s does not have mail') % (partner_name)) |
729 | else: |
730 | - raise osv.except_osv(_('Warning'), _('Not Found\ |
731 | - outgoing mail server.Configure the outgoing mail server named "FacturaE"')) |
732 | - except Exception, e: |
733 | - error = tools.ustr(traceback.format_exc()) |
734 | - self.write(cr, uid, ids, {'msj': error}, context=context) |
735 | - _logger.error(error) |
736 | - return False |
737 | + raise osv.except_osv( |
738 | + _('Warning'), _('Check that your template is assigned outgoing mail server named %s.\nAlso the field has report_template = Factura Electronica Report.\nTemplate is associated with the same company') % (server_name)) |
739 | + else: |
740 | + raise osv.except_osv(_('Warning'), _('Not Found\ |
741 | + outgoing mail server.Configure the outgoing mail server named "FacturaE"')) |
742 | + return status |
743 | |
744 | def action_send_customer(self, cr, uid, ids, context=None): |
745 | return self.write(cr, uid, ids, {'state': 'sent_customer'}, context=context) |
746 | |
747 | def signal_send_backup(self, cr, uid, ids, context=None): |
748 | - try: |
749 | - if context is None: |
750 | - context = {} |
751 | - msj = '' |
752 | - wf_service = netsvc.LocalService("workflow") |
753 | - msj = _('Send Backup\n') |
754 | - self.write(cr, uid, ids, {'msj': msj, |
755 | - 'last_date': time.strftime('%Y-%m-%d %H:%M:%S') |
756 | - }, context=context) |
757 | - wf_service.trg_validate( |
758 | - uid, self._name, ids[0], 'action_send_backup', cr) |
759 | - return True |
760 | - except Exception, e: |
761 | - error = tools.ustr(traceback.format_exc()) |
762 | - self.write(cr, uid, ids, {'msj': error}, context=context) |
763 | - _logger.error(error) |
764 | - return False |
765 | + if context is None: |
766 | + context = {} |
767 | + msj = '' |
768 | + wf_service = netsvc.LocalService("workflow") |
769 | + msj = _('Send Backup\n') |
770 | + self.write(cr, uid, ids, {'msj': msj, |
771 | + 'last_date': time.strftime('%Y-%m-%d %H:%M:%S') |
772 | + }, context=context) |
773 | + wf_service.trg_validate(uid, self._name, ids[0], 'action_send_backup', cr) |
774 | + return True |
775 | |
776 | def action_send_backup(self, cr, uid, ids, context=None): |
777 | return self.write(cr, uid, ids, {'state': 'sent_backup'}, context=context) |
778 | |
779 | def signal_done(self, cr, uid, ids, context=None): |
780 | - try: |
781 | - if context is None: |
782 | - context = {} |
783 | - msj = '' |
784 | - wf_service = netsvc.LocalService("workflow") |
785 | - msj = _('Done\n') |
786 | - self.write(cr, uid, ids, {'msj': msj, |
787 | - 'last_date': time.strftime('%Y-%m-%d %H:%M:%S') |
788 | - }, context=context) |
789 | - wf_service.trg_validate(uid, self._name, ids[0], 'action_done', cr) |
790 | - return True |
791 | - except Exception, e: |
792 | - error = tools.ustr(traceback.format_exc()) |
793 | - self.write(cr, uid, ids, {'msj': error}, context=context) |
794 | - _logger.error(error) |
795 | - return False |
796 | + if context is None: |
797 | + context = {} |
798 | + msj = '' |
799 | + wf_service = netsvc.LocalService("workflow") |
800 | + msj = _('Done\n') |
801 | + self.write(cr, uid, ids, {'msj': msj, |
802 | + 'last_date': time.strftime('%Y-%m-%d %H:%M:%S') |
803 | + }, context=context) |
804 | + wf_service.trg_validate(uid, self._name, ids[0], 'action_done', cr) |
805 | + return True |
806 | |
807 | def action_done(self, cr, uid, ids, context=None): |
808 | return self.write(cr, uid, ids, {'state': 'done'}, context=context) |
809 | |
810 | def signal_cancel(self, cr, uid, ids, context=None): |
811 | - try: |
812 | - invoice_obj = self.pool.get('account.invoice') |
813 | - attach_obj = self.pool.get('ir.attachment') |
814 | - wf_service = netsvc.LocalService("workflow") |
815 | - inv_cancel_status = False |
816 | - for ir_attach_facturae_mx_id in self.browse(cr, uid, ids, context=context): |
817 | - msj = '' |
818 | - invoice = ir_attach_facturae_mx_id.invoice_id |
819 | + invoice_obj = self.pool.get('account.invoice') |
820 | + attach_obj = self.pool.get('ir.attachment') |
821 | + wf_service = netsvc.LocalService("workflow") |
822 | + status = False |
823 | + status_stamp = False |
824 | + res = False |
825 | + for ir_attach_facturae_mx_id in self.browse(cr, uid, ids, context=context): |
826 | + msj = '' |
827 | + invoice = ir_attach_facturae_mx_id.invoice_id |
828 | + if invoice.state != 'cancel': |
829 | + res = invoice_obj.action_cancel(cr, uid, [invoice.id]) |
830 | + else: |
831 | + #wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_cancel', cr) |
832 | if 'cfdi' in ir_attach_facturae_mx_id.type: |
833 | if not ir_attach_facturae_mx_id.state in ['cancel', 'draft', 'confirmed']: |
834 | type__fc = self.get_driver_fc_cancel() |
835 | @@ -521,57 +523,45 @@ |
836 | ir_attach_facturae_mx_id.id], context=context |
837 | ) |
838 | msj += tools.ustr(cfdi_cancel.get('message', False)) |
839 | - # TODO, validate cfdi_cancel True or False |
840 | - if cfdi_cancel.get('status', True): |
841 | + status_stamp = cfdi_cancel.get('status', False) |
842 | + if status_stamp: |
843 | + cr.execute("""UPDATE ir_attachment SET res_id = Null |
844 | + WHERE res_id = %s and res_model='account.invoice'""", (invoice.id,)) |
845 | wf_service.trg_validate( |
846 | uid, self._name, ir_attach_facturae_mx_id.id, 'action_cancel', cr) |
847 | - if invoice.state != 'cancel': |
848 | - inv_cancel_status = invoice_obj.action_cancel( |
849 | - cr, uid, [invoice.id], context=context) |
850 | - cr.execute("""UPDATE ir_attachment |
851 | - SET res_id = Null |
852 | - WHERE res_id = %s and res_model='account.invoice'""", (invoice.id,)) |
853 | - else: |
854 | - inv_cancel_status = True |
855 | + status = True |
856 | + else: |
857 | + status = False |
858 | else: |
859 | - msj += _("Unknow cfdi driver for %s" % (ir_attach_facturae_mx_id.type)) |
860 | + msj = _("Unknow cfdi driver for %s" % (ir_attach_facturae_mx_id.type)) |
861 | else: |
862 | wf_service.trg_validate( |
863 | uid, self._name, ir_attach_facturae_mx_id.id, 'action_cancel', cr) |
864 | - if invoice.state != 'cancel': |
865 | - inv_cancel_status = invoice_obj.action_cancel( |
866 | - cr, uid, [invoice.id], context=context) |
867 | - cr.execute("""UPDATE ir_attachment |
868 | - SET res_id = Null |
869 | - WHERE res_id = %s and res_model='account.invoice'""", (invoice.id,)) |
870 | - else: |
871 | - inv_cancel_status = True |
872 | + cr.execute("""UPDATE ir_attachment SET res_id = Null |
873 | + WHERE res_id = %s and res_model='account.invoice'""", (invoice.id,)) |
874 | + status = True |
875 | msj = 'cancelled' |
876 | elif 'cfd' in ir_attach_facturae_mx_id.type and not 'cfdi' in ir_attach_facturae_mx_id.type: |
877 | wf_service.trg_validate( |
878 | uid, self._name, ir_attach_facturae_mx_id.id, 'action_cancel', cr) |
879 | inv_cancel_status = invoice_obj.action_cancel(cr, uid, [invoice.id], context=context) |
880 | msj = 'cancelled' |
881 | - inv_cancel_status = True |
882 | + status = True |
883 | elif 'cbb' in ir_attach_facturae_mx_id.type: |
884 | wf_service.trg_validate( |
885 | uid, self._name, ir_attach_facturae_mx_id.id, 'action_cancel', cr) |
886 | inv_cancel_status = invoice_obj.action_cancel(cr, uid, [invoice.id], context=context) |
887 | msj = 'cancelled' |
888 | - inv_cancel_status = True |
889 | + status = True |
890 | else: |
891 | raise osv.except_osv(_("Type Electronic Invoice Unknow!"), _( |
892 | "The Type Electronic Invoice:" + (ir_attach_facturae_mx_id.type or ''))) |
893 | - self.write(cr, uid, ids, { |
894 | + if status: |
895 | + self.write(cr, uid, ids, { |
896 | 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'), |
897 | 'msj': msj, |
898 | }) |
899 | - except Exception, e: |
900 | - error = tools.ustr( traceback.format_exc() ) |
901 | - self.write(cr, uid, ids, {'msj': error}, context=context) |
902 | - _logger.error( error ) |
903 | - return False |
904 | - return inv_cancel_status |
905 | + return status |
906 | |
907 | def action_cancel(self, cr, uid, ids, context=None): |
908 | return self.write(cr, uid, ids, {'state': 'cancel'}, context=context) |
909 | |
910 | === modified file 'l10n_mx_ir_attachment_facturae/ir_attachment_facturae_view.xml' |
911 | --- l10n_mx_ir_attachment_facturae/ir_attachment_facturae_view.xml 2013-10-08 22:57:43 +0000 |
912 | +++ l10n_mx_ir_attachment_facturae/ir_attachment_facturae_view.xml 2014-08-28 21:29:50 +0000 |
913 | @@ -44,6 +44,7 @@ |
914 | <field name="file_xml_sign"/> |
915 | <field name="file_pdf"/> |
916 | <field name="identifier"/> |
917 | + <field name="file_input_index"/> |
918 | <field name="file_xml_sign_index"/> |
919 | <field name="file_pdf_index"/> |
920 | </group> |
@Moy
Ya revise esta propuesta de merge funcionalmente. Falta en cuestiones técnicas no se si tu le puedas dar una revisada para proceder con su mergeo.