diff --git a/setup/stock_account_valuation_discrepancy_adjust/odoo/addons/stock_account_valuation_discrepancy_adjust b/setup/stock_account_valuation_discrepancy_adjust/odoo/addons/stock_account_valuation_discrepancy_adjust new file mode 120000 index 000000000..623094bdd --- /dev/null +++ b/setup/stock_account_valuation_discrepancy_adjust/odoo/addons/stock_account_valuation_discrepancy_adjust @@ -0,0 +1 @@ +../../../../stock_account_valuation_discrepancy_adjust \ No newline at end of file diff --git a/setup/stock_account_valuation_discrepancy_adjust/setup.py b/setup/stock_account_valuation_discrepancy_adjust/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_account_valuation_discrepancy_adjust/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_account_valuation_discrepancy_adjust/README.rst b/stock_account_valuation_discrepancy_adjust/README.rst new file mode 100644 index 000000000..5e4d85b4f --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/README.rst @@ -0,0 +1,96 @@ +==================================== +Account Valuation Discrepancy Adjust +==================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:dd2d6fb4bffb4420e86213ebd3c3d2887293fb56a54b1f64dc428cde4ba31092 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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/16.0/stock_account_valuation_discrepancy_adjust + :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-16-0/stock-logistics-reporting-16-0-stock_account_valuation_discrepancy_adjust + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-reporting&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Wizard to show discrepancies between stock and accounting valuation, and possibility to make accounting adjustment. + +You should use this module if you have products where the inventory valuation is automated (this means that your inventory is connected with accounting). The report allows you to identify the products where the inventory value has a discrepancy with the accounting value for that same product, and to make an adjustment entry in your accounting to align the two values. + +This module adds an action the report in *Inventory / Reporting / Dual Inventory Valuation*. The action is accesible for Account Managers. + +The action allows to create accounting entries by product in order to match the accounting value to the stock value. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Christopher Ormaza +* Aaron Henriquez + +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. + +.. |maintainer-ChrisOForgeFlow| image:: https://github.com/ChrisOForgeFlow.png?size=40px + :target: https://github.com/ChrisOForgeFlow + :alt: ChrisOForgeFlow + +Current `maintainer `__: + +|maintainer-ChrisOForgeFlow| + +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_valuation_discrepancy_adjust/__init__.py b/stock_account_valuation_discrepancy_adjust/__init__.py new file mode 100644 index 000000000..283b87bc0 --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import wizards diff --git a/stock_account_valuation_discrepancy_adjust/__manifest__.py b/stock_account_valuation_discrepancy_adjust/__manifest__.py new file mode 100644 index 000000000..20d04300a --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2021 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Account Valuation Discrepancy Adjust", + "version": "16.0.1.0.0", + "summary": "Implements Wizard for Adjust " + "Discrepancies on Account Inventory Valuation", + "category": "Warehouse Management", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-reporting", + "license": "AGPL-3", + "depends": ["stock_account_valuation_report"], + "data": [ + "security/ir.model.access.csv", + "wizards/wizard_stock_discrepancy_adjustment_view.xml", + ], + "demo": [], + "installable": True, + "development_status": "Alpha", + "maintainers": ["ChrisOForgeFlow"], +} diff --git a/stock_account_valuation_discrepancy_adjust/i18n/stock_account_valuation_discrepancy_adjust.pot b/stock_account_valuation_discrepancy_adjust/i18n/stock_account_valuation_discrepancy_adjust.pot new file mode 100644 index 000000000..e69de29bb diff --git a/stock_account_valuation_discrepancy_adjust/readme/CONTRIBUTORS.rst b/stock_account_valuation_discrepancy_adjust/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..dabecf981 --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Christopher Ormaza +* Aaron Henriquez diff --git a/stock_account_valuation_discrepancy_adjust/readme/DESCRIPTION.rst b/stock_account_valuation_discrepancy_adjust/readme/DESCRIPTION.rst new file mode 100644 index 000000000..4849ddc6c --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +Wizard to show discrepancies between stock and accounting valuation, and possibility to make accounting adjustment. + +You should use this module if you have products where the inventory valuation is automated (this means that your inventory is connected with accounting). The report allows you to identify the products where the inventory value has a discrepancy with the accounting value for that same product, and to make an adjustment entry in your accounting to align the two values. + +This module adds an action the report in *Inventory / Reporting / Dual Inventory Valuation*. The action is accesible for Account Managers. + +The action allows to create accounting entries by product in order to match the accounting value to the stock value. diff --git a/stock_account_valuation_discrepancy_adjust/security/ir.model.access.csv b/stock_account_valuation_discrepancy_adjust/security/ir.model.access.csv new file mode 100644 index 000000000..178682de7 --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_wizard_stock_discrepancy_adjustment,access_wizard_stock_discrepancy_adjustment,model_wizard_stock_discrepancy_adjustment,account.group_account_manager,1,1,1,1 +access_wizard_stock_discrepancy_adjustment_line,access_wizard_stock_discrepancy_adjustment_line,model_wizard_stock_discrepancy_adjustment_line,account.group_account_manager,1,1,1,1 diff --git a/stock_account_valuation_discrepancy_adjust/static/description/icon.png b/stock_account_valuation_discrepancy_adjust/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_account_valuation_discrepancy_adjust/static/description/icon.png differ diff --git a/stock_account_valuation_discrepancy_adjust/static/description/index.html b/stock_account_valuation_discrepancy_adjust/static/description/index.html new file mode 100644 index 000000000..676580b15 --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Account Valuation Discrepancy Adjust + + + +
+

