From 2cd2b9cd195e69f63fa12231613f980858e35ae6 Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Mon, 5 Feb 2024 14:52:49 +0100 Subject: [PATCH 1/5] [IMP] sale_stock_on_hand_popup: add maintainers --- sale_stock_on_hand_popup/README.rst | 16 +++++++++++++++- sale_stock_on_hand_popup/__manifest__.py | 1 + .../static/description/index.html | 5 ++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sale_stock_on_hand_popup/README.rst b/sale_stock_on_hand_popup/README.rst index 1cae68b7d936..cf8ece5fcf87 100644 --- a/sale_stock_on_hand_popup/README.rst +++ b/sale_stock_on_hand_popup/README.rst @@ -7,7 +7,7 @@ Sale Stock On Hand Popup !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:7e7d0b495f5c5c2c119238bc86c9beee329c4ac57c102e536b6fc4dce6988870 + !! source digest: sha256:8afb561c639c15549500e32ef695b6653bda17d45ad957f6cc908e525343b79c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -88,6 +88,20 @@ 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-aleuffre| image:: https://github.com/aleuffre.png?size=40px + :target: https://github.com/aleuffre + :alt: aleuffre +.. |maintainer-renda-dev| image:: https://github.com/renda-dev.png?size=40px + :target: https://github.com/renda-dev + :alt: renda-dev +.. |maintainer-PicchiSeba| image:: https://github.com/PicchiSeba.png?size=40px + :target: https://github.com/PicchiSeba + :alt: PicchiSeba + +Current `maintainers `__: + +|maintainer-aleuffre| |maintainer-renda-dev| |maintainer-PicchiSeba| + 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/sale_stock_on_hand_popup/__manifest__.py b/sale_stock_on_hand_popup/__manifest__.py index f725b5579771..02cc0e392c32 100644 --- a/sale_stock_on_hand_popup/__manifest__.py +++ b/sale_stock_on_hand_popup/__manifest__.py @@ -1,6 +1,7 @@ { "name": "Sale Stock On Hand Popup", "author": "PyTech SRL, Ooops404, Odoo Community Association (OCA)", + "maintainers": ["aleuffre", "renda-dev", "PicchiSeba"], "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse Management", "version": "14.0.1.0.1", diff --git a/sale_stock_on_hand_popup/static/description/index.html b/sale_stock_on_hand_popup/static/description/index.html index 7f5e6d6c0f51..908d28099fc8 100644 --- a/sale_stock_on_hand_popup/static/description/index.html +++ b/sale_stock_on_hand_popup/static/description/index.html @@ -1,3 +1,4 @@ + @@ -366,7 +367,7 @@

Sale Stock On Hand Popup

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:7e7d0b495f5c5c2c119238bc86c9beee329c4ac57c102e536b6fc4dce6988870 +!! source digest: sha256:8afb561c639c15549500e32ef695b6653bda17d45ad957f6cc908e525343b79c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This module allows user to check from sale order line all inventory lines related to that product.

@@ -428,6 +429,8 @@

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.

+

Current maintainers:

+

aleuffre renda-dev PicchiSeba

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.

