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
=== modified file 'base_sale_multichannels/sale.py'
--- base_sale_multichannels/sale.py 2013-06-08 20:04:37 +0000
+++ base_sale_multichannels/sale.py 2013-06-09 15:09:25 +0000
@@ -475,14 +475,21 @@
475 return True475 return True
476476
477 def export_invoices(self, cr, uid, ids, context=None):477 def export_invoices(self, cr, uid, ids, context=None):
478 for shop in self.browse(cr, uid, ids, context=None):
479 external_session = ExternalSession(shop.referential_id, shop)
480 self._export_invoice_for_shop(cr, uid, external_session, shop, context=context)
481 return True
482
483 def _export_invoice_for_shop(self, cr, uid, external_session, shop, context=None):
478 invoice_obj = self.pool.get('account.invoice')484 invoice_obj = self.pool.get('account.invoice')
479 for shop in self.browse(cr, uid, ids, context=None):485 invoice_ids = self.get_invoice_to_export(cr, uid, shop.id, context=context)
480 external_session = ExternalSession(shop.referential_id, shop)486 external_session.logger.info("Start to export %s invoice for the shop '%s' to the external referential" % (len(invoice_ids), shop.name,))
481 invoice_ids = self.get_invoice_to_export(cr, uid, shop.id, context=context)487 if not invoice_ids:
482 if not invoice_ids:488 external_session.logger.info("There is no invoice to export for the shop '%s' to the external referential" % (shop.name,))
483 external_session.logger.info("There is no invoice to export for the shop '%s' to the external referential" % (shop.name,))489 for invoice_id in invoice_ids:
484 for invoice_id in invoice_ids:490 with new_cursor(cr, external_session.logger) as new_cr:
485 self.pool.get('account.invoice')._export_one_resource(cr, uid, external_session, invoice_id, context=context)491 with commit_now(new_cr, external_session.logger) as cr:
492 invoice_obj._export_one_resource(new_cr, uid, external_session, invoice_id, context=context)
486 return True493 return True
487494
488 def get_invoice_to_export(self, cr, uid, shop_id, context=None):495 def get_invoice_to_export(self, cr, uid, shop_id, context=None):