Somesh Khare(OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-575216-skh into 
lp:openobject-addons/6.1.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-575216-skh/+merge/107919

Hello Sir,

[FIX] purchase :Use of multi-currency in purchase order workflow is 
inconsistent as compared to a sale order

Steps to reproduce:

1. Install Puchase module and create new pricelist which has different currency 
than company currency (Eg: Company currency = EUR, New Purchase Pricelist 
currency=USD).
2. Create PO and select NewPricelist.
3. Pay the created invoice from the PO and see the "Progress bar" for the 
Invoice rate also the boolean field "Invoiced & Paid" in not checked even if 
the Invoice is in paid state.

This branch fixes this issue.

Kindly review the branch and please share your views on it.

Thanks,
Somesh Khare
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-575216-skh/+merge/107919
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-575216-skh.
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py	2012-02-16 12:34:08 +0000
+++ purchase/purchase.py	2012-05-30 06:58:18 +0000
@@ -88,12 +88,15 @@
     def _invoiced_rate(self, cursor, user, ids, name, arg, context=None):
         res = {}
         for purchase in self.browse(cursor, user, ids, context=context):
+            if purchase.invoiced:
+                res[purchase.id] = 100.0
+                continue
             tot = 0.0
             for invoice in purchase.invoice_ids:
                 if invoice.state not in ('draft','cancel'):
                     tot += invoice.amount_untaxed
-            if purchase.amount_untaxed:
-                res[purchase.id] = tot * 100.0 / purchase.amount_untaxed
+            if tot:
+                res[purchase.id] = tot * 100.0 / purchase.amount_untaxed 
             else:
                 res[purchase.id] = 0.0
         return res
@@ -135,10 +138,16 @@
     def _invoiced(self, cursor, user, ids, name, arg, context=None):
         res = {}
         for purchase in self.browse(cursor, user, ids, context=context):
-            invoiced = False
-            if purchase.invoiced_rate == 100.00:
-                invoiced = True
-            res[purchase.id] = invoiced
+            res[purchase.id] = True
+            invoice_existence = False
+            for invoice in purchase.invoice_ids:
+                if invoice.state!='cancel':
+                    invoice_existence = True
+                    if invoice.state != 'paid':
+                        res[purchase.id] = False
+                        break
+            if not invoice_existence:
+                res[purchase.id] = False
         return res
 
     STATE_SELECTION = [

_______________________________________________
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