-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #571 from ForgeFlow/17.0-mig-rma_filter_lot
[17.0][MIG] rma_filter_lot
- Loading branch information
Showing
10 changed files
with
571 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
============== | ||
RMA Filter Lot | ||
============== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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 <https://github.com/ForgeFlow/stock-rma/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 <https://github.com/ForgeFlow/stock-rma/issues/new?body=module:%20rma_filter_lot%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* ForgeFlow | ||
|
||
Contributors | ||
------------ | ||
|
||
- Mateu Griful <[email protected]> | ||
- Lois Rilo <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is part of the `ForgeFlow/stock-rma <https://github.com/ForgeFlow/stock-rma/tree/17.0/rma_filter_lot>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2021-24 ForgeFlow S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
{ | ||
"name": "RMA Filter Lot", | ||
"version": "17.0.1.0.0", | ||
"license": "LGPL-3", | ||
"category": "RMA", | ||
"summary": "Filter RMA lots", | ||
"author": "ForgeFlow", | ||
"website": "https://github.com/ForgeFlow", | ||
"depends": ["rma"], | ||
"data": [ | ||
"views/rma_order_view.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import rma_order_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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 | ||
from odoo.tools import float_compare | ||
|
||
|
||
class RmaOrderLine(models.Model): | ||
_inherit = "rma.order.line" | ||
|
||
valid_lot_ids = fields.One2many( | ||
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.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.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_lot_ids = lots | ||
|
||
def _onchange_product_id(self): | ||
super()._onchange_product_id() | ||
# Override domain added in base `rma` module. | ||
return {"domain": {"lot_id": [("id", "in", self.valid_lot_ids.ids)]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Mateu Griful \<<[email protected]>\> | ||
- Lois Rilo \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Oops, something went wrong.