From 85ec8effe2c55c8a5a92750d6188113fae24de2a Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Thu, 1 Feb 2024 18:40:50 +0100 Subject: [PATCH 2/5] [IMP] sale_stock_on_hand_popup: open in a popup --- sale_stock_on_hand_popup/README.rst | 2 +- sale_stock_on_hand_popup/__init__.py | 1 + sale_stock_on_hand_popup/__manifest__.py | 11 ++++- sale_stock_on_hand_popup/models/__init__.py | 3 +- sale_stock_on_hand_popup/models/product.py | 20 -------- .../models/product_product.py | 20 ++++++++ .../models/res_config_settings.py | 11 +++++ .../security/ir.model.access.csv | 2 + .../security/security.xml | 9 ++++ .../static/description/index.html | 2 +- .../static/src/js/qty_at_date_widget.js | 29 ----------- .../static/src/js/stock_on_hand_widget.js | 47 ++++++++++++++++++ .../static/src/xml/sale_stock.xml | 20 -------- .../static/src/xml/stock_on_hand_widget.xml | 8 ++++ .../tests/test_sale_stock_on_hand_popup.py | 32 +++++++++---- sale_stock_on_hand_popup/views/assets.xml | 15 ++++++ .../views/res_config_settings_views.xml | 23 +++++++++ .../views/sale_order_views.xml | 33 ++++++++----- sale_stock_on_hand_popup/wizards/__init__.py | 1 + .../wizards/product_quant_wizard.py | 22 +++++++++ .../wizards/product_quant_wizard_views.xml | 48 +++++++++++++++++++ 21 files changed, 263 insertions(+), 96 deletions(-) delete mode 100644 sale_stock_on_hand_popup/models/product.py create mode 100644 sale_stock_on_hand_popup/models/product_product.py create mode 100644 sale_stock_on_hand_popup/models/res_config_settings.py create mode 100644 sale_stock_on_hand_popup/security/ir.model.access.csv create mode 100644 sale_stock_on_hand_popup/security/security.xml delete mode 100644 sale_stock_on_hand_popup/static/src/js/qty_at_date_widget.js create mode 100644 sale_stock_on_hand_popup/static/src/js/stock_on_hand_widget.js delete mode 100644 sale_stock_on_hand_popup/static/src/xml/sale_stock.xml create mode 100644 sale_stock_on_hand_popup/static/src/xml/stock_on_hand_widget.xml create mode 100644 sale_stock_on_hand_popup/views/assets.xml create mode 100644 sale_stock_on_hand_popup/views/res_config_settings_views.xml create mode 100644 sale_stock_on_hand_popup/wizards/__init__.py create mode 100644 sale_stock_on_hand_popup/wizards/product_quant_wizard.py create mode 100644 sale_stock_on_hand_popup/wizards/product_quant_wizard_views.xml diff --git a/sale_stock_on_hand_popup/README.rst b/sale_stock_on_hand_popup/README.rst index cf8ece5fcf87..47358bf7d968 100644 --- a/sale_stock_on_hand_popup/README.rst +++ b/sale_stock_on_hand_popup/README.rst @@ -7,7 +7,7 @@ Sale Stock On Hand Popup !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:8afb561c639c15549500e32ef695b6653bda17d45ad957f6cc908e525343b79c + !! source digest: sha256:be440b588a162856106f68611bf86c8d8e0c1a27641a9ebb7b2fedcfc0d5b905 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/sale_stock_on_hand_popup/__init__.py b/sale_stock_on_hand_popup/__init__.py index 0650744f6bc6..aee8895e7a31 100644 --- a/sale_stock_on_hand_popup/__init__.py +++ b/sale_stock_on_hand_popup/__init__.py @@ -1 +1,2 @@ from . import models +from . import wizards diff --git a/sale_stock_on_hand_popup/__manifest__.py b/sale_stock_on_hand_popup/__manifest__.py index 02cc0e392c32..849d6aecefaa 100644 --- a/sale_stock_on_hand_popup/__manifest__.py +++ b/sale_stock_on_hand_popup/__manifest__.py @@ -7,8 +7,15 @@ "version": "14.0.1.0.1", "license": "AGPL-3", "depends": ["sale_stock", "stock_available"], - "data": ["views/sale_order_views.xml"], - "qweb": ["static/src/xml/sale_stock.xml"], + "data": [ + "security/ir.model.access.csv", + "security/security.xml", + "views/assets.xml", + "views/res_config_settings_views.xml", + "views/sale_order_views.xml", + "wizards/product_quant_wizard_views.xml", + ], + "qweb": ["static/src/xml/stock_on_hand_widget.xml"], "installable": True, "application": False, } diff --git a/sale_stock_on_hand_popup/models/__init__.py b/sale_stock_on_hand_popup/models/__init__.py index 9649db77a159..e0848eaa7738 100644 --- a/sale_stock_on_hand_popup/models/__init__.py +++ b/sale_stock_on_hand_popup/models/__init__.py @@ -1 +1,2 @@ -from . import product +from . import product_product +from . import res_config_settings diff --git a/sale_stock_on_hand_popup/models/product.py b/sale_stock_on_hand_popup/models/product.py deleted file mode 100644 index b55eb0d2b51a..000000000000 --- a/sale_stock_on_hand_popup/models/product.py +++ /dev/null @@ -1,20 +0,0 @@ -from odoo import _, models - - -class Product(models.Model): - _inherit = "product.product" - - def action_open_quants_show_products(self): - res = self.action_open_quants() - - res.update( - { - "name": _("Stock Lines"), - "context": { - **res.get("context", {}), - "single_product": False, - "edit": False, - }, - } - ) - return res diff --git a/sale_stock_on_hand_popup/models/product_product.py b/sale_stock_on_hand_popup/models/product_product.py new file mode 100644 index 000000000000..90e9cfd53872 --- /dev/null +++ b/sale_stock_on_hand_popup/models/product_product.py @@ -0,0 +1,20 @@ +from odoo import models + + +class Product(models.Model): + _inherit = "product.product" + + def action_open_quants_show_products(self): + self.ensure_one() + return { + "name": self.display_name, + "view_type": "form", + "view_mode": "form", + "res_model": "product.quant.wizard", + "type": "ir.actions.act_window", + "target": "new", + "context": { + **self.env.context, + "default_product_id": self.id, + }, + } diff --git a/sale_stock_on_hand_popup/models/res_config_settings.py b/sale_stock_on_hand_popup/models/res_config_settings.py new file mode 100644 index 000000000000..b3a16b81cf02 --- /dev/null +++ b/sale_stock_on_hand_popup/models/res_config_settings.py @@ -0,0 +1,11 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + group_show_transit_location_stock_wizard = fields.Boolean( + "Display also transit location lines in sale line stock popup.", + implied_group="sale_stock_on_hand_popup.group_show_transit_location_stock_wizard", + default=False, + ) diff --git a/sale_stock_on_hand_popup/security/ir.model.access.csv b/sale_stock_on_hand_popup/security/ir.model.access.csv new file mode 100644 index 000000000000..f799a79b5ad7 --- /dev/null +++ b/sale_stock_on_hand_popup/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_quant_wizard,access_product_quant_wizard,model_product_quant_wizard,base.group_user,1,1,1,1 diff --git a/sale_stock_on_hand_popup/security/security.xml b/sale_stock_on_hand_popup/security/security.xml new file mode 100644 index 000000000000..47e93bfd8289 --- /dev/null +++ b/sale_stock_on_hand_popup/security/security.xml @@ -0,0 +1,9 @@ + + + + Display transit location lines in sale line stock popup + + + diff --git a/sale_stock_on_hand_popup/static/description/index.html b/sale_stock_on_hand_popup/static/description/index.html index 908d28099fc8..b9aef2ffffd5 100644 --- a/sale_stock_on_hand_popup/static/description/index.html +++ b/sale_stock_on_hand_popup/static/description/index.html @@ -367,7 +367,7 @@

