From 302338cea5051d56432d4d3cc3b0e60d1cecb1ff Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Fri, 2 Aug 2019 09:46:24 +0000 Subject: [PATCH] [FIX] stock: duplicate inventory Before this commit, when you duplicate a validated inventory, the new one has the inventory lines of the original one. Now, the duplicate inventory is created without inventory lines. Task #2043851 closes odoo/odoo#35402 Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/stock_inventory.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index f9a08e4747d..914a627079b 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -38,7 +38,7 @@ class Inventory(models.Model): "If the inventory adjustment is validated, date at which the inventory adjustment has been validated.") line_ids = fields.One2many( 'stock.inventory.line', 'inventory_id', string='Inventories', - copy=True, readonly=False, + copy=False, readonly=False, states={'done': [('readonly', True)]}) move_ids = fields.One2many( 'stock.move', 'inventory_id', string='Created Moves', @@ -73,6 +73,11 @@ class Inventory(models.Model): "with all counted quantity set to zero.", default='counted', selection=[('counted', 'Default to stock on hand'), ('zero', 'Default to zero')]) + def copy_data(self, default=None): + name = _("%s (copy)") % (self.name) + default = dict(default or {}, name=name) + return super(Inventory, self).copy_data(default) + def unlink(self): for inventory in self: if inventory.state not in ('draft', 'cancel'):