From 2b4d1cab917163535dbde30ad4d37cdb7aa9e529 Mon Sep 17 00:00:00 2001 From: Rujia Liu Date: Mon, 21 Jun 2021 10:03:42 +1200 Subject: [PATCH] [IMP] improve code to pass initial check --- .../model/stock_move.py | 19 ++++++++----------- .../test_stock_account_operating_unit.py | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/stock_account_operating_unit/model/stock_move.py b/stock_account_operating_unit/model/stock_move.py index a35fc04965..16564c07f0 100644 --- a/stock_account_operating_unit/model/stock_move.py +++ b/stock_account_operating_unit/model/stock_move.py @@ -18,7 +18,7 @@ def _generate_valuation_lines_data( credit_account_id, description, ): - res = super(StockMove, self)._generate_valuation_lines_data( + rslt = super(StockMove, self)._generate_valuation_lines_data( partner_id, qty, debit_value, @@ -27,10 +27,10 @@ def _generate_valuation_lines_data( credit_account_id, description, ) - if res: - debit_line_vals = res.get("debit_line_vals") - credit_line_vals = res.get("credit_line_vals") - price_diff_line_vals = res.get("price_diff_line_vals", {}) + if rslt: + debit_line_vals = rslt.get("debit_line_vals") + credit_line_vals = rslt.get("credit_line_vals") + price_diff_line_vals = rslt.get("price_diff_line_vals", {}) if ( self.operating_unit_id @@ -59,17 +59,14 @@ def _generate_valuation_lines_data( credit_line_vals["operating_unit_id"] = ( ou_id or self.operating_unit_id.id or self.operating_unit_dest_id.id ) - rslt = { - "credit_line_vals": credit_line_vals, - "debit_line_vals": debit_line_vals, - } + rslt["credit_line_vals"] = credit_line_vals + rslt["debit_line_vals"] = debit_line_vals if price_diff_line_vals: price_diff_line_vals["operating_unit_id"] = ( ou_id or self.operating_unit_id.id or self.operating_unit_dest_id.id ) rslt["price_diff_line_vals"] = price_diff_line_vals - return rslt - return res + return rslt def _action_done(self, cancel_backorder=False): """ diff --git a/stock_account_operating_unit/tests/test_stock_account_operating_unit.py b/stock_account_operating_unit/tests/test_stock_account_operating_unit.py index 847e2c545f..1e55fb6278 100644 --- a/stock_account_operating_unit/tests/test_stock_account_operating_unit.py +++ b/stock_account_operating_unit/tests/test_stock_account_operating_unit.py @@ -383,7 +383,7 @@ def test_pickings(self): [("stock_move_id", "=", self.picking.move_lines[0].id)] ) account_move.line_ids.mapped("operating_unit_id") - # Confirm the ou are all the one from picking type's ou + # Confirm the ou is picking type's ou self.assertEqual( account_move.line_ids.mapped("operating_unit_id"), self.picking.picking_type_id.warehouse_id.operating_unit_id,