Ravi Gohil (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-574049-rgo 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-574049-rgo/+merge/104885

Hello,

There is an issue when delivering the SO partially, invoice is created with 
undelivered quantity,

Steps to Reproduce the issue:

1) create a so with a product: say for example PC1 with quantity=10 with below 
policies and confirm it. A picking is created.

Picking Policy: Deliver each product when available
Invoice Policy: Deliver & invoice on demand
Invoice On: Shipped Quantities

2) Now, deliver 3 products from created picking, go to SO created and click on 
"Create Final Invoice", invoice will be created with quantity 7(undelivered 
quantity).

This MP contains fix for this issue, Kindly review it.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-574049-rgo/+merge/104885
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-574049-rgo.
=== modified file 'sale/sale.py'
--- sale/sale.py	2012-02-16 16:52:53 +0000
+++ sale/sale.py	2012-05-07 10:38:20 +0000
@@ -912,6 +912,33 @@
         return False
 sale_order()
 
+class procurement_order(osv.osv):
+    _inherit = 'procurement.order'
+    
+    def _quantity_compute_get(self, cr, uid, proc, context=None):
+        """ Computes only quantity of product that were Delivered and also computes the quantity of returned products.
+        @param proc: Current procurement.
+        @return: Quantity or False.
+        """
+        if proc.product_id.type == 'product' and proc.move_id:
+            move_obj = self.pool.get('stock.move')
+            sale_id = proc.move_id.picking_id.sale_id.id
+            picking_ids = self.pool.get('stock.picking').search(cr, uid, [('sale_id', '=', sale_id), ('state', '=', 'done'), ('type', '=', 'out')], context=context)
+            returned_picking_ids = self.pool.get('stock.picking').search(cr, uid, [('sale_id', '=', sale_id), ('state', '=', 'done'), ('type', '=', 'in')], context=context)
+            qty_uos = 0
+            for returned_picking_id in returned_picking_ids:
+                 move_ids = move_obj.search(cr, uid, [('picking_id', '=', returned_picking_id)], context=context)
+                 qty_uos += move_obj.browse(cr, uid, move_ids, context=context)[0].product_uos_qty
+            qty_uos = -qty_uos
+            for picking_id in picking_ids:
+                move_ids = move_obj.search(cr, uid, [('picking_id', '=', picking_id)], context=context)
+                qty_uos += move_obj.browse(cr, uid, move_ids, context=context)[0].product_uos_qty
+            return qty_uos
+        return False
+    
+procurement_order()
+
+
 # TODO add a field price_unit_uos
 # - update it on change product and unit price
 # - use it in report if there is a uos

_______________________________________________
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