diff --git a/setup/stock_account_quantity_history_location/odoo/addons/stock_account_quantity_history_location b/setup/stock_account_quantity_history_location/odoo/addons/stock_account_quantity_history_location new file mode 120000 index 0000000..c405a0f --- /dev/null +++ b/setup/stock_account_quantity_history_location/odoo/addons/stock_account_quantity_history_location @@ -0,0 +1 @@ +../../../../stock_account_quantity_history_location \ No newline at end of file diff --git a/setup/stock_account_quantity_history_location/setup.py b/setup/stock_account_quantity_history_location/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/stock_account_quantity_history_location/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_quantity_history_location/README.rst b/stock_account_quantity_history_location/README.rst new file mode 100644 index 0000000..6fff688 --- /dev/null +++ b/stock_account_quantity_history_location/README.rst @@ -0,0 +1,85 @@ +======================================= +Stock Account Quantity History Location +======================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-reporting/tree/15.0/stock_account_quantity_history_location + :alt: OCA/stock-logistics-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-15-0/stock-logistics-reporting-15-0-stock_account_quantity_history_location + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/stock-logistics-reporting&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module between Stock Account and Stock Quantity History Location modules. + +Display a warning on the Stock Inventory report that accounting valuation is +not calculated when you specify a location. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Eficent + +Contributors +~~~~~~~~~~~~ + +* Jordi Ballester Alomar + +* `Tecnativa `_: + + * Víctor Martínez + * Ernesto Tejeda + +* `Sodexis `_: + + * Atchuthan Ubendran + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/stock-logistics-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_account_quantity_history_location/__init__.py b/stock_account_quantity_history_location/__init__.py new file mode 100644 index 0000000..5cb1c49 --- /dev/null +++ b/stock_account_quantity_history_location/__init__.py @@ -0,0 +1 @@ +from . import wizards diff --git a/stock_account_quantity_history_location/__manifest__.py b/stock_account_quantity_history_location/__manifest__.py new file mode 100644 index 0000000..e1ac21d --- /dev/null +++ b/stock_account_quantity_history_location/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# Copyright 2019 Aleph Objects, Inc. +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Account Quantity History Location", + "summary": """ + Glue module between Stock Account and Stock Quantity History Location + modules""", + "version": "15.0.1.0.0", + "license": "AGPL-3", + "author": "Eficent, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-reporting", + "depends": ["stock_account", "stock_quantity_history_location"], + "auto_install": True, +} diff --git a/stock_account_quantity_history_location/i18n/fr.po b/stock_account_quantity_history_location/i18n/fr.po new file mode 100644 index 0000000..b90c7e6 --- /dev/null +++ b/stock_account_quantity_history_location/i18n/fr.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quantity_history_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-01-22 15:46+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: stock_account_quantity_history_location +#: model:ir.model,name:stock_account_quantity_history_location.model_stock_quantity_history +msgid "Stock Quantity History" +msgstr "Historique des quantités en stock" diff --git a/stock_account_quantity_history_location/i18n/stock_account_quantity_history_location.pot b/stock_account_quantity_history_location/i18n/stock_account_quantity_history_location.pot new file mode 100644 index 0000000..56edca5 --- /dev/null +++ b/stock_account_quantity_history_location/i18n/stock_account_quantity_history_location.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quantity_history_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_account_quantity_history_location +#: model:ir.model.fields,field_description:stock_account_quantity_history_location.field_stock_quantity_history__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_account_quantity_history_location +#: model:ir.model.fields,field_description:stock_account_quantity_history_location.field_stock_quantity_history__id +msgid "ID" +msgstr "" + +#. module: stock_account_quantity_history_location +#: model:ir.model.fields,field_description:stock_account_quantity_history_location.field_stock_quantity_history____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_account_quantity_history_location +#: model:ir.model,name:stock_account_quantity_history_location.model_stock_quantity_history +msgid "Stock Quantity History" +msgstr "" diff --git a/stock_account_quantity_history_location/readme/CONTRIBUTORS.rst b/stock_account_quantity_history_location/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..cca6e78 --- /dev/null +++ b/stock_account_quantity_history_location/readme/CONTRIBUTORS.rst @@ -0,0 +1,10 @@ +* Jordi Ballester Alomar + +* `Tecnativa `_: + + * Víctor Martínez + * Ernesto Tejeda + +* `Sodexis `_: + + * Atchuthan Ubendran diff --git a/stock_account_quantity_history_location/readme/DESCRIPTION.rst b/stock_account_quantity_history_location/readme/DESCRIPTION.rst new file mode 100644 index 0000000..85b2005 --- /dev/null +++ b/stock_account_quantity_history_location/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +Glue module between Stock Account and Stock Quantity History Location modules. + +Display a warning on the Stock Inventory report that accounting valuation is +not calculated when you specify a location. diff --git a/stock_account_quantity_history_location/static/description/icon.png b/stock_account_quantity_history_location/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/stock_account_quantity_history_location/static/description/icon.png differ diff --git a/stock_account_quantity_history_location/static/description/index.html b/stock_account_quantity_history_location/static/description/index.html new file mode 100644 index 0000000..1c3e2d1 --- /dev/null +++ b/stock_account_quantity_history_location/static/description/index.html @@ -0,0 +1,430 @@ + + + + + + +Stock Account Quantity History Location + + + +
+

Stock Account Quantity History Location

+ + +

Beta License: AGPL-3 OCA/stock-logistics-reporting Translate me on Weblate Try me on Runboat

+

Glue module between Stock Account and Stock Quantity History Location modules.

+

