diff --git a/setup/stock_inventory_cost_info/odoo/addons/stock_inventory_cost_info b/setup/stock_inventory_cost_info/odoo/addons/stock_inventory_cost_info deleted file mode 120000 index ee4ff970c4a8..000000000000 --- a/setup/stock_inventory_cost_info/odoo/addons/stock_inventory_cost_info +++ /dev/null @@ -1 +0,0 @@ -../../../../stock_inventory_cost_info \ No newline at end of file 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_inventory_cost_info/setup.py b/setup/stock_quant_cost_info/setup.py similarity index 100% rename from setup/stock_inventory_cost_info/setup.py rename to setup/stock_quant_cost_info/setup.py diff --git a/stock_quant_cost_info/README.rst b/stock_quant_cost_info/README.rst index 1cb5619918f2..b2a54a1b9d09 100644 --- a/stock_quant_cost_info/README.rst +++ b/stock_quant_cost_info/README.rst @@ -1,6 +1,6 @@ -========================= -Stock Inventory Cost Info -========================= +===================== +Stock Quant Cost Info +===================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! @@ -14,20 +14,20 @@ Stock Inventory Cost Info :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/14.0/stock_inventory_cost_info + :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-14-0/stock-logistics-warehouse-14-0-stock_inventory_cost_info + :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/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/153/14.0 - :alt: Try me on Runbot +.. |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 *Inventory Adjustments* to show a new -column *Adjustment cost* in *Inventory Details* list and PDF report table. The -value of *Adjustment cost* will be self-calculated according to: +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** @@ -39,18 +39,17 @@ Installation ============ A pre_init_hook process is initiated in order to set the *Adjustment cost* to -zero in all existing *inventory adjustment* before installation. +zero in all existing *stock quant* before installation. Usage ===== To use this module, you need to: -#. Go to *Inventory > Operations > Inventory Adjustments* and create a new one. -#. Click on *Start Inventory* button. -#. In *Inventory Details* list you will see a new column named - *Adjustment cost*. -#. The cost will be recomputed when the inventory adjustment is validated. +#. 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 =========== @@ -58,7 +57,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -78,6 +77,7 @@ Contributors * Ernesto Tejeda * Pedro M. Baeza * Sergio Teruel + * Carlos Roca Maintainers ~~~~~~~~~~~ @@ -92,6 +92,6 @@ 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. +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/__manifest__.py b/stock_quant_cost_info/__manifest__.py index 08574016141f..bf50130f234a 100644 --- a/stock_quant_cost_info/__manifest__.py +++ b/stock_quant_cost_info/__manifest__.py @@ -2,9 +2,9 @@ # Copyright 2019 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { - "name": "Stock Inventory Cost Info", - "summary": "Shows the cost of the inventory adjustments", - "version": "14.0.1.0.0", + "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", diff --git a/stock_quant_cost_info/hooks.py b/stock_quant_cost_info/hooks.py index 2811ac8e85ba..5682ca7ed486 100644 --- a/stock_quant_cost_info/hooks.py +++ b/stock_quant_cost_info/hooks.py @@ -4,12 +4,12 @@ def pre_init_hook(cr): cr.execute( - """ALTER TABLE stock_inventory_line + """ALTER TABLE stock_quant ADD COLUMN adjustment_cost numeric DEFAULT 0""" ) cr.execute( - """ALTER TABLE stock_inventory_line + """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 index 20a65e264045..b3e9d2301ae5 100644 --- a/stock_quant_cost_info/i18n/es.po +++ b/stock_quant_cost_info/i18n/es.po @@ -6,38 +6,41 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 18:15+0000\n" -"PO-Revision-Date: 2019-07-19 18:15+0000\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: \n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" +"X-Generator: Poedit 3.2.2\n" -#. module: stock_inventory_cost_info -#: model_terms:ir.ui.view,arch_db:stock_inventory_cost_info.report_inventory_cost_info +#. 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_inventory_cost_info -#: model:ir.model.fields,field_description:stock_inventory_cost_info.field_stock_inventory_line__adjustment_cost +#. 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_inventory_cost_info -#: model:ir.model.fields,field_description:stock_inventory_cost_info.field_stock_inventory_line__currency_id +#. 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_inventory_cost_info -#: model:ir.model,name:stock_inventory_cost_info.model_stock_inventory_line -msgid "Inventory Line" -msgstr "Línea de inventario" +#. module: stock_quant_cost_info +#: model:ir.model,name:stock_quant_cost_info.model_stock_quant +msgid "Quants" +msgstr "Quants" -#. module: stock_inventory_cost_info -#: model_terms:ir.ui.view,arch_db:stock_inventory_cost_info.stock_inventory_line_tree -#: model_terms:ir.ui.view,arch_db:stock_inventory_cost_info.stock_inventory_line_tree2 +#. 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 "" +msgstr "Total" + +#~ msgid "Inventory Line" +#~ msgstr "Línea de inventario" diff --git a/stock_quant_cost_info/i18n/stock_inventory_cost_info.pot b/stock_quant_cost_info/i18n/stock_inventory_cost_info.pot deleted file mode 100644 index a60fbcb8fe7d..000000000000 --- a/stock_quant_cost_info/i18n/stock_inventory_cost_info.pot +++ /dev/null @@ -1,54 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * stock_inventory_cost_info -# -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_inventory_cost_info -#: model_terms:ir.ui.view,arch_db:stock_inventory_cost_info.report_inventory_cost_info -msgid "Adjustment cost" -msgstr "" - -#. module: stock_inventory_cost_info -#: model:ir.model.fields,field_description:stock_inventory_cost_info.field_stock_inventory_line__adjustment_cost -msgid "Adjustment cost" -msgstr "" - -#. module: stock_inventory_cost_info -#: model:ir.model.fields,field_description:stock_inventory_cost_info.field_stock_inventory_line__currency_id -msgid "Currency" -msgstr "" - -#. module: stock_inventory_cost_info -#: model:ir.model.fields,field_description:stock_inventory_cost_info.field_stock_inventory_line__display_name -msgid "Display Name" -msgstr "" - -#. module: stock_inventory_cost_info -#: model:ir.model.fields,field_description:stock_inventory_cost_info.field_stock_inventory_line__id -msgid "ID" -msgstr "" - -#. module: stock_inventory_cost_info -#: model:ir.model,name:stock_inventory_cost_info.model_stock_inventory_line -msgid "Inventory Line" -msgstr "" - -#. module: stock_inventory_cost_info -#: model:ir.model.fields,field_description:stock_inventory_cost_info.field_stock_inventory_line____last_update -msgid "Last Modified on" -msgstr "" - -#. module: stock_inventory_cost_info -#: model_terms:ir.ui.view,arch_db:stock_inventory_cost_info.stock_inventory_line_tree -msgid "Total" -msgstr "" 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 index 7ef50e944d34..2b7b6c8b8b62 100644 --- a/stock_quant_cost_info/models/__init__.py +++ b/stock_quant_cost_info/models/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from . import stock_inventory +from . import stock_quant diff --git a/stock_quant_cost_info/models/stock_inventory.py b/stock_quant_cost_info/models/stock_inventory.py deleted file mode 100644 index 9ebdf5b47ac1..000000000000 --- a/stock_quant_cost_info/models/stock_inventory.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2019 Tecnativa - Ernesto Tejeda -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from odoo import api, fields, models - - -class InventoryLine(models.Model): - _inherit = "stock.inventory.line" - - currency_id = fields.Many2one( - string="Currency", related="inventory_id.company_id.currency_id" - ) - adjustment_cost = fields.Monetary( - string="Adjustment cost", compute="_compute_adjustment_cost", store=True - ) - - @api.depends("difference_qty", "inventory_id.state") - def _compute_adjustment_cost(self): - for record in self: - record.adjustment_cost = ( - record.difference_qty * record.product_id.standard_price - ) 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 index 0c71102569a2..21e014c78896 100644 --- a/stock_quant_cost_info/readme/CONTRIBUTORS.rst +++ b/stock_quant_cost_info/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * 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 index 5fb286cd2966..6f3edd768220 100644 --- a/stock_quant_cost_info/readme/DESCRIPTION.rst +++ b/stock_quant_cost_info/readme/DESCRIPTION.rst @@ -1,4 +1,4 @@ -This module extends the functionality of *Inventory Adjustments* to show a new -column *Adjustment cost* in *Inventory Details* list and PDF report table. The -value of *Adjustment cost* will be self-calculated according to: +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 index 82cc8b75399c..a57fc8dcc905 100644 --- a/stock_quant_cost_info/readme/INSTALL.rst +++ b/stock_quant_cost_info/readme/INSTALL.rst @@ -1,2 +1,2 @@ A pre_init_hook process is initiated in order to set the *Adjustment cost* to -zero in all existing *inventory adjustment* before installation. +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 index fb5b8ba85370..763db187326c 100644 --- a/stock_quant_cost_info/readme/USAGE.rst +++ b/stock_quant_cost_info/readme/USAGE.rst @@ -1,7 +1,6 @@ To use this module, you need to: -#. Go to *Inventory > Operations > Inventory Adjustments* and create a new one. -#. Click on *Start Inventory* button. -#. In *Inventory Details* list you will see a new column named - *Adjustment cost*. -#. The cost will be recomputed when the inventory adjustment is validated. +#. 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/index.html b/stock_quant_cost_info/static/description/index.html index 0845fef66cc1..c4b69dfeeac2 100644 --- a/stock_quant_cost_info/static/description/index.html +++ b/stock_quant_cost_info/static/description/index.html @@ -3,8 +3,8 @@ - -Stock Inventory Cost Info + +Stock Quant Cost Info -
-