Account Valuation Discrepancy Adjust

+ + +

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

+

Wizard to show discrepancies between stock and accounting valuation, and possibility to make accounting adjustment.

+

You should use this module if you have products where the inventory valuation is automated (this means that your inventory is connected with accounting). The report allows you to identify the products where the inventory value has a discrepancy with the accounting value for that same product, and to make an adjustment entry in your accounting to align the two values.

+

This module adds an action the report in Inventory / Reporting / Dual Inventory Valuation. The action is accesible for Account Managers.

+

The action allows to create accounting entries by product in order to match the accounting value to the stock value.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

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.

+

Current maintainer:

+

ChrisOForgeFlow

+

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_valuation_discrepancy_adjust/tests/__init__.py b/stock_account_valuation_discrepancy_adjust/tests/__init__.py new file mode 100644 index 000000000..86eba7009 --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_account_valuation_discrepancy_adjust diff --git a/stock_account_valuation_discrepancy_adjust/tests/test_stock_account_valuation_discrepancy_adjust.py b/stock_account_valuation_discrepancy_adjust/tests/test_stock_account_valuation_discrepancy_adjust.py new file mode 100644 index 000000000..53b3e0376 --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/tests/test_stock_account_valuation_discrepancy_adjust.py @@ -0,0 +1,196 @@ +# Copyright 2024 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import time + +from odoo import fields +from odoo.tests.common import TransactionCase + + +class TestStockAccountValuationDiscrepancy(TransactionCase): + def setUp(self): + super(TestStockAccountValuationDiscrepancy, self).setUp() + # Get required Model + self.product_model = self.env["product.product"] + self.template_model = self.env["product.template"] + self.product_ctg_model = self.env["product.category"] + self.account_model = self.env["account.account"] + self.stock_quant_model = self.env["stock.quant"] + self.stock_location_model = self.env["stock.location"] + self.account_move_model = self.env["account.move"] + self.account_move_line_model = self.env["account.move.line"] + # Get required Model data + self.company = self.env.ref("base.main_company") + + location = self.stock_location_model.search([("name", "=", "WH")]) + self.location = self.stock_location_model.search( + [("location_id", "=", location.id)] + ) + + # Account types + self.stock_journal = self.env["account.journal"].create( + {"name": "Stock journal", "type": "general", "code": "STK00"} + ) + + expense_type = "expense" + equity_type = "equity" + asset_type = "asset_current" + + # Create account for Goods Received Not Invoiced + name = "Goods Received Not Invoiced" + code = "grni" + self.account_grni = self._create_account(equity_type, name, code, self.company) + # Create account for Cost of Goods Sold + name = "Cost of Goods Sold" + code = "cogs" + self.account_cogs = self._create_account(expense_type, name, code, self.company) + + # Create account for Inventory + name = "Inventory" + code = "inventory" + acc_type = asset_type + self.account_inventory = self._create_account( + acc_type, name, code, self.company + ) + name = "Goods Delivered Not Invoiced" + code = "gdni" + self.account_gdni = self._create_account(asset_type, name, code, self.company) + # Create product category + self.product_ctg = self._create_product_category() + # Create a Product with fifo cost + standard_price = 10.0 + list_price = 20.0 + self.product_fifo_1 = self._create_product(standard_price, False, list_price) + # Add default quantity + quantity = 10.00 + self._update_product_qty(self.product_fifo_1, self.location, quantity) + + # Default journal + journals = self.env["account.journal"].search([("type", "=", "general")]) + self.journal = journals[0] + + # Create a journal entry + self.move = self._create_account_move(50) + self.move.action_post() + + def _create_account(self, acc_type, name, code, company): + """Create an account.""" + account = self.account_model.create( + { + "name": name, + "code": code, + "account_type": acc_type, + "company_id": company.id, + } + ) + return account + + def _create_product_category(self): + product_ctg = self.product_ctg_model.create( + { + "name": "test_product_ctg", + "property_stock_valuation_account_id": self.account_inventory.id, + "property_stock_account_input_categ_id": self.account_grni.id, + "property_account_expense_categ_id": self.account_cogs.id, + "property_stock_account_output_categ_id": self.account_gdni.id, + "property_valuation": "real_time", + "property_cost_method": "fifo", + "property_stock_journal": self.stock_journal.id, + } + ) + return product_ctg + + def _create_product(self, standard_price, template, list_price): + """Create a Product variant.""" + if not template: + template = self.template_model.create( + { + "name": "test_product", + "categ_id": self.product_ctg.id, + "type": "product", + "standard_price": standard_price, + "valuation": "real_time", + } + ) + return template.product_variant_ids[0] + product = self.product_model.create( + {"product_tmpl_id": template.id, "list_price": list_price} + ) + return product + + def _update_product_qty(self, product, location, quantity): + """Update Product quantity.""" + quant = self.stock_quant_model.create( + { + "location_id": location.id, + "product_id": product.id, + "inventory_quantity": quantity, + } + ) + quant._apply_inventory() + + def _create_account_move(self, amount): + date_move = fields.Date.today() + + debit_data = [ + ( + 0, + 0, + { + "name": self.product_fifo_1.name, + "date": date_move, + "product_id": self.product_fifo_1.id, + "account_id": self.account_inventory.id, + "debit": amount, + }, + ) + ] + credit_data = [ + ( + 0, + 0, + { + "name": self.product_fifo_1.name, + "date": date_move, + "product_id": self.product_fifo_1.id, + "account_id": self.account_cogs.id, + "credit": amount, + }, + ) + ] + line_data = debit_data + credit_data + move = self.account_move_model.create( + { + "date": time.strftime("%Y-%m-%d"), + "ref": "Sample", + "journal_id": self.journal.id, + "line_ids": line_data, + } + ) + return move + + def test_01_manual_adjustment(self): + """Test the accounting value after applying the adjustment""" + self.product_fifo_1._compute_inventory_value() + self.assertEqual(self.product_fifo_1.stock_value, 100.0) + self.assertEqual(self.product_fifo_1.account_value, 150.0) + self.assertEqual(self.product_fifo_1.valuation_discrepancy, -50.0) + + wiz = ( + self.env["wizard.stock.discrepancy.adjustment"] + .with_context( + active_model="product.product", + active_ids=[self.product_fifo_1.id], + active_id=self.product_fifo_1.id, + ) + .create( + { + "increase_account_id": self.account_cogs.id, + "decrease_account_id": self.account_cogs.id, + "journal_id": self.journal.id, + } + ) + ) + wiz.with_context(no_delay=True).action_create_adjustment() + self.product_fifo_1._compute_inventory_value() + self.assertEqual(self.product_fifo_1.valuation_discrepancy, 0.0) diff --git a/stock_account_valuation_discrepancy_adjust/views/product_discrepancy_view.xml b/stock_account_valuation_discrepancy_adjust/views/product_discrepancy_view.xml new file mode 100644 index 000000000..2d2e62d37 --- /dev/null +++ b/stock_account_valuation_discrepancy_adjust/views/product_discrepancy_view.xml @@ -0,0 +1,61 @@ + + + + + + product_discrepancy_view_tree + product.discrepancy + + + + + + + + + + + +