Meera Trambadia (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-804265-mtr into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #804265 in OpenERP Addons: "group sales order with different pricelists 
in a same invoice"
  https://bugs.launchpad.net/openobject-addons/+bug/804265

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-804265-mtr/+merge/69059

Sale:-It raise an exception while grouping SO having pricelist with different 
currencies." --fixes=lp:804265 
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-804265-mtr/+merge/69059
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-804265-mtr.
=== modified file 'sale/sale.py'
--- sale/sale.py	2011-07-08 11:50:51 +0000
+++ sale/sale.py	2011-07-25 10:14:29 +0000
@@ -465,6 +465,7 @@
         res = False
         invoices = {}
         invoice_ids = []
+        res_partner_pricelist = {}
         picking_obj = self.pool.get('stock.picking')
         invoice = self.pool.get('account.invoice')
         obj_sale_order_line = self.pool.get('sale.order.line')
@@ -481,6 +482,11 @@
                     continue
                 elif (line.state in states):
                     lines.append(line.id)
+            if o.partner_id.id in res_partner_pricelist:
+                if o.pricelist_id.currency_id.id not in res_partner_pricelist[o.partner_id.id]:
+                    res_partner_pricelist[o.partner_id.id].append(o.pricelist_id.currency_id.id)
+            else:
+                res_partner_pricelist[o.partner_id.id] = [o.pricelist_id.currency_id.id]
             created_lines = obj_sale_order_line.invoice_line_create(cr, uid, lines)
             if created_lines:
                 invoices.setdefault(o.partner_id.id, []).append((o, created_lines))
@@ -491,6 +497,9 @@
                         return i.id
         for val in invoices.values():
             if grouped:
+                if len([ value for value in res_partner_pricelist.values() if len(value)!= 1]) != 0:
+                    raise osv.except_osv(_('Could not group these sales order in a same invoice!'),
+                                         _('You are trying to group sales order having pricelist with different currencies in a same invoice!'))
                 res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x, y: x + y, [l for o, l in val], []), context=context)
                 invoice_ref = ''
                 for o, l in val:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to