From c1ff88670a55be00a7a700c4da39a4aaf25d99e4 Mon Sep 17 00:00:00 2001 From: Mateu Griful Date: Wed, 6 Oct 2021 12:54:40 +0200 Subject: [PATCH 1/5] [14.0][ADD] rma_filter_lot: add filter --- rma_filter_lot/__init__.py | 4 +++ rma_filter_lot/__manifest__.py | 17 +++++++++ rma_filter_lot/models/__init__.py | 1 + rma_filter_lot/models/rma_order_line.py | 47 +++++++++++++++++++++++++ rma_filter_lot/readme/CONTRIBUTORS.rst | 2 ++ rma_filter_lot/readme/DESCRIPTION.rst | 2 ++ rma_filter_lot/views/rma_order_view.xml | 13 +++++++ 7 files changed, 86 insertions(+) create mode 100644 rma_filter_lot/__init__.py create mode 100644 rma_filter_lot/__manifest__.py create mode 100644 rma_filter_lot/models/__init__.py create mode 100644 rma_filter_lot/models/rma_order_line.py create mode 100644 rma_filter_lot/readme/CONTRIBUTORS.rst create mode 100644 rma_filter_lot/readme/DESCRIPTION.rst create mode 100644 rma_filter_lot/views/rma_order_view.xml diff --git a/rma_filter_lot/__init__.py b/rma_filter_lot/__init__.py new file mode 100644 index 00000000..e6d259b1 --- /dev/null +++ b/rma_filter_lot/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from . import models diff --git a/rma_filter_lot/__manifest__.py b/rma_filter_lot/__manifest__.py new file mode 100644 index 00000000..3773e24d --- /dev/null +++ b/rma_filter_lot/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +{ + "name": "RMA Filter Lot", + "version": "14.0.1.0.0", + "license": "LGPL-3", + "category": "RMA", + "summary": "Filter RMA lots", + "author": "ForgeFlow", + "website": "https://github.com/ForgeFlow/stock-rma", + "depends": ["rma"], + "data": [ + "views/rma_order_view.xml", + ], + "installable": True, +} diff --git a/rma_filter_lot/models/__init__.py b/rma_filter_lot/models/__init__.py new file mode 100644 index 00000000..0ec42a97 --- /dev/null +++ b/rma_filter_lot/models/__init__.py @@ -0,0 +1 @@ +from . import rma_order_line diff --git a/rma_filter_lot/models/rma_order_line.py b/rma_filter_lot/models/rma_order_line.py new file mode 100644 index 00000000..f54dd0c8 --- /dev/null +++ b/rma_filter_lot/models/rma_order_line.py @@ -0,0 +1,47 @@ +# Copyright 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, fields, models +from odoo.tools import float_compare + + +class RmaOrderLine(models.Model): + _inherit = "rma.order.line" + + lot_id = fields.Many2one( + comodel_name="stock.production.lot", + domain="[('id', 'in', valid_lots_ids)]", + ) + valid_lots_ids = fields.One2many( + comodel_name="stock.production.lot", + compute="_compute_domain_lot_ids", + ) + + @api.depends("product_id") + def _compute_domain_lot_ids(self): + for rec in self: + lots = rec.env["stock.production.lot"].search( + [("product_id", "=", rec.product_id.id)] + ) + if ( + lots + and rec.type == "customer" + and rec.product_id + and rec.product_id.tracking != "none" + ): + valid_ids = self.env["stock.production.lot"] + for quant in rec.product_id.stock_quant_ids: + if ( + float_compare(quant.available_quantity, 0.0, precision_digits=2) + > 0 + and quant.location_id.usage == "customer" + and quant.lot_id + ): + valid_ids |= quant.lot_id + if valid_ids: + lots = valid_ids + rec.valid_lots_ids = lots + + def _onchange_product_id(self): + super()._onchange_product_id() + return {"domain": {"lot_id": [("id", "in", self.valid_lots_ids)]}} diff --git a/rma_filter_lot/readme/CONTRIBUTORS.rst b/rma_filter_lot/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..087dd292 --- /dev/null +++ b/rma_filter_lot/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Mateu Griful +* Lois Rilo diff --git a/rma_filter_lot/readme/DESCRIPTION.rst b/rma_filter_lot/readme/DESCRIPTION.rst new file mode 100644 index 00000000..c6c49173 --- /dev/null +++ b/rma_filter_lot/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module filters the lots in the rma by searching if there are units of the selected product in any customer +location in order to ease the search. diff --git a/rma_filter_lot/views/rma_order_view.xml b/rma_filter_lot/views/rma_order_view.xml new file mode 100644 index 00000000..fef36976 --- /dev/null +++ b/rma_filter_lot/views/rma_order_view.xml @@ -0,0 +1,13 @@ + + + + rma.order.line.form + rma.order.line + + + + + + + + From 1853216e80f3b8fda41703f7b44b12ce915e2658 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Fri, 8 Oct 2021 11:05:07 +0200 Subject: [PATCH 2/5] [IMP] rma_filter_lot: onchange returned by domain should use ids * rename field to `valid_lot_ids`. * add small readme --- rma_filter_lot/README.rst | 37 +++++++++++++++++++++++++ rma_filter_lot/models/rma_order_line.py | 10 +++---- rma_filter_lot/views/rma_order_view.xml | 2 +- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 rma_filter_lot/README.rst diff --git a/rma_filter_lot/README.rst b/rma_filter_lot/README.rst new file mode 100644 index 00000000..e36debc6 --- /dev/null +++ b/rma_filter_lot/README.rst @@ -0,0 +1,37 @@ +============== +RMA Filter Lot +============== + +Filter RMA lots in customer RMA to only allow lots sent to customer. + +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 +~~~~~~~ + +* ForgeFlow S.L. + +Contributors +~~~~~~~~~~~~ + +* Mateu Griful +* Lois Rilo + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the ForgeFlow. + +This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. + diff --git a/rma_filter_lot/models/rma_order_line.py b/rma_filter_lot/models/rma_order_line.py index f54dd0c8..d3283271 100644 --- a/rma_filter_lot/models/rma_order_line.py +++ b/rma_filter_lot/models/rma_order_line.py @@ -9,10 +9,9 @@ class RmaOrderLine(models.Model): _inherit = "rma.order.line" lot_id = fields.Many2one( - comodel_name="stock.production.lot", - domain="[('id', 'in', valid_lots_ids)]", + domain="[('id', 'in', valid_lot_ids)]", ) - valid_lots_ids = fields.One2many( + valid_lot_ids = fields.One2many( comodel_name="stock.production.lot", compute="_compute_domain_lot_ids", ) @@ -40,8 +39,9 @@ class RmaOrderLine(models.Model): valid_ids |= quant.lot_id if valid_ids: lots = valid_ids - rec.valid_lots_ids = lots + rec.valid_lot_ids = lots def _onchange_product_id(self): super()._onchange_product_id() - return {"domain": {"lot_id": [("id", "in", self.valid_lots_ids)]}} + # Override domain added in base `rma` module. + return {"domain": {"lot_id": [("id", "in", self.valid_lot_ids.ids)]}} diff --git a/rma_filter_lot/views/rma_order_view.xml b/rma_filter_lot/views/rma_order_view.xml index fef36976..cef3c835 100644 --- a/rma_filter_lot/views/rma_order_view.xml +++ b/rma_filter_lot/views/rma_order_view.xml @@ -6,7 +6,7 @@ - + From 99c01501694515f772991f32e3a548e71b034057 Mon Sep 17 00:00:00 2001 From: Jasmin Solanki Date: Mon, 10 Jan 2022 13:23:11 +0530 Subject: [PATCH 3/5] [MIG] rma_filter_lot: Migration to 15.0 --- rma_filter_lot/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rma_filter_lot/__manifest__.py b/rma_filter_lot/__manifest__.py index 3773e24d..c7366a60 100644 --- a/rma_filter_lot/__manifest__.py +++ b/rma_filter_lot/__manifest__.py @@ -3,7 +3,7 @@ { "name": "RMA Filter Lot", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "license": "LGPL-3", "category": "RMA", "summary": "Filter RMA lots", From 68e870c26a2b4bd3a6a12576112c607864102c3c Mon Sep 17 00:00:00 2001 From: DavidJForgeFlow Date: Wed, 8 Jan 2025 12:06:54 +0100 Subject: [PATCH 4/5] [IMP] rma_filter_lot: pre-commit stuff --- rma_filter_lot/README.rst | 50 ++- rma_filter_lot/__manifest__.py | 2 +- rma_filter_lot/pyproject.toml | 3 + rma_filter_lot/readme/CONTRIBUTORS.md | 2 + rma_filter_lot/readme/CONTRIBUTORS.rst | 2 - rma_filter_lot/readme/DESCRIPTION.md | 3 + rma_filter_lot/readme/DESCRIPTION.rst | 2 - rma_filter_lot/static/description/index.html | 418 +++++++++++++++++++ 8 files changed, 465 insertions(+), 17 deletions(-) create mode 100644 rma_filter_lot/pyproject.toml create mode 100644 rma_filter_lot/readme/CONTRIBUTORS.md delete mode 100644 rma_filter_lot/readme/CONTRIBUTORS.rst create mode 100644 rma_filter_lot/readme/DESCRIPTION.md delete mode 100644 rma_filter_lot/readme/DESCRIPTION.rst create mode 100644 rma_filter_lot/static/description/index.html diff --git a/rma_filter_lot/README.rst b/rma_filter_lot/README.rst index e36debc6..057ef411 100644 --- a/rma_filter_lot/README.rst +++ b/rma_filter_lot/README.rst @@ -2,15 +2,42 @@ RMA Filter Lot ============== -Filter RMA lots in customer RMA to only allow lots sent to customer. +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5967cd7bfff06a7f473e981a345743e4347878f87dc37615e2ea4671edaeab1c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-ForgeFlow%2Fstock--rma-lightgray.png?logo=github + :target: https://github.com/ForgeFlow/stock-rma/tree/17.0/rma_filter_lot + :alt: ForgeFlow/stock-rma + +|badge1| |badge2| |badge3| + +This module filters the lots in the rma by searching if there are units +of the selected product in any customer location in order to ease the +search. + +**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 smashing it by providing a detailed and welcomed -`feedback `_. +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. @@ -18,20 +45,19 @@ Credits ======= Authors -~~~~~~~ +------- -* ForgeFlow S.L. +* ForgeFlow Contributors -~~~~~~~~~~~~ +------------ -* Mateu Griful -* Lois Rilo +- Mateu Griful +- Lois Rilo Maintainers -~~~~~~~~~~~ +----------- -This module is maintained by the ForgeFlow. - -This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. +This module is part of the `ForgeFlow/stock-rma `_ project on GitHub. +You are welcome to contribute. diff --git a/rma_filter_lot/__manifest__.py b/rma_filter_lot/__manifest__.py index c7366a60..c12e81fa 100644 --- a/rma_filter_lot/__manifest__.py +++ b/rma_filter_lot/__manifest__.py @@ -8,7 +8,7 @@ "category": "RMA", "summary": "Filter RMA lots", "author": "ForgeFlow", - "website": "https://github.com/ForgeFlow/stock-rma", + "website": "https://github.com/ForgeFlow", "depends": ["rma"], "data": [ "views/rma_order_view.xml", diff --git a/rma_filter_lot/pyproject.toml b/rma_filter_lot/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/rma_filter_lot/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/rma_filter_lot/readme/CONTRIBUTORS.md b/rma_filter_lot/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..ec3dfeec --- /dev/null +++ b/rma_filter_lot/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Mateu Griful \<\> +- Lois Rilo \<\> diff --git a/rma_filter_lot/readme/CONTRIBUTORS.rst b/rma_filter_lot/readme/CONTRIBUTORS.rst deleted file mode 100644 index 087dd292..00000000 --- a/rma_filter_lot/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,2 +0,0 @@ -* Mateu Griful -* Lois Rilo diff --git a/rma_filter_lot/readme/DESCRIPTION.md b/rma_filter_lot/readme/DESCRIPTION.md new file mode 100644 index 00000000..4ccafd29 --- /dev/null +++ b/rma_filter_lot/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module filters the lots in the rma by searching if there are units +of the selected product in any customer location in order to ease the +search. diff --git a/rma_filter_lot/readme/DESCRIPTION.rst b/rma_filter_lot/readme/DESCRIPTION.rst deleted file mode 100644 index c6c49173..00000000 --- a/rma_filter_lot/readme/DESCRIPTION.rst +++ /dev/null @@ -1,2 +0,0 @@ -This module filters the lots in the rma by searching if there are units of the selected product in any customer -location in order to ease the search. diff --git a/rma_filter_lot/static/description/index.html b/rma_filter_lot/static/description/index.html new file mode 100644 index 00000000..d3fe1b83 --- /dev/null +++ b/rma_filter_lot/static/description/index.html @@ -0,0 +1,418 @@ + + + + + +RMA Filter Lot + + + +
+

