[FIX] inversed invoice_control value problem in stock_location addon (with
authorrha@tinyerp.com <rha@tinyerp.com>
Mon, 14 Oct 2013 07:54:43 +0000 (07:54 +0000)
committerStefan Rijnhart <stefan@therp.nl>
Wed, 2 Jul 2014 17:41:42 +0000 (19:41 +0200)
chained picking setup)

https://launchpad.net/bugs/1208456

addons/sale_stock/stock.py
addons/stock_location/stock_location.py

index c69ea6d..6efa1f5 100644 (file)
@@ -31,6 +31,9 @@ class stock_move(osv.osv):
         values = super(stock_move, self)._prepare_chained_picking(cr, uid, picking_name, picking, picking_type, moves_todo, context=context)
         if picking.sale_id:
             values['sale_id'] = picking.sale_id.id
+            if values.get('type') == 'out' and picking.sale_id.order_policy == 'picking':
+                values['invoice_state'] = '2binvoiced'
+        picking.write({'invoice_state': 'none'})
         return values
 
 class stock_picking(osv.osv):
index 1258ddb..1843907 100644 (file)
@@ -112,7 +112,11 @@ class stock_move(osv.osv):
 
     def _prepare_chained_picking(self, cr, uid, picking_name, picking, picking_type, moves_todo, context=None):
         res = super(stock_move, self)._prepare_chained_picking(cr, uid, picking_name, picking, picking_type, moves_todo, context=context)
-        res.update({'invoice_state': moves_todo[0][1][6] or 'none'})
+        state = moves_todo[0][1][6] or 'none'
+        if picking.sale_id:
+            if res.get('type') == 'out' and picking.sale_id.order_policy == 'picking':
+                state = '2binvoiced'
+        res.update(invoice_state=state)
         return res
 stock_move()