Display a warning on the Stock Inventory report that accounting valuation is +not calculated when you specify a location.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Eficent
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/stock-logistics-reporting project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_account_quantity_history_location/tests/__init__.py b/stock_account_quantity_history_location/tests/__init__.py new file mode 100644 index 0000000..0118859 --- /dev/null +++ b/stock_account_quantity_history_location/tests/__init__.py @@ -0,0 +1 @@ +from . import test_valuation_location diff --git a/stock_account_quantity_history_location/tests/test_valuation_location.py b/stock_account_quantity_history_location/tests/test_valuation_location.py new file mode 100644 index 0000000..c0750ef --- /dev/null +++ b/stock_account_quantity_history_location/tests/test_valuation_location.py @@ -0,0 +1,100 @@ +# Copyright 2020 Tecnativa - David Vidal +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from datetime import datetime + +from odoo.addons.stock_quantity_history_location.tests import ( + test_stock_quantity_history_location, +) + + +class TestValuationLocation( + test_stock_quantity_history_location.TestStockQuantityHistoryLocation +): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.sqh_model = cls.env["stock.quantity.history"] + cls.sqh_model_svl = cls.env["stock.quantity.history"].with_context( + active_model="stock.valuation.layer" + ) + + def _create_stock_move(self, location_dest_id, qty): + move = self.env["stock.move"].create( + { + "name": "Stock move in", + "location_id": self.supplier_location.id, + "location_dest_id": location_dest_id.id, + "product_id": self.product.id, + "product_uom": self.product.uom_id.id, + "product_uom_qty": qty, + } + ) + move._action_confirm() + move._action_assign() + move_line = move.move_line_ids[0] + move_line.qty_done = qty + move._action_done() + return move + + def test_stock_location_valuation(self): + wizard = self.sqh_model.create( + { + "location_id": self.test_stock_loc.id, + "include_child_locations": True, + "inventory_datetime": datetime.today(), + } + ) + action = wizard.with_context(company_owned=True).open_at_date() + qty_svl_prev = self.product.with_context(**action["context"]).quantity_svl + move = self._create_stock_move(location_dest_id=self.test_stock_loc, qty=60) + wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date + action = wizard.with_context(company_owned=True).open_at_date() + product = self.product.with_context(**action["context"]) + self.assertEqual(product.quantity_svl - qty_svl_prev, 60) + + def test_stock_location_valuation_without_location_id(self): + wizard = self.sqh_model.create( + {"include_child_locations": True, "inventory_datetime": datetime.today()} + ) + action = wizard.with_context(company_owned=True, valuation=True).open_at_date() + qty_svl_prev = self.product.with_context(**action["context"]).quantity_svl + self._create_stock_move(location_dest_id=self.test_stock_loc, qty=50) + move = self._create_stock_move( + location_dest_id=self.child_test_stock_loc, qty=10 + ) + wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date + action = wizard.with_context(company_owned=True).open_at_date() + product = self.product.with_context(**action["context"]) + self.assertEqual(product.quantity_svl - qty_svl_prev, 60) + + def test_stock_location_valuation_with_svl(self): + wizard = self.sqh_model_svl.create( + { + "location_id": self.test_stock_loc.id, + "include_child_locations": True, + "inventory_datetime": datetime.today(), + } + ) + action = wizard.with_context(company_owned=True).open_at_date() + records_prev = self.env[action["res_model"]].search(action["domain"]) + move = self._create_stock_move(location_dest_id=self.test_stock_loc, qty=100) + wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date + action = wizard.with_context(company_owned=True).open_at_date() + records = self.env[action["res_model"]].search(action["domain"]) - records_prev + self.assertEqual(sum(records.mapped("quantity")), 100) + + def test_stock_location_valuation_with_svl_without_location_id(self): + wizard = self.sqh_model_svl.create( + {"include_child_locations": True, "inventory_datetime": datetime.today()} + ) + action = wizard.with_context(company_owned=True).open_at_date() + records_prev = self.env[action["res_model"]].search(action["domain"]) + self._create_stock_move(location_dest_id=self.test_stock_loc, qty=100) + move = self._create_stock_move( + location_dest_id=self.child_test_stock_loc, qty=100 + ) + wizard["inventory_datetime"] = move.stock_valuation_layer_ids.create_date + action = wizard.with_context(company_owned=True).open_at_date() + records = self.env[action["res_model"]].search(action["domain"]) - records_prev + self.assertEqual(sum(records.mapped("quantity")), 200) diff --git a/stock_account_quantity_history_location/wizards/__init__.py b/stock_account_quantity_history_location/wizards/__init__.py new file mode 100644 index 0000000..51f2abb --- /dev/null +++ b/stock_account_quantity_history_location/wizards/__init__.py @@ -0,0 +1 @@ +from . import stock_quantity_history diff --git a/stock_account_quantity_history_location/wizards/stock_quantity_history.py b/stock_account_quantity_history_location/wizards/stock_quantity_history.py new file mode 100644 index 0000000..7ef0436 --- /dev/null +++ b/stock_account_quantity_history_location/wizards/stock_quantity_history.py @@ -0,0 +1,41 @@ +# Copyright 2019 Eficent Business and IT Consulting Services, S.L. +# Copyright 2019 Aleph Objects, Inc. +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models +from odoo.osv import expression + + +class StockQuantityHistory(models.TransientModel): + _inherit = "stock.quantity.history" + + def open_at_date(self): + action = super().open_at_date() + if ( + self.location_id + and self.env.context.get("active_model") == "stock.valuation.layer" + ): + operator = "child_of" if self.include_child_locations else "=" + action["domain"] = expression.AND( + [ + action["domain"], + [ + "|", + ( + "stock_move_id.location_dest_id", + operator, + self.location_id.id, + ), + ( + "stock_move_id.location_id", + operator, + self.location_id.id, + ), + ], + ] + ) + action[ + "display_name" + ] = f"{self.location_id.complete_name} - {action['display_name']}" + return action