RMA Filter Lot

+ + +

Beta License: LGPL-3 ForgeFlow/stock-rma

+

This module filters the lots in the rma by searching if there are units +of the selected product in any customer location in order to ease the +search.

+

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
  • +
+
+ +
+

Maintainers

+

This module is part of the ForgeFlow/stock-rma project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + From 2684d83bf3ffba0b292d1e308ef943926394bb27 Mon Sep 17 00:00:00 2001 From: DavidJForgeFlow Date: Wed, 8 Jan 2025 12:38:16 +0100 Subject: [PATCH 5/5] [MIG] rma_filter_lot: Migration to 17.0 Moved the domain from the python declaration to xml view field to match base changes (https://github.com/ForgeFlow/stock-rma/commit/6c67346b084c7764e2904b247b6c9b3dc0598cd8). --- rma_filter_lot/__manifest__.py | 4 ++-- rma_filter_lot/models/rma_order_line.py | 13 ++++--------- rma_filter_lot/views/rma_order_view.xml | 5 +++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rma_filter_lot/__manifest__.py b/rma_filter_lot/__manifest__.py index c12e81fa..6911eda1 100644 --- a/rma_filter_lot/__manifest__.py +++ b/rma_filter_lot/__manifest__.py @@ -1,9 +1,9 @@ -# Copyright 2021 ForgeFlow S.L. +# Copyright 2021-24 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) { "name": "RMA Filter Lot", - "version": "15.0.1.0.0", + "version": "17.0.1.0.0", "license": "LGPL-3", "category": "RMA", "summary": "Filter RMA lots", diff --git a/rma_filter_lot/models/rma_order_line.py b/rma_filter_lot/models/rma_order_line.py index d3283271..b5a42ab0 100644 --- a/rma_filter_lot/models/rma_order_line.py +++ b/rma_filter_lot/models/rma_order_line.py @@ -1,4 +1,4 @@ -# Copyright 2021 ForgeFlow S.L. +# Copyright 2021-24 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from odoo import api, fields, models @@ -8,27 +8,22 @@ from odoo.tools import float_compare class RmaOrderLine(models.Model): _inherit = "rma.order.line" - lot_id = fields.Many2one( - domain="[('id', 'in', valid_lot_ids)]", - ) valid_lot_ids = fields.One2many( - comodel_name="stock.production.lot", + comodel_name="stock.lot", compute="_compute_domain_lot_ids", ) @api.depends("product_id") def _compute_domain_lot_ids(self): for rec in self: - lots = rec.env["stock.production.lot"].search( - [("product_id", "=", rec.product_id.id)] - ) + lots = rec.env["stock.lot"].search([("product_id", "=", rec.product_id.id)]) if ( lots and rec.type == "customer" and rec.product_id and rec.product_id.tracking != "none" ): - valid_ids = self.env["stock.production.lot"] + valid_ids = self.env["stock.lot"] for quant in rec.product_id.stock_quant_ids: if ( float_compare(quant.available_quantity, 0.0, precision_digits=2) diff --git a/rma_filter_lot/views/rma_order_view.xml b/rma_filter_lot/views/rma_order_view.xml index cef3c835..15e85bde 100644 --- a/rma_filter_lot/views/rma_order_view.xml +++ b/rma_filter_lot/views/rma_order_view.xml @@ -8,6 +8,11 @@ + + [('product_id', '=', product_id),('id','in',valid_lot_ids)] +