From 5e9c858a0497138474ebb5f05bb381f48e210868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Alan=20Ramos=20Rodr=C3=ADguez?= Date: Wed, 12 Feb 2020 19:18:34 -0600 Subject: [PATCH] [MIG] stock_account_operating_unit: Migration to V13 --- .../odoo/addons/stock_account_operating_unit | 1 + setup/stock_account_operating_unit/setup.py | 6 ++++++ stock_account_operating_unit/__manifest__.py | 2 +- stock_account_operating_unit/model/stock_move.py | 12 +++++++----- stock_account_operating_unit/readme/CONTRIBUTORS.rst | 1 + .../tests/test_stock_account_operating_unit.py | 7 +++---- 6 files changed, 19 insertions(+), 10 deletions(-) create mode 120000 setup/stock_account_operating_unit/odoo/addons/stock_account_operating_unit create mode 100644 setup/stock_account_operating_unit/setup.py diff --git a/setup/stock_account_operating_unit/odoo/addons/stock_account_operating_unit b/setup/stock_account_operating_unit/odoo/addons/stock_account_operating_unit new file mode 120000 index 000000000..a9682672d --- /dev/null +++ b/setup/stock_account_operating_unit/odoo/addons/stock_account_operating_unit @@ -0,0 +1 @@ +../../../../stock_account_operating_unit \ No newline at end of file diff --git a/setup/stock_account_operating_unit/setup.py b/setup/stock_account_operating_unit/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_account_operating_unit/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_operating_unit/__manifest__.py b/stock_account_operating_unit/__manifest__.py index d0a45669e..7a0545766 100644 --- a/stock_account_operating_unit/__manifest__.py +++ b/stock_account_operating_unit/__manifest__.py @@ -7,7 +7,7 @@ "name": "Stock account moves with Operating Unit", "summary": "Create journal entries in moves between internal locations " "with different operating units.", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "category": "Generic Modules/Sales & Purchases", "author": "Eficent Business and IT Consulting Services S.L., " "Serpent Consulting Services Pvt. Ltd.," diff --git a/stock_account_operating_unit/model/stock_move.py b/stock_account_operating_unit/model/stock_move.py index 008c235b0..33eb57fc6 100644 --- a/stock_account_operating_unit/model/stock_move.py +++ b/stock_account_operating_unit/model/stock_move.py @@ -2,7 +2,7 @@ # - Jordi Ballester Alomar # © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo import _, api, exceptions, models +from odoo import _, exceptions, models class StockMove(models.Model): @@ -16,6 +16,7 @@ def _generate_valuation_lines_data( credit_value, debit_account_id, credit_account_id, + description, ): res = super(StockMove, self)._generate_valuation_lines_data( partner_id, @@ -24,6 +25,7 @@ def _generate_valuation_lines_data( credit_value, debit_account_id, credit_account_id, + description, ) if res: debit_line_vals = res.get("debit_line_vals") @@ -69,8 +71,7 @@ def _generate_valuation_lines_data( return rslt return res - @api.multi - def _action_done(self): + def _action_done(self, cancel_backorder=False): """ Generate accounting moves if the product being moved is subject to real_time valuation tracking, @@ -78,7 +79,7 @@ def _action_done(self): a transit location or is outside of the company or the source or destination locations belong to different operating units. """ - res = super(StockMove, self)._action_done() + res = super(StockMove, self)._action_done(cancel_backorder) for move in self: if move.product_id.valuation == "real_time": @@ -101,6 +102,7 @@ def _action_done(self): move.product_id.standard_price, acc_valuation, acc_valuation, + _("%s - OU Move") % move.product_id.display_name, ) am = ( self.env["account.move"] @@ -114,7 +116,7 @@ def _action_done(self): "line_ids": move_lines, "company_id": move.company_id.id, "ref": move.picking_id and move.picking_id.name, - "stock_move_id": self.id, + "stock_move_id": move.id, } ) ) diff --git a/stock_account_operating_unit/readme/CONTRIBUTORS.rst b/stock_account_operating_unit/readme/CONTRIBUTORS.rst index 6f2631217..4a40e09b3 100644 --- a/stock_account_operating_unit/readme/CONTRIBUTORS.rst +++ b/stock_account_operating_unit/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Eficent Business and IT Consulting Services S.L. * Serpent Consulting Services Pvt. Ltd. +* Jarsa Sistemas 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 407555b78..1cffa23a2 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 @@ -14,7 +14,6 @@ def setUp(self): self.account_model = self.env["account.account"] self.product_model = self.env["product.product"] self.product_cteg_model = self.env["product.category"] - self.inv_line_model = self.env["account.invoice.line"] self.acc_type_model = self.env["account.account.type"] self.operating_unit_model = self.env["operating.unit"] self.company_model = self.env["res.company"] @@ -147,7 +146,7 @@ def _create_product(self): def _create_picking(self, user, ou_id, picking_type, src_loc_id, dest_loc_id): """Create a Picking.""" - picking = self.picking_model.sudo(user.id).create( + picking = self.picking_model.with_user(user.id).create( { "picking_type_id": picking_type.id, "location_id": src_loc_id.id, @@ -155,7 +154,7 @@ def _create_picking(self, user, ou_id, picking_type, src_loc_id, dest_loc_id): "operating_unit_id": ou_id.id, } ) - self.move_model.sudo(user.id).create( + self.move_model.with_user(user.id).create( { "name": "a move", "product_id": self.product.id, @@ -174,7 +173,7 @@ def _confirm_receive(self, user_id, picking): """ picking.action_confirm() picking.action_assign() - res = picking.sudo(user_id).button_validate() + res = picking.with_user(user_id).button_validate() validate_id = res["res_id"] validate = self.env["stock.immediate.transfer"].browse(validate_id) validate.process()