Reviewers: ,


Please review this at http://codereview.tryton.org/230004/

Affected files:
  M inventory.py


Index: inventory.py
===================================================================
--- a/inventory.py
+++ b/inventory.py
@@ -99,6 +99,12 @@
             'state': 'done',
             })

+    def write(self, ids, vals):
+        product_obj = self.pool.get('product.product')
+        res = super(Inventory, self).write(ids, vals)
+        self.complete_lines(ids, fill=False)
+        return res
+
     def copy(self, ids, default=None):
         date_obj = Pool().get('ir.date')
         line_obj = Pool().get('stock.inventory.line')
@@ -129,7 +135,7 @@
             return new_ids[0]
         return new_ids

-    def complete_lines(self, ids):
+    def complete_lines(self, ids, fill=True):
         '''
         Complete or update the inventories

@@ -179,13 +185,14 @@
                     line_obj.write(line.id, values)

             # Create lines if needed
-            for product_id in product_qty:
-                if product2type[product_id] != 'stockable':
-                    continue
-                quantity, uom_id = product_qty[product_id]
- values = line_obj.create_values4complete(product_id, inventory,
-                        quantity, uom_id)
-                line_obj.create(values)
+            if fill:
+                for product_id in product_qty:
+                    if product2type[product_id] != 'stockable':
+                        continue
+                    quantity, uom_id = product_qty[product_id]
+ values = line_obj.create_values4complete(product_id, inventory,
+                            quantity, uom_id)
+                    line_obj.create(values)

 Inventory()



--
[email protected] mailing list

Reply via email to