diff options
| author | mreficent <miquel.raich@eficent.com> | 2019-09-17 13:25:40 +0000 |
|---|---|---|
| committer | mreficent <miquel.raich@eficent.com> | 2019-10-03 15:35:47 +0000 |
| commit | 72333b2e09605730de59cd2bc4ee54349cfe3d16 (patch) | |
| tree | b2505cef8ce39bbe1e555817be64afc8b262e29e | |
| parent | a96872defe3779b1a2ac4be43a525490f7e74f56 (diff) | |
[IMP] stock: add hook to get virtual location
Some companies may have several locations with usage == 'inventory' and they would like to choose each time which adjustment location to use.
closes odoo/odoo#37022
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
| -rw-r--r-- | addons/stock/models/stock_inventory.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index 556d012d895..a79b3552b05 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -469,16 +469,20 @@ class InventoryLine(models.Model): })] } + def _get_virtual_location(self): + return self.product_id.with_context(force_company=self.company_id.id).property_stock_inventory + def _generate_moves(self): vals_list = [] for line in self: + virtual_location = line._get_virtual_location() rounding = line.product_id.uom_id.rounding if float_is_zero(line.difference_qty, precision_rounding=rounding): continue if line.difference_qty > 0: # found more than expected - vals = line._get_move_values(line.difference_qty, line.product_id.with_context(force_company=line.company_id.id).property_stock_inventory.id, line.location_id.id, False) + vals = line._get_move_values(line.difference_qty, virtual_location.id, line.location_id.id, False) else: - vals = line._get_move_values(abs(line.difference_qty), line.location_id.id, line.product_id.with_context(force_company=line.company_id.id).property_stock_inventory.id, True) + vals = line._get_move_values(abs(line.difference_qty), line.location_id.id, virtual_location.id, True) vals_list.append(vals) return self.env['stock.move'].create(vals_list) |
