Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions rma_sale_lot/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
============
Rma Sale Lot
============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b78509745350922121af05dc007a0cbd04294051b18538e0e52ba5ce0eb984c4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-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%2Frma-lightgray.png?logo=github
:target: https://github.com/OCA/rma/tree/18.0/rma_sale_lot
:alt: OCA/rma
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rma-18-0/rma-18-0-rma_sale_lot
: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/rma&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the rma_lot module by integrating lot tracking into
the return wizard in the sales orders. It assists salespeople in
accurately recording returns by ensuring that customers are returning
the correct lot that was originally delivered.

This enhancement improves both tracking and inventory accuracy, leading
to more efficient and reliable return processing.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/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/OCA/rma/issues/new?body=module:%20rma_sale_lot%0Aversion:%2018.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
-------

* ACSONE SA/NV
* BCIM

Contributors
------------

- Jacques-Etienne Baudoux - BCIM je@bcim.be
- Souheil Bejaoui - ACSONE SA/NV souheil.bejaoui@acsone.eu

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/rma <https://github.com/OCA/rma/tree/18.0/rma_sale_lot>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions rma_sale_lot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import wizards
from . import models
15 changes: 15 additions & 0 deletions rma_sale_lot/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 ACSONE SA/NV,BCIM
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Rma Sale Lot",
"summary": """
Manage sale returns with lot.""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,BCIM,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/rma",
"depends": ["rma_lot", "rma_sale"],
"data": ["wizards/sale_order_rma_wizard.xml"],
"demo": [],
}
42 changes: 42 additions & 0 deletions rma_sale_lot/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rma_sale_lot
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-10-21 10:06+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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: rma_sale_lot
#: model:ir.model.fields,field_description:rma_sale_lot.field_sale_order_line_rma_wizard__lot_id
msgid "Lot/Serial Number"
msgstr "Numero di lotto/serie"

#. module: rma_sale_lot
#: model:ir.model.fields,field_description:rma_sale_lot.field_sale_order_line_rma_wizard__lots_visible
msgid "Lots Visible"
msgstr "Lotti visibili"

#. module: rma_sale_lot
#: model:ir.model,name:rma_sale_lot.model_sale_order_line_rma_wizard
msgid "Sale Order Line Rma Wizard"
msgstr "Procedura guidata RMA riga ordine di vendita"

#. module: rma_sale_lot
#: model:ir.model,name:rma_sale_lot.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"

#. module: rma_sale_lot
#: model:ir.model,name:rma_sale_lot.model_sale_order_line
msgid "Sales Order Line"
msgstr "Riga ordine di vendita"
39 changes: 39 additions & 0 deletions rma_sale_lot/i18n/rma_sale_lot.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rma_sale_lot
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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: rma_sale_lot
#: model:ir.model.fields,field_description:rma_sale_lot.field_sale_order_line_rma_wizard__lot_id
msgid "Lot/Serial Number"
msgstr ""

#. module: rma_sale_lot
#: model:ir.model.fields,field_description:rma_sale_lot.field_sale_order_line_rma_wizard__lots_visible
msgid "Lots Visible"
msgstr ""

#. module: rma_sale_lot
#: model:ir.model,name:rma_sale_lot.model_sale_order_line_rma_wizard
msgid "Sale Order Line Rma Wizard"
msgstr ""

#. module: rma_sale_lot
#: model:ir.model,name:rma_sale_lot.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: rma_sale_lot
#: model:ir.model,name:rma_sale_lot.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
2 changes: 2 additions & 0 deletions rma_sale_lot/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import sale_order_line
from . import sale_order
13 changes: 13 additions & 0 deletions rma_sale_lot/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class SaleOrder(models.Model):
_inherit = "sale.order"

def _prepare_rma_wizard_line_vals(self, data):
vals = super()._prepare_rma_wizard_line_vals(data)
vals["lot_id"] = data.get("lot_id")
return vals
74 changes: 74 additions & 0 deletions rma_sale_lot/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from collections import defaultdict

from odoo import models
from odoo.tools.float_utils import float_round


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _get_qty_done_by_product_lot(self, moves):
res = defaultdict(float)
for group in self.env["stock.move.line"].read_group(
[
("move_id", "in", moves.ids),
("state", "=", "done"),
("move_id.scrapped", "=", False),
],
["quantity:sum"],
["product_id", "lot_id"],
lazy=False,
):
lot_id = group.get("lot_id")[0] if group.get("lot_id") else False
product_id = group.get("product_id")[0]
quantity = group.get("quantity")
res[(product_id, lot_id)] += quantity
return res

def prepare_sale_rma_data(self):
self.ensure_one()
if self.product_id.type not in ["product", "consu"]:
return {}
if not self.product_id.tracking or self.product_id.tracking == "none":
return super().prepare_sale_rma_data()
moves = self.get_delivery_move()
data = []
qty_done_by_product_lot = self._get_qty_done_by_product_lot(moves)
for (product_id, lot_id), qty_done in qty_done_by_product_lot.items():
data.append(
self._prepare_sale_rma_data_line(moves, product_id, lot_id, qty_done)
)
return data

def _prepare_sale_rma_data_line(self, moves, product_id, lot_id, qty_done):
moves = moves.move_line_ids.filtered(
lambda ml, p_id=product_id, l_id=lot_id: ml.product_id.id == p_id
and ml.lot_id.id == l_id
).move_id
quantity = qty_done
for returned_move in moves.returned_move_ids.filtered(
lambda r: r.state in ["partially_available", "assigned", "done"]
):
if (
returned_move.restrict_lot_id
and returned_move.restrict_lot_id.id == lot_id
or not lot_id
):
if returned_move.state in ("partially_available", "assigned"):
quantity -= sum(returned_move.move_line_ids.mapped("quantity"))
elif returned_move.state == "done":
quantity -= returned_move.product_qty
quantity = float_round(
quantity, precision_rounding=moves.product_id.uom_id.rounding
)
return {
"product": moves.product_id,
"quantity": quantity,
"uom": moves.product_uom,
"picking": moves.picking_id[0],
"sale_line_id": self,
"lot_id": lot_id,
}
3 changes: 3 additions & 0 deletions rma_sale_lot/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions rma_sale_lot/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Jacques-Etienne Baudoux - BCIM <je@bcim.be>
- Souheil Bejaoui - ACSONE SA/NV <souheil.bejaoui@acsone.eu>
7 changes: 7 additions & 0 deletions rma_sale_lot/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module extends the rma_lot module by integrating lot tracking into the
return wizard in the sales orders. It assists salespeople in accurately
recording returns by ensuring that customers are returning the correct lot that
was originally delivered.

This enhancement improves both tracking and inventory accuracy, leading to
more efficient and reliable return processing.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading