diff options
| author | Swapnesh Shah <swapneshshah111@gmail.com> | 2020-03-16 18:11:15 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-05-15 09:14:06 +0000 |
| commit | bea1613f11e1def53bc3c558f82b8edc4633091a (patch) | |
| tree | ebf597da2ab014963648faaaf7dbb77070d1d98c | |
| parent | 0cc6a76891d022cf44ba1117799fa0165663d4e8 (diff) | |
[FIX] stock,stock_account: fix undefined variable and return True
Fixes #29694
Close #47204
Fix #37554
Before this commit, There was Traceback on calling this method w/o any inventories as variable `res` was not declared but Returned or Calling this methord over RPC will raise TypeError as this method does not returns amything.
In this commit, We return True at original `post_inventory` method and Declare `res` to prevent undefined variable.
closes odoo/odoo#51320
X-original-commit: cfb2f00ae2fcbe33184d76383e3b624700101a75
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
| -rw-r--r-- | addons/stock/models/stock_inventory.py | 1 | ||||
| -rw-r--r-- | addons/stock_account/models/stock_inventory.py | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index 08ec874c996..9fa8f655e2a 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -127,6 +127,7 @@ class Inventory(models.Model): # as they will be moved to inventory loss, and other quants will be created to the encoded quant location. This is a normal behavior # as quants cannot be reuse from inventory location (users can still manually move the products before/after the inventory if they want). self.mapped('move_ids').filtered(lambda move: move.state != 'done')._action_done() + return True def action_check(self): """ Checks the inventory and computes the stock move to do """ diff --git a/addons/stock_account/models/stock_inventory.py b/addons/stock_account/models/stock_inventory.py index ce00ed251c5..03522076eae 100644 --- a/addons/stock_account/models/stock_inventory.py +++ b/addons/stock_account/models/stock_inventory.py @@ -35,10 +35,11 @@ class StockInventory(models.Model): return action_data def post_inventory(self): + res = True acc_inventories = self.filtered(lambda inventory: inventory.accounting_date) for inventory in acc_inventories: - super(StockInventory, inventory.with_context(force_period_date=inventory.accounting_date)).post_inventory() + res = super(StockInventory, inventory.with_context(force_period_date=inventory.accounting_date)).post_inventory() other_inventories = self - acc_inventories if other_inventories: - super(StockInventory, other_inventories).post_inventory() - + res = super(StockInventory, other_inventories).post_inventory() + return res |
