Merge lp:~sebastien.beau/e-commerce-addons/e-commerce-addons-improve-invoice-export into lp:~extra-addons-commiter/e-commerce-addons/oerp6.1-stable

Proposed by Sébastien BEAU - http://www.akretion.com
Status: Merged
Merged at revision: 287
Proposed branch: lp:~sebastien.beau/e-commerce-addons/e-commerce-addons-improve-invoice-export
Merge into: lp:~extra-addons-commiter/e-commerce-addons/oerp6.1-stable
Diff against target: 32 lines (+14/-7)
1 file modified
base_sale_multichannels/sale.py (+14/-7)
To merge this branch: bzr merge lp:~sebastien.beau/e-commerce-addons/e-commerce-addons-improve-invoice-export
Reviewer Review Type Date Requested Status
Maxime Chambreuil (http://www.savoirfairelinux.com) code review Approve
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+168289@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Hi I just split the function in two and commit it directly after pushing it.
This avoid in case of error to send twice the invoice. It will be better to add the reporting system on the invoice export, but for now I don't have the time. And I prefer to focus on 7.0 version. So just add this change to make the 6.1 more stable.

Thanks

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_sale_multichannels/sale.py'
2--- base_sale_multichannels/sale.py 2013-06-08 20:04:37 +0000
3+++ base_sale_multichannels/sale.py 2013-06-09 15:09:25 +0000
4@@ -475,14 +475,21 @@
5 return True
6
7 def export_invoices(self, cr, uid, ids, context=None):
8+ for shop in self.browse(cr, uid, ids, context=None):
9+ external_session = ExternalSession(shop.referential_id, shop)
10+ self._export_invoice_for_shop(cr, uid, external_session, shop, context=context)
11+ return True
12+
13+ def _export_invoice_for_shop(self, cr, uid, external_session, shop, context=None):
14 invoice_obj = self.pool.get('account.invoice')
15- for shop in self.browse(cr, uid, ids, context=None):
16- external_session = ExternalSession(shop.referential_id, shop)
17- invoice_ids = self.get_invoice_to_export(cr, uid, shop.id, context=context)
18- if not invoice_ids:
19- external_session.logger.info("There is no invoice to export for the shop '%s' to the external referential" % (shop.name,))
20- for invoice_id in invoice_ids:
21- self.pool.get('account.invoice')._export_one_resource(cr, uid, external_session, invoice_id, context=context)
22+ invoice_ids = self.get_invoice_to_export(cr, uid, shop.id, context=context)
23+ external_session.logger.info("Start to export %s invoice for the shop '%s' to the external referential" % (len(invoice_ids), shop.name,))
24+ if not invoice_ids:
25+ external_session.logger.info("There is no invoice to export for the shop '%s' to the external referential" % (shop.name,))
26+ for invoice_id in invoice_ids:
27+ with new_cursor(cr, external_session.logger) as new_cr:
28+ with commit_now(new_cr, external_session.logger) as cr:
29+ invoice_obj._export_one_resource(new_cr, uid, external_session, invoice_id, context=context)
30 return True
31
32 def get_invoice_to_export(self, cr, uid, shop_id, context=None):