Stock Inventory Cost Info

+
+

Stock Quant Cost Info

-

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

-

This module extends the functionality of Inventory Adjustments to show a new -column Adjustment cost in Inventory Details list and PDF report table. The -value of Adjustment cost will be self-calculated according to: +

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

@@ -389,17 +389,16 @@

Stock Inventory Cost Info

Installation

A pre_init_hook process is initiated in order to set the Adjustment cost to -zero in all existing inventory adjustment before installation.

+zero in all existing stock quant before installation.

Usage

To use this module, you need to:

    -
  1. Go to Inventory > Operations > Inventory Adjustments and create a new one.
  2. -
  3. Click on Start Inventory button.
  4. -
  5. In Inventory Details list you will see a new column named -Adjustment cost.
  6. -
  7. The cost will be recomputed when the inventory adjustment is validated.
  8. +
  9. Go to Inventory > Products > Products and create or select one.
  10. +
  11. Click on Update Quantity button.
  12. +
  13. In Quant list you will see a new column named Adjustment cost.
  14. +
  15. The cost will be recomputed when we change the Counted Quantity.
@@ -407,7 +406,7 @@

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.

+feedback.

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

@@ -425,6 +424,7 @@

Contributors

  • Ernesto Tejeda
  • Pedro M. Baeza
  • Sergio Teruel
  • +
  • Carlos Roca
  • @@ -436,7 +436,7 @@

    Maintainers

    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.

    +

    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/test_stock_inventory_cost_info.py b/stock_quant_cost_info/tests/test_stock_inventory_cost_info.py index 188d88553e9a..cf8dbe129fff 100644 --- a/stock_quant_cost_info/tests/test_stock_inventory_cost_info.py +++ b/stock_quant_cost_info/tests/test_stock_inventory_cost_info.py @@ -6,7 +6,7 @@ @tagged("post_install", "-at_install") -class TestStockInventoryCostInfo(TransactionCase): +class TestStockQuantCostInfo(TransactionCase): def setUp(self): super().setUp() product_obj = self.env["product.product"] @@ -16,40 +16,22 @@ def setUp(self): self.product_2 = product_obj.create( {"name": "product test 2", "type": "product", "standard_price": 2000} ) - self.inventory = self.env["stock.inventory"].create( - { - "name": "Another inventory", - "line_ids": [ - ( - 0, - 0, - { - "product_id": self.product_1.id, - "product_qty": 10, - "location_id": self.env.ref( - "stock.warehouse0" - ).lot_stock_id.id, - }, - ), - ( - 0, - 0, - { - "product_id": self.product_2.id, - "product_qty": 20, - "location_id": self.env.ref( - "stock.warehouse0" - ).lot_stock_id.id, - }, - ), - ], - } - ) def test_compute_adjustment_cost(self): """Tests if the adjustment_cost is correctly computed.""" - lines = self.inventory.line_ids - line1 = lines.filtered(lambda r: r.product_id == self.product_1) - self.assertEqual(line1.adjustment_cost, 10000) - line2 = lines.filtered(lambda r: r.product_id == self.product_2) - self.assertEqual(line2.adjustment_cost, 40000) + 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 index 8d9dda2c3b6f..ccbbc3b8ae3b 100644 --- a/stock_quant_cost_info/views/report_stockinventory.xml +++ b/stock_quant_cost_info/views/report_stockinventory.xml @@ -2,14 +2,17 @@