diff --git a/setup/stock_quant_cost_info/odoo/addons/stock_quant_cost_info b/setup/stock_quant_cost_info/odoo/addons/stock_quant_cost_info new file mode 120000 index 000000000000..e5cf547a2a3b --- /dev/null +++ b/setup/stock_quant_cost_info/odoo/addons/stock_quant_cost_info @@ -0,0 +1 @@ +../../../../stock_quant_cost_info \ No newline at end of file diff --git a/setup/stock_quant_cost_info/setup.py b/setup/stock_quant_cost_info/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/stock_quant_cost_info/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_quant_cost_info/README.rst b/stock_quant_cost_info/README.rst new file mode 100644 index 000000000000..b2a54a1b9d09 --- /dev/null +++ b/stock_quant_cost_info/README.rst @@ -0,0 +1,97 @@ +===================== +Stock Quant Cost Info +===================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_quant_cost_info + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_quant_cost_info + :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-warehouse&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of *Quantity Adjustments* in *Stock Quants* to +show a new column *Adjustment cost* in *Quant Details* list and PDF report table. +The value of *Adjustment cost* will be self-calculated according to: +(`Real Quantity` - `Theoretical Quantity`) * `Product Cost` + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +A pre_init_hook process is initiated in order to set the *Adjustment cost* to +zero in all existing *stock quant* before installation. + +Usage +===== + +To use this module, you need to: + +#. Go to *Inventory > Products > Products* and create or select one. +#. Click on *Update Quantity* button. +#. In *Quant* list you will see a new column named *Adjustment cost*. +#. The cost will be recomputed when we change the *Counted Quantity*. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Ernesto Tejeda + * Pedro M. Baeza + * Sergio Teruel + * Carlos Roca + +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-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_quant_cost_info/__init__.py b/stock_quant_cost_info/__init__.py new file mode 100644 index 000000000000..68b72dd03222 --- /dev/null +++ b/stock_quant_cost_info/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models +from .hooks import pre_init_hook diff --git a/stock_quant_cost_info/__manifest__.py b/stock_quant_cost_info/__manifest__.py new file mode 100644 index 000000000000..bf50130f234a --- /dev/null +++ b/stock_quant_cost_info/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2019 Tecnativa - Ernesto Tejeda +# Copyright 2019 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Stock Quant Cost Info", + "summary": "Shows the cost of the quants", + "version": "15.0.1.0.0", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse", + "depends": ["stock"], + "data": ["views/stock_inventory_views.xml", "views/report_stockinventory.xml"], + "pre_init_hook": "pre_init_hook", + "license": "AGPL-3", + "installable": True, + "application": False, +} diff --git a/stock_quant_cost_info/hooks.py b/stock_quant_cost_info/hooks.py new file mode 100644 index 000000000000..5682ca7ed486 --- /dev/null +++ b/stock_quant_cost_info/hooks.py @@ -0,0 +1,15 @@ +# Copyright 2019 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + + +def pre_init_hook(cr): + cr.execute( + """ALTER TABLE stock_quant + ADD COLUMN adjustment_cost numeric + DEFAULT 0""" + ) + + cr.execute( + """ALTER TABLE stock_quant + ALTER COLUMN adjustment_cost DROP DEFAULT;""" + ) diff --git a/stock_quant_cost_info/i18n/es.po b/stock_quant_cost_info/i18n/es.po new file mode 100644 index 000000000000..b3e9d2301ae5 --- /dev/null +++ b/stock_quant_cost_info/i18n/es.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_cost_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-01-16 09:20+0000\n" +"PO-Revision-Date: 2023-01-16 10:21+0100\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 3.2.2\n" + +#. module: stock_quant_cost_info +#: model_terms:ir.ui.view,arch_db:stock_quant_cost_info.report_inventory_cost_info +msgid "Adjustment cost" +msgstr "Coste de ajuste" + +#. module: stock_quant_cost_info +#: model:ir.model.fields,field_description:stock_quant_cost_info.field_stock_quant__adjustment_cost +msgid "Adjustment cost" +msgstr "Coste de ajuste" + +#. module: stock_quant_cost_info +#: model:ir.model.fields,field_description:stock_quant_cost_info.field_stock_quant__currency_id +msgid "Currency" +msgstr "Moneda" + +#. module: stock_quant_cost_info +#: model:ir.model,name:stock_quant_cost_info.model_stock_quant +msgid "Quants" +msgstr "Quants" + +#. module: stock_quant_cost_info +#: model_terms:ir.ui.view,arch_db:stock_quant_cost_info.view_stock_quant_tree_inventory_editable +msgid "Total" +msgstr "Total" + +#~ msgid "Inventory Line" +#~ msgstr "LĂ­nea de inventario" diff --git a/stock_quant_cost_info/i18n/stock_quant_cost_info.pot b/stock_quant_cost_info/i18n/stock_quant_cost_info.pot new file mode 100644 index 000000000000..e186935adc63 --- /dev/null +++ b/stock_quant_cost_info/i18n/stock_quant_cost_info.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quant_cost_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-01-16 09:20+0000\n" +"PO-Revision-Date: 2023-01-16 09:20+0000\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_quant_cost_info +#: model_terms:ir.ui.view,arch_db:stock_quant_cost_info.report_inventory_cost_info +msgid "Adjustment cost" +msgstr "" + +#. module: stock_quant_cost_info +#: model:ir.model.fields,field_description:stock_quant_cost_info.field_stock_quant__adjustment_cost +msgid "Adjustment cost" +msgstr "" + +#. module: stock_quant_cost_info +#: model:ir.model.fields,field_description:stock_quant_cost_info.field_stock_quant__currency_id +msgid "Currency" +msgstr "" + +#. module: stock_quant_cost_info +#: model:ir.model,name:stock_quant_cost_info.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_quant_cost_info +#: model_terms:ir.ui.view,arch_db:stock_quant_cost_info.view_stock_quant_tree_inventory_editable +msgid "Total" +msgstr "" diff --git a/stock_quant_cost_info/models/__init__.py b/stock_quant_cost_info/models/__init__.py new file mode 100644 index 000000000000..2b7b6c8b8b62 --- /dev/null +++ b/stock_quant_cost_info/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import stock_quant diff --git a/stock_quant_cost_info/models/stock_quant.py b/stock_quant_cost_info/models/stock_quant.py new file mode 100644 index 000000000000..3a2b1b906ecc --- /dev/null +++ b/stock_quant_cost_info/models/stock_quant.py @@ -0,0 +1,24 @@ +# Copyright 2019 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + currency_id = fields.Many2one( + comodel_name="res.currency", string="Currency", related="company_id.currency_id" + ) + adjustment_cost = fields.Monetary( + string="Adjustment cost", compute="_compute_adjustment_cost", store=True + ) + + @api.depends("inventory_diff_quantity", "product_id.standard_price") + def _compute_adjustment_cost(self): + for record in self: + record.adjustment_cost = False + if record.inventory_diff_quantity: + record.adjustment_cost = ( + record.inventory_diff_quantity * record.product_id.standard_price + ) diff --git a/stock_quant_cost_info/readme/CONTRIBUTORS.rst b/stock_quant_cost_info/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..21e014c78896 --- /dev/null +++ b/stock_quant_cost_info/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* `Tecnativa `_: + + * Ernesto Tejeda + * Pedro M. Baeza + * Sergio Teruel + * Carlos Roca diff --git a/stock_quant_cost_info/readme/DESCRIPTION.rst b/stock_quant_cost_info/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..6f3edd768220 --- /dev/null +++ b/stock_quant_cost_info/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module extends the functionality of *Quantity Adjustments* in *Stock Quants* to +show a new column *Adjustment cost* in *Quant Details* list and PDF report table. +The value of *Adjustment cost* will be self-calculated according to: +(`Real Quantity` - `Theoretical Quantity`) * `Product Cost` diff --git a/stock_quant_cost_info/readme/INSTALL.rst b/stock_quant_cost_info/readme/INSTALL.rst new file mode 100644 index 000000000000..a57fc8dcc905 --- /dev/null +++ b/stock_quant_cost_info/readme/INSTALL.rst @@ -0,0 +1,2 @@ +A pre_init_hook process is initiated in order to set the *Adjustment cost* to +zero in all existing *stock quant* before installation. diff --git a/stock_quant_cost_info/readme/USAGE.rst b/stock_quant_cost_info/readme/USAGE.rst new file mode 100644 index 000000000000..763db187326c --- /dev/null +++ b/stock_quant_cost_info/readme/USAGE.rst @@ -0,0 +1,6 @@ +To use this module, you need to: + +#. Go to *Inventory > Products > Products* and create or select one. +#. Click on *Update Quantity* button. +#. In *Quant* list you will see a new column named *Adjustment cost*. +#. The cost will be recomputed when we change the *Counted Quantity*. diff --git a/stock_quant_cost_info/static/description/icon.png b/stock_quant_cost_info/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_quant_cost_info/static/description/icon.png differ diff --git a/stock_quant_cost_info/static/description/index.html b/stock_quant_cost_info/static/description/index.html new file mode 100644 index 000000000000..c4b69dfeeac2 --- /dev/null +++ b/stock_quant_cost_info/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +Stock Quant Cost Info + + + +
+