Sale Stock On Hand Popup

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:8afb561c639c15549500e32ef695b6653bda17d45ad957f6cc908e525343b79c +!! source digest: sha256:be440b588a162856106f68611bf86c8d8e0c1a27641a9ebb7b2fedcfc0d5b905 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This module allows user to check from sale order line all inventory lines related to that product.

diff --git a/sale_stock_on_hand_popup/static/src/js/qty_at_date_widget.js b/sale_stock_on_hand_popup/static/src/js/qty_at_date_widget.js deleted file mode 100644 index bacdb7913dcb..000000000000 --- a/sale_stock_on_hand_popup/static/src/js/qty_at_date_widget.js +++ /dev/null @@ -1,29 +0,0 @@ -odoo.define("sale_stock_on_hand_popup.QtyAtDateWidget", function (require) { - "use strict"; - - const QtyAtDateWidget = require("sale_stock.QtyAtDateWidget"); - - QtyAtDateWidget.include({ - async _openStock(ev) { - ev.stopPropagation(); - - return this.trigger_up("button_clicked", { - attrs: { - name: "action_open_quants_show_products", - type: "object", - }, - record: this.data.product_id, - }); - }, - - _getContent() { - const $content = this._super.apply(this, arguments); - if ($content) { - $content.on("click", ".action_open_stock", this._openStock.bind(this)); - } - return $content; - }, - }); - - return QtyAtDateWidget; -}); diff --git a/sale_stock_on_hand_popup/static/src/js/stock_on_hand_widget.js b/sale_stock_on_hand_popup/static/src/js/stock_on_hand_widget.js new file mode 100644 index 000000000000..aa7c3389426c --- /dev/null +++ b/sale_stock_on_hand_popup/static/src/js/stock_on_hand_widget.js @@ -0,0 +1,47 @@ +odoo.define("sale_stock_on_hand_popup.StockOnHandWidget", function (require) { + "use strict"; + + var Widget = require("web.Widget"); + var widget_registry = require("web.widget_registry"); + + var StockOnHandWidget = Widget.extend({ + template: "sale_stock_on_hand_popup.qtyOnHand", + events: _.extend({}, Widget.prototype.events, { + "click .fa-arrow-right": "_onClickButton", + }), + + /** + * @override + * @param {Widget|null} parent + * @param {Object} params + */ + init: function (parent, params) { + this.data = params.data; + this.fields = params.fields; + this._super(parent); + }, + + updateState: function (state) { + var candidate = state.data[this.getParent().currentRow]; + if (candidate) { + this.data = candidate.data; + this.renderElement(); + } + }, + + _onClickButton: async function (ev) { + ev.stopPropagation(); + var action = await this._rpc({ + model: "product.product", + method: "action_open_quants_show_products", + args: [[this.data.product_id.data.id]], + }); + action.views = [[false, "form"]]; + return this.do_action(action); + }, + }); + + widget_registry.add("stock_on_hand_widget", StockOnHandWidget); + + return StockOnHandWidget; +}); diff --git a/sale_stock_on_hand_popup/static/src/xml/sale_stock.xml b/sale_stock_on_hand_popup/static/src/xml/sale_stock.xml deleted file mode 100644 index cf2dbae2bab1..000000000000 --- a/sale_stock_on_hand_popup/static/src/xml/sale_stock.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - diff --git a/sale_stock_on_hand_popup/static/src/xml/stock_on_hand_widget.xml b/sale_stock_on_hand_popup/static/src/xml/stock_on_hand_widget.xml new file mode 100644 index 000000000000..a2a156c91a42 --- /dev/null +++ b/sale_stock_on_hand_popup/static/src/xml/stock_on_hand_widget.xml @@ -0,0 +1,8 @@ + + + + diff --git a/sale_stock_on_hand_popup/tests/test_sale_stock_on_hand_popup.py b/sale_stock_on_hand_popup/tests/test_sale_stock_on_hand_popup.py index ee6ebd460253..9eeb43c89c71 100644 --- a/sale_stock_on_hand_popup/tests/test_sale_stock_on_hand_popup.py +++ b/sale_stock_on_hand_popup/tests/test_sale_stock_on_hand_popup.py @@ -5,20 +5,32 @@ class TestSaleStockOnHandPopup(common.SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.Product = cls.env["product.product"] - cls.product_1 = cls.env.ref("product.product_product_1") - cls.product_2 = cls.env.ref("product.product_product_2") + cls.product_1 = cls.env.ref("product.product_product_6") + cls.product_2 = cls.env.ref("product.product_product_7") def test_action_open_quants_show_products(self): action_data = self.product_1.action_open_quants_show_products() - self.assertNotEqual( - action_data, - self.product_1.action_open_quants(), - ) - self.assertEqual("Stock Lines", action_data.get("name")) + self.assertEqual(self.product_1.display_name, action_data.get("name")) context = action_data.get("context") - self.assertFalse(context.get("single_product", True)) - self.assertFalse(context.get("edit", True)) + self.assertEqual(self.product_1.id, context.get("default_product_id")) + + def test_get_stock_quant(self): + wiz_prod_1 = self.env["product.quant.wizard"].create( + { + "product_id": self.product_1.id, + } + ) + wiz_prod_2 = self.env["product.quant.wizard"].create( + { + "product_id": self.product_2.id, + } + ) + (wiz_prod_1 | wiz_prod_2)._compute_stock_quant_ids() + + self.assertNotEqual(wiz_prod_1.stock_quant_ids, wiz_prod_2.stock_quant_ids) + self.assertNotEqual( + wiz_prod_1.stock_quant_ids, wiz_prod_1.product_id.stock_quant_ids + ) diff --git a/sale_stock_on_hand_popup/views/assets.xml b/sale_stock_on_hand_popup/views/assets.xml new file mode 100644 index 000000000000..d6c4925eb7a8 --- /dev/null +++ b/sale_stock_on_hand_popup/views/assets.xml @@ -0,0 +1,15 @@ + + +