diff --git a/README.md b/README.md index 560f1faa0..dc9449f11 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ addon | version | maintainers | summary --- | --- | --- | --- [stock_delivery_note](stock_delivery_note/) | 19.0.1.0.0 | | This module allows to fill in a delivery note that will be displayed on delivery report [stock_move_value_report](stock_move_value_report/) | 19.0.1.0.0 | | Stock Move Cost Value Report +[stock_picking_operations_multilang](stock_picking_operations_multilang/) | 19.0.1.0.0 | | Stock Picking Operations Multilang [stock_picking_report_external_note](stock_picking_report_external_note/) | 19.0.1.0.0 | Shide | Adds a note in Stock Picking shown on external reports like Delivery Slip [stock_picking_report_valued](stock_picking_report_valued/) | 19.0.1.0.1 | | Adding Valued Picking on Delivery Slip report [stock_product_demand_info](stock_product_demand_info/) | 19.0.1.1.0 | ivantodorovich | Past demand by configurable periods on product and orderpoint diff --git a/setup/_metapackage/pyproject.toml b/setup/_metapackage/pyproject.toml index 4a72dbca4..f07f1d8b1 100644 --- a/setup/_metapackage/pyproject.toml +++ b/setup/_metapackage/pyproject.toml @@ -4,6 +4,7 @@ version = "19.0.20260724.0" dependencies = [ "odoo-addon-stock_delivery_note==19.0.*", "odoo-addon-stock_move_value_report==19.0.*", + "odoo-addon-stock_picking_operations_multilang==19.0.*", "odoo-addon-stock_picking_report_external_note==19.0.*", "odoo-addon-stock_picking_report_valued==19.0.*", "odoo-addon-stock_product_demand_info==19.0.*", diff --git a/stock_picking_operations_multilang/README.rst b/stock_picking_operations_multilang/README.rst new file mode 100644 index 000000000..f4078f0c8 --- /dev/null +++ b/stock_picking_operations_multilang/README.rst @@ -0,0 +1,113 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================== +Stock Picking Operations Multilang +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:29fc9a1fe651284faa3d38d8d6545157dac262b5926a1e1a2f0d981e8e4a1e47 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/stock_picking_operations_multilang + :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-19-0/stock-logistics-reporting-19-0-stock_picking_operations_multilang + :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=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows printing the Picking Operations report in the +partner's or warehouse's language, configurable at the warehouse level. + +**Table of contents** + +.. contents:: + :local: + +Use Cases / Context +=================== + +When a company operates internationally, employees from different +countries may encounter language barriers. For instance, a warehouse +manager who only understands his native language might face difficulties +if the Picking Operations report is in a different language. This module +addresses such scenarios by enabling the customization of the Picking +Operations report language, ensuring it matches the language preferences +of the warehouse manager or the partner. + +Configuration +============= + +To set up a specific language for Picking Operations: + +- Go to Inventory > Configuration > Warehouses. + +- Select the warehouse for which you want to set up the language for the + Picking Operations report. + +- Choose the Picking Operation Language option. There are two options: + + - Partner: It will use the language of the partner for the picking. If + there is no partner for the picking, it will use the standard + behavior of Odoo. + - Warehouse: If you select this option, you must fill in the Warehouse + Language field, and this will be applied to Picking Operations. + - If left blank, it will use the standard behavior of Odoo. + +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 +------- + +* Quartile + +Contributors +------------ + +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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_picking_operations_multilang/__init__.py b/stock_picking_operations_multilang/__init__.py new file mode 100644 index 000000000..071962a35 --- /dev/null +++ b/stock_picking_operations_multilang/__init__.py @@ -0,0 +1,2 @@ +from . import models +from .hooks import uninstall_hook diff --git a/stock_picking_operations_multilang/__manifest__.py b/stock_picking_operations_multilang/__manifest__.py new file mode 100644 index 000000000..cdd4ebcca --- /dev/null +++ b/stock_picking_operations_multilang/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Picking Operations Multilang", + "version": "19.0.1.0.0", + "category": "Reporting", + "website": "https://github.com/OCA/stock-logistics-reporting", + "author": "Quartile, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["stock"], + "data": [ + "views/stock_warehouse_views.xml", + "reports/picking_operations_report.xml", + "reports/report_picking_with_language.xml", + ], + "uninstall_hook": "uninstall_hook", + "installable": True, +} diff --git a/stock_picking_operations_multilang/hooks.py b/stock_picking_operations_multilang/hooks.py new file mode 100644 index 000000000..cf5f45393 --- /dev/null +++ b/stock_picking_operations_multilang/hooks.py @@ -0,0 +1,4 @@ +def uninstall_hook(env): + report_action = env.ref("stock.action_report_picking", raise_if_not_found=False) + if report_action: + report_action.write({"report_name": "stock.report_picking"}) diff --git a/stock_picking_operations_multilang/i18n/it.po b/stock_picking_operations_multilang/i18n/it.po new file mode 100644 index 000000000..3e1346173 --- /dev/null +++ b/stock_picking_operations_multilang/i18n/it.po @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_operations_multilang +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-07-30 11:58+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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 5.6.2\n" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__active_lang_count +msgid "Active Lang Count" +msgstr "Numero lingue attive" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields.selection,name:stock_picking_operations_multilang.selection__stock_warehouse__picking_operation_language_option__partner +msgid "Partner" +msgstr "Partner" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,help:stock_picking_operations_multilang.field_stock_warehouse__picking_operation_language_option +msgid "" +"Partner: Picking Operations report will use the partner's language.\n" +"Warehouse: Picking Operations report will use the language specified in the Warehouse Language field." +msgstr "" +"Partner: il resoconto operazioni del partner utilizzerà la lingua del " +"partner.\n" +"Magazzino: il resoconto operazioni del partner utilizzerà la lingua indicata " +"nel campo lingua magazzino." + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__picking_operation_language_option +msgid "Picking Operation Language Option" +msgstr "Opzione lingua operazione prelievo" + +#. module: stock_picking_operations_multilang +#: model:ir.model,name:stock_picking_operations_multilang.model_stock_picking +msgid "Transfer" +msgstr "Trasferimento" + +#. module: stock_picking_operations_multilang +#: model:ir.model,name:stock_picking_operations_multilang.model_stock_warehouse +#: model:ir.model.fields.selection,name:stock_picking_operations_multilang.selection__stock_warehouse__picking_operation_language_option__warehouse +msgid "Warehouse" +msgstr "Magazzino" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__warehouse_language +msgid "Warehouse Language" +msgstr "Lingua magazzino" diff --git a/stock_picking_operations_multilang/i18n/ja.po b/stock_picking_operations_multilang/i18n/ja.po new file mode 100644 index 000000000..eced972d6 --- /dev/null +++ b/stock_picking_operations_multilang/i18n/ja.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_operations_multilang +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__active_lang_count +msgid "Active Lang Count" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields.selection,name:stock_picking_operations_multilang.selection__stock_warehouse__picking_operation_language_option__partner +msgid "Partner" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,help:stock_picking_operations_multilang.field_stock_warehouse__picking_operation_language_option +msgid "" +"Partner: Picking Operations report will use the partner's language.\n" +"Warehouse: Picking Operations report will use the language specified in the Warehouse Language field." +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__picking_operation_language_option +msgid "Picking Operation Language Option" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model,name:stock_picking_operations_multilang.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model,name:stock_picking_operations_multilang.model_stock_warehouse +#: model:ir.model.fields.selection,name:stock_picking_operations_multilang.selection__stock_warehouse__picking_operation_language_option__warehouse +msgid "Warehouse" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__warehouse_language +msgid "Warehouse Language" +msgstr "" diff --git a/stock_picking_operations_multilang/i18n/stock_picking_operations_multilang.pot b/stock_picking_operations_multilang/i18n/stock_picking_operations_multilang.pot new file mode 100644 index 000000000..b7a3f4193 --- /dev/null +++ b/stock_picking_operations_multilang/i18n/stock_picking_operations_multilang.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_operations_multilang +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 19.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_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__active_lang_count +msgid "Active Lang Count" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields.selection,name:stock_picking_operations_multilang.selection__stock_warehouse__picking_operation_language_option__partner +msgid "Partner" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,help:stock_picking_operations_multilang.field_stock_warehouse__picking_operation_language_option +msgid "" +"Partner: Picking Operations report will use the partner's language.\n" +"Warehouse: Picking Operations report will use the language specified in the Warehouse Language field." +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__picking_operation_language_option +msgid "Picking Operation Language Option" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model,name:stock_picking_operations_multilang.model_stock_picking +msgid "Transfer" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model,name:stock_picking_operations_multilang.model_stock_warehouse +#: model:ir.model.fields.selection,name:stock_picking_operations_multilang.selection__stock_warehouse__picking_operation_language_option__warehouse +msgid "Warehouse" +msgstr "" + +#. module: stock_picking_operations_multilang +#: model:ir.model.fields,field_description:stock_picking_operations_multilang.field_stock_warehouse__warehouse_language +msgid "Warehouse Language" +msgstr "" diff --git a/stock_picking_operations_multilang/models/__init__.py b/stock_picking_operations_multilang/models/__init__.py new file mode 100644 index 000000000..0b10b2155 --- /dev/null +++ b/stock_picking_operations_multilang/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_picking +from . import stock_warehouse diff --git a/stock_picking_operations_multilang/models/stock_picking.py b/stock_picking_operations_multilang/models/stock_picking.py new file mode 100644 index 000000000..3bff60e97 --- /dev/null +++ b/stock_picking_operations_multilang/models/stock_picking.py @@ -0,0 +1,23 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + def _get_picking_operations_lang(self): + self.ensure_one() + warehouse = self.picking_type_id.warehouse_id + if ( + warehouse.picking_operation_language_option == "partner" + and self.partner_id.lang + ): + return self.partner_id.lang + if ( + warehouse.picking_operation_language_option == "warehouse" + and warehouse.warehouse_language + ): + return warehouse.warehouse_language + return self._get_report_lang() or self.env.user.lang or self.env.lang diff --git a/stock_picking_operations_multilang/models/stock_warehouse.py b/stock_picking_operations_multilang/models/stock_warehouse.py new file mode 100644 index 000000000..312c96b64 --- /dev/null +++ b/stock_picking_operations_multilang/models/stock_warehouse.py @@ -0,0 +1,31 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class Warehouse(models.Model): + _inherit = "stock.warehouse" + + @api.model + def _lang_get(self): + return self.env["res.lang"].get_installed() + + picking_operation_language_option = fields.Selection( + [("partner", "Partner"), ("warehouse", "Warehouse")], + help="Partner: Picking Operations report will use the partner's language.\n" + "Warehouse: Picking Operations report will use the language specified in " + "the Warehouse Language field.", + ) + + warehouse_language = fields.Selection( + _lang_get, + default=lambda self: self.env.lang, + ) + active_lang_count = fields.Integer(compute="_compute_active_lang_count") + + @api.depends("warehouse_language") + def _compute_active_lang_count(self): + lang_count = len(self.env["res.lang"].get_installed()) + for rec in self: + rec.active_lang_count = lang_count diff --git a/stock_picking_operations_multilang/pyproject.toml b/stock_picking_operations_multilang/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/stock_picking_operations_multilang/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_picking_operations_multilang/readme/CONFIGURE.md b/stock_picking_operations_multilang/readme/CONFIGURE.md new file mode 100644 index 000000000..8a313540a --- /dev/null +++ b/stock_picking_operations_multilang/readme/CONFIGURE.md @@ -0,0 +1,14 @@ +To set up a specific language for Picking Operations: + +- Go to Inventory \> Configuration \> Warehouses. + +- Select the warehouse for which you want to set up the language for the + Picking Operations report. + +- Choose the Picking Operation Language option. There are two options: + - Partner: It will use the language of the partner for the picking. If + there is no partner for the picking, it will use the standard + behavior of Odoo. + - Warehouse: If you select this option, you must fill in the Warehouse + Language field, and this will be applied to Picking Operations. + - If left blank, it will use the standard behavior of Odoo. diff --git a/stock_picking_operations_multilang/readme/CONTEXT.md b/stock_picking_operations_multilang/readme/CONTEXT.md new file mode 100644 index 000000000..fddb54af2 --- /dev/null +++ b/stock_picking_operations_multilang/readme/CONTEXT.md @@ -0,0 +1,7 @@ +When a company operates internationally, employees from different +countries may encounter language barriers. For instance, a warehouse +manager who only understands his native language might face difficulties +if the Picking Operations report is in a different language. This module +addresses such scenarios by enabling the customization of the Picking +Operations report language, ensuring it matches the language preferences +of the warehouse manager or the partner. diff --git a/stock_picking_operations_multilang/readme/CONTRIBUTORS.md b/stock_picking_operations_multilang/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..2f6060845 --- /dev/null +++ b/stock_picking_operations_multilang/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/stock_picking_operations_multilang/readme/DESCRIPTION.md b/stock_picking_operations_multilang/readme/DESCRIPTION.md new file mode 100644 index 000000000..6876a8206 --- /dev/null +++ b/stock_picking_operations_multilang/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows printing the Picking Operations report in the +partner's or warehouse's language, configurable at the warehouse level. diff --git a/stock_picking_operations_multilang/reports/picking_operations_report.xml b/stock_picking_operations_multilang/reports/picking_operations_report.xml new file mode 100644 index 000000000..0dd8629a3 --- /dev/null +++ b/stock_picking_operations_multilang/reports/picking_operations_report.xml @@ -0,0 +1,8 @@ + + + + stock_picking_operations_multilang.report_picking_with_language + + diff --git a/stock_picking_operations_multilang/reports/report_picking_with_language.xml b/stock_picking_operations_multilang/reports/report_picking_with_language.xml new file mode 100644 index 000000000..bf6a98772 --- /dev/null +++ b/stock_picking_operations_multilang/reports/report_picking_with_language.xml @@ -0,0 +1,10 @@ + + + + diff --git a/stock_picking_operations_multilang/static/description/icon.png b/stock_picking_operations_multilang/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_picking_operations_multilang/static/description/icon.png differ diff --git a/stock_picking_operations_multilang/static/description/index.html b/stock_picking_operations_multilang/static/description/index.html new file mode 100644 index 000000000..49e387dc7 --- /dev/null +++ b/stock_picking_operations_multilang/static/description/index.html @@ -0,0 +1,463 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Stock Picking Operations Multilang

+ +

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

+

This module allows printing the Picking Operations report in the +partner’s or warehouse’s language, configurable at the warehouse level.

+

Table of contents

+ +
+

Use Cases / Context

+

When a company operates internationally, employees from different +countries may encounter language barriers. For instance, a warehouse +manager who only understands his native language might face difficulties +if the Picking Operations report is in a different language. This module +addresses such scenarios by enabling the customization of the Picking +Operations report language, ensuring it matches the language preferences +of the warehouse manager or the partner.

+
+
+

Configuration

+

To set up a specific language for Picking Operations:

+
    +
  • Go to Inventory > Configuration > Warehouses.
  • +
  • Select the warehouse for which you want to set up the language for the +Picking Operations report.
  • +
  • Choose the Picking Operation Language option. There are two options:
      +
    • Partner: It will use the language of the partner for the picking. If +there is no partner for the picking, it will use the standard +behavior of Odoo.
    • +
    • Warehouse: If you select this option, you must fill in the Warehouse +Language field, and this will be applied to Picking Operations.
    • +
    • If left blank, it will use the standard behavior of Odoo.
    • +
    +
  • +
+
+
+

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

+
    +
  • Quartile
  • +
+
+
+

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_picking_operations_multilang/tests/__init__.py b/stock_picking_operations_multilang/tests/__init__.py new file mode 100644 index 000000000..4ea4d2a30 --- /dev/null +++ b/stock_picking_operations_multilang/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking_operations_multilang diff --git a/stock_picking_operations_multilang/tests/test_stock_picking_operations_multilang.py b/stock_picking_operations_multilang/tests/test_stock_picking_operations_multilang.py new file mode 100644 index 000000000..40e98a713 --- /dev/null +++ b/stock_picking_operations_multilang/tests/test_stock_picking_operations_multilang.py @@ -0,0 +1,127 @@ +# Copyright 2024 Quartile (https://www.quartile.co) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from unittest.mock import patch + +from odoo import Command + +from odoo.addons.stock.tests.common import TestStockCommon +from odoo.addons.stock_picking_operations_multilang.hooks import uninstall_hook + + +class TestPickingOperationsLanguage(TestStockCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + ja = ( + cls.env["res.lang"] + .with_context(active_test=False) + .search([("code", "=", "ja_JP")]) + ) + cls.env["base.language.install"].create({"lang_ids": ja.ids}).lang_install() + cls.partner = cls.env["res.partner"].create( + {"name": "Test Partner", "lang": "ja_JP"} + ) + cls.picking = cls.env["stock.picking"].create( + { + "partner_id": cls.partner.id, + "picking_type_id": cls.picking_type_in.id, + } + ) + cls.warehouse = cls.picking_type_in.warehouse_id + cls.report = cls.env.ref("stock.action_report_picking") + cls.product_for_report = cls.env["product.product"].create( + {"name": "English Product", "is_storable": True} + ) + cls.product_for_report.with_context(lang="ja_JP").name = "Translated Product" + + def _render_report_html(self, picking): + with patch( + "odoo.addons.base.models.ir_actions_report.IrActionsReport.barcode", + return_value=b"", + ): + result = self.report._render_qweb_html(self.report.id, [picking.id])[0] + return result.decode() if isinstance(result, bytes) else result + + def test_stock_picking_operations_language(self): + report_html = self._render_report_html(self.picking) + self.assertIn('lang="ja-JP"', report_html) + self.assertEqual(self.picking._get_picking_operations_lang(), "ja_JP") + + self.warehouse.picking_operation_language_option = "partner" + report_html = self._render_report_html(self.picking) + self.assertIn('lang="ja-JP"', report_html) + self.assertEqual(self.picking._get_picking_operations_lang(), "ja_JP") + + self.partner.lang = "en_US" + report_html = self._render_report_html(self.picking) + self.assertIn("Receipt", report_html) + self.assertEqual(self.picking._get_picking_operations_lang(), "en_US") + + self.picking.partner_id = False + report_html = self._render_report_html(self.picking) + self.assertIn("Receipt", report_html) + self.assertEqual(self.picking._get_picking_operations_lang(), "en_US") + + self.warehouse.picking_operation_language_option = "warehouse" + self.warehouse.warehouse_language = "ja_JP" + report_html = self._render_report_html(self.picking) + self.assertIn('lang="ja-JP"', report_html) + self.assertEqual(self.picking._get_picking_operations_lang(), "ja_JP") + + self.warehouse.warehouse_language = "en_US" + report_html = self._render_report_html(self.picking) + self.assertIn("Receipt", report_html) + self.assertEqual(self.picking._get_picking_operations_lang(), "en_US") + + def test_report_uses_translated_field_values(self): + self.warehouse.picking_operation_language_option = "warehouse" + self.warehouse.warehouse_language = "ja_JP" + picking = self.env["stock.picking"].create( + { + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "picking_type_id": self.picking_type_in.id, + "move_line_ids": [ + Command.create( + { + "product_id": self.product_for_report.id, + "product_uom_id": self.product_for_report.uom_id.id, + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "quantity": 1, + } + ) + ], + } + ) + + report_html = self._render_report_html(picking) + + self.assertIn('lang="ja-JP"', report_html) + self.assertIn("Translated Product", report_html) + + def test_active_lang_count(self): + """Test computation of active_lang_count""" + self.assertGreater(self.warehouse.active_lang_count, 0) + self.assertEqual( + self.warehouse._lang_get(), self.env["res.lang"].get_installed() + ) + + # Simulate change in warehouse_language + self.warehouse.warehouse_language = "ja_JP" + self.warehouse._compute_active_lang_count() + + # Ensure the computed count remains correct + self.assertEqual( + self.warehouse.active_lang_count, len(self.env["res.lang"].get_installed()) + ) + + def test_uninstall_hook_restores_report_name(self): + self.report.report_name = ( + "stock_picking_operations_multilang.report_picking_with_language" + ) + + uninstall_hook(self.env) + + self.assertEqual(self.report.report_name, "stock.report_picking") diff --git a/stock_picking_operations_multilang/views/stock_warehouse_views.xml b/stock_picking_operations_multilang/views/stock_warehouse_views.xml new file mode 100644 index 000000000..cf853dcee --- /dev/null +++ b/stock_picking_operations_multilang/views/stock_warehouse_views.xml @@ -0,0 +1,18 @@ + + + stock.warehouse.inherit + stock.warehouse + + + + + + + + + +