Stock Quant Cost Info

+ + +

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

+

This module extends the functionality of Quantity Adjustments in Stock Quants to +show a new column Adjustment cost in Quant Details list and PDF report table. +The value of Adjustment cost will be self-calculated according to: +(Real Quantity - Theoretical Quantity) * Product Cost

+

Table of contents

+ +
+

Installation

+

A pre_init_hook process is initiated in order to set the Adjustment cost to +zero in all existing stock quant before installation.

+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Inventory > Products > Products and create or select one.
  2. +
  3. Click on Update Quantity button.
  4. +
  5. In Quant list you will see a new column named Adjustment cost.
  6. +
  7. The cost will be recomputed when we change the Counted Quantity.
  8. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Ernesto Tejeda
    • +
    • Pedro M. Baeza
    • +
    • Sergio Teruel
    • +
    • Carlos Roca
    • +
    +
  • +
+
+
+

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-warehouse project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_quant_cost_info/tests/__init__.py b/stock_quant_cost_info/tests/__init__.py new file mode 100644 index 000000000000..69414abc7657 --- /dev/null +++ b/stock_quant_cost_info/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_stock_quant_cost_info diff --git a/stock_quant_cost_info/tests/test_stock_quant_cost_info.py b/stock_quant_cost_info/tests/test_stock_quant_cost_info.py new file mode 100644 index 000000000000..cf8dbe129fff --- /dev/null +++ b/stock_quant_cost_info/tests/test_stock_quant_cost_info.py @@ -0,0 +1,37 @@ +# Copyright 2019 Tecnativa - Ernesto Tejeda +# Copyright 2019 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestStockQuantCostInfo(TransactionCase): + def setUp(self): + super().setUp() + product_obj = self.env["product.product"] + self.product_1 = product_obj.create( + {"name": "product test 1", "type": "product", "standard_price": 1000} + ) + self.product_2 = product_obj.create( + {"name": "product test 2", "type": "product", "standard_price": 2000} + ) + + def test_compute_adjustment_cost(self): + """Tests if the adjustment_cost is correctly computed.""" + quant_prod_1 = self.env["stock.quant"].create( + { + "product_id": self.product_1.id, + "location_id": self.env.ref("stock.stock_location_stock").id, + "inventory_quantity": 10.0, + } + ) + self.assertEqual(quant_prod_1.adjustment_cost, 10000) + quant_prod_2 = self.env["stock.quant"].create( + { + "product_id": self.product_2.id, + "location_id": self.env.ref("stock.stock_location_stock").id, + "inventory_quantity": 20.0, + } + ) + self.assertEqual(quant_prod_2.adjustment_cost, 40000) diff --git a/stock_quant_cost_info/views/report_stockinventory.xml b/stock_quant_cost_info/views/report_stockinventory.xml new file mode 100644 index 000000000000..ccbbc3b8ae3b --- /dev/null +++ b/stock_quant_cost_info/views/report_stockinventory.xml @@ -0,0 +1,21 @@ + + + + diff --git a/stock_quant_cost_info/views/stock_inventory_views.xml b/stock_quant_cost_info/views/stock_inventory_views.xml new file mode 100644 index 000000000000..4a8cd0abb4f5 --- /dev/null +++ b/stock_quant_cost_info/views/stock_inventory_views.xml @@ -0,0 +1,13 @@ + + + + stock.quant + + + + + + + + +