Skip to content
Open
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
85 changes: 85 additions & 0 deletions mrp_unbuild_lot_location/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
========================
MRP Unbuild Lot Location
========================

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

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

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

When a lot/serial number is selected on an unbuild order, this module
filters the available source locations to only those where the
lot/serial number is currently stocked.

If stock exists in a single location, it is automatically set as the
source location. If stock exists in multiple locations, the list is
narrowed down for the user to choose from. A warning is displayed if
no stock is found for the selected lot/serial number.

**Table of contents**

.. contents::
:local:

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

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

* Quartile

Contributors
~~~~~~~~~~~~

* `Quartile <https://www.quartile.co>`_:
* Toshikimi Shigenobu
* Aung Ko Ko Lin

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/manufacture <https://github.com/OCA/manufacture/tree/16.0/mrp_unbuild_lot_location>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions mrp_unbuild_lot_location/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
14 changes: 14 additions & 0 deletions mrp_unbuild_lot_location/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "MRP Unbuild Lot Location",
"summary": "Filter unbuild source locations by lot/serial stock",
"category": "Manufacturing",
"license": "AGPL-3",
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture",
"version": "16.0.1.0.0",
"depends": ["mrp"],
"data": ["views/mrp_unbuild_views.xml"],
"installable": True,
}
33 changes: 33 additions & 0 deletions mrp_unbuild_lot_location/i18n/ja.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_unbuild_lot_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-02-27 04:51+0000\n"
"PO-Revision-Date: 2026-02-27 04:51+0000\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: mrp_unbuild_lot_location
#: model:ir.model.fields,field_description:mrp_unbuild_lot_location.field_mrp_unbuild__location_id_domain
msgid "Location Id Domain"
msgstr "ロケーションIDドメイン"

#. module: mrp_unbuild_lot_location
#. odoo-python
#: code:addons/mrp_unbuild_lot_location/models/mrp_unbuild.py:0
#, python-format
msgid "No stock found for lot/serial number %s."
msgstr "ロット/シリアル番号 %s の在庫がありません。"

#. module: mrp_unbuild_lot_location
#: model:ir.model,name:mrp_unbuild_lot_location.model_mrp_unbuild
msgid "Unbuild Order"
msgstr "解体オーダ"
1 change: 1 addition & 0 deletions mrp_unbuild_lot_location/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mrp_unbuild
63 changes: 63 additions & 0 deletions mrp_unbuild_lot_location/models/mrp_unbuild.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2026 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.osv import expression


class MrpUnbuild(models.Model):
_inherit = "mrp.unbuild"

location_id_domain = fields.Binary(compute="_compute_location_id_domain")

@api.depends("lot_id", "product_id", "company_id")
def _compute_location_id_domain(self):
for record in self:
# Standard location filter (applies even without a lot)
base_domain = [
("usage", "in", ["internal", "transit"]),
"|",
("company_id", "=", False),
("company_id", "=", record.company_id.id),
]
if record.lot_id:
location_ids = (
self.env["stock.quant"]
.search(
[
("product_id", "=", record.product_id.id),
("lot_id", "=", record.lot_id.id),
("quantity", ">", 0),
]
)
.location_id.ids
)
base_domain = expression.AND(
[
base_domain,
[("id", "in", location_ids)],
]
)
record.location_id_domain = base_domain

@api.depends("company_id", "location_id_domain")
def _compute_location_id(self):
super()._compute_location_id()
for record in self.filtered("lot_id"):
locations = self.env["stock.location"].search(record.location_id_domain)
if len(locations) == 1:
record.location_id = locations
return

@api.constrains("lot_id")
def _check_lot_location(self):
for record in self:
if not record.lot_id:
continue
if not self.env["stock.location"].search(
record.location_id_domain, limit=1
):
raise ValidationError(
_("No stock found for lot/serial number %s.") % record.lot_id.name
)
3 changes: 3 additions & 0 deletions mrp_unbuild_lot_location/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Quartile <https://www.quartile.co>`_:
* Toshikimi Shigenobu
* Aung Ko Ko Lin
8 changes: 8 additions & 0 deletions mrp_unbuild_lot_location/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
When a lot/serial number is selected on an unbuild order, this module
filters the available source locations to only those where the
lot/serial number is currently stocked.

If stock exists in a single location, it is automatically set as the
source location. If stock exists in multiple locations, the list is
narrowed down for the user to choose from. A warning is displayed if
no stock is found for the selected lot/serial number.
Loading
Loading