mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
Merge pull request #183 from ForgeFlow/14.0-add-rma_filter_lot-2
[14.0][ADD] rma_filter_lot: add filter
This commit is contained in:
4
rma_filter_lot/__init__.py
Normal file
4
rma_filter_lot/__init__.py
Normal file
@@ -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
|
||||
17
rma_filter_lot/__manifest__.py
Normal file
17
rma_filter_lot/__manifest__.py
Normal file
@@ -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,
|
||||
}
|
||||
1
rma_filter_lot/models/__init__.py
Normal file
1
rma_filter_lot/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import rma_order_line
|
||||
47
rma_filter_lot/models/rma_order_line.py
Normal file
47
rma_filter_lot/models/rma_order_line.py
Normal file
@@ -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)]}}
|
||||
2
rma_filter_lot/readme/CONTRIBUTORS.rst
Normal file
2
rma_filter_lot/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1,2 @@
|
||||
* Mateu Griful <mateu.griful@forgeflow.com>
|
||||
* Lois Rilo <lois.rilo@forgeflow.com>
|
||||
2
rma_filter_lot/readme/DESCRIPTION.rst
Normal file
2
rma_filter_lot/readme/DESCRIPTION.rst
Normal file
@@ -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.
|
||||
13
rma_filter_lot/views/rma_order_view.xml
Normal file
13
rma_filter_lot/views/rma_order_view.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<record id="view_rma_line_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.form</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="valid_lots_ids" invisible="1" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
1
setup/rma_filter_lot/odoo/addons/rma_filter_lot
Symbolic link
1
setup/rma_filter_lot/odoo/addons/rma_filter_lot
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../rma_filter_lot
|
||||
6
setup/rma_filter_lot/setup.py
Normal file
6
setup/rma_filter_lot/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user