-
Notifications
You must be signed in to change notification settings - Fork 0
[7003][ADD] stock_lot_top_parent: trace top-level parent on lots/serials #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| ../../../../stock_lot_top_parent |
This file contains hidden or 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,6 @@ | ||
| import setuptools | ||
|
|
||
| setuptools.setup( | ||
| setup_requires=['setuptools-odoo'], | ||
| odoo_addon=True, | ||
| ) |
This file contains hidden or 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,79 @@ | ||
| ==================== | ||
| Stock Lot Top Parent | ||
| ==================== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:94b5d1f66e4e12433572b8e103c9da3fcd341da805c3f922bde6e4d38e4478bc | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |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/license-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-qrtl%2Fthc--custom-lightgray.png?logo=github | ||
| :target: https://github.com/qrtl/thc-custom/tree/16.0/stock_lot_top_parent | ||
| :alt: qrtl/thc-custom | ||
|
|
||
| |badge1| |badge2| |badge3| | ||
|
|
||
| This module adds top-level parent traceability fields to lots/serials | ||
| (*Inventory > Products > Lots/Serial Numbers*): | ||
|
|
||
| - **Top lv Parent S/N**: the serial number (lot) of the top-level parent | ||
| assembly this lot belongs to. | ||
| - **Top lv Parent P/N**: the product of the top-level parent serial (a | ||
| related field, kept in sync automatically). | ||
| - **Physical Location**: the current internal location(s) of the | ||
| top-level parent serial, computed on the fly from stock quants. It is | ||
| empty when the parent serial is not stored in any internal location. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/qrtl/thc-custom/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/qrtl/thc-custom/issues/new?body=module:%20stock_lot_top_parent%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 | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| .. |maintainer-nobuQuartile| image:: https://github.com/nobuQuartile.png?size=40px | ||
| :target: https://github.com/nobuQuartile | ||
| :alt: nobuQuartile | ||
|
|
||
| Current maintainer: | ||
|
|
||
| |maintainer-nobuQuartile| | ||
|
|
||
| This module is part of the `qrtl/thc-custom <https://github.com/qrtl/thc-custom/tree/16.0/stock_lot_top_parent>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. |
This file contains hidden or 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 models |
This file contains hidden or 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,18 @@ | ||
| # Copyright 2026 Quartile (https://www.quartile.co) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
| { | ||
| "name": "Stock Lot Top Parent", | ||
| "summary": "Track the top-level parent serial, part number and current " | ||
| "physical location on lots/serials.", | ||
| "version": "16.0.1.0.0", | ||
| "category": "Inventory", | ||
| "license": "AGPL-3", | ||
| "author": "Quartile", | ||
| "website": "https://www.quartile.co", | ||
| "maintainers": ["nobuQuartile"], | ||
| "depends": ["stock"], | ||
| "data": [ | ||
| "views/stock_lot_views.xml", | ||
| ], | ||
| "installable": True, | ||
| } |
This file contains hidden or 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,53 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * stock_lot_top_parent | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 16.0+e\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2026-07-24 02:47+0000\n" | ||
| "PO-Revision-Date: 2026-07-24 02:47+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: stock_lot_top_parent | ||
| #: model:ir.model.fields,help:stock_lot_top_parent.field_stock_lot__top_parent_location_ids | ||
| msgid "" | ||
| "Current internal locations of Top lv Parent S/N, or of this lot itself when " | ||
| "it has no parent. Empty when it is not stored in any internal location." | ||
| msgstr "トップレベル親 S/N(親がない場合はこのロット自身)の現在の内部ロケーション。いずれの内部ロケーションにも保管されていない場合は空欄。" | ||
|
|
||
| #. module: stock_lot_top_parent | ||
| #: model:ir.model,name:stock_lot_top_parent.model_stock_lot | ||
| msgid "Lot/Serial" | ||
| msgstr "ロット/シリアル" | ||
|
|
||
| #. module: stock_lot_top_parent | ||
| #: model:ir.model.fields,field_description:stock_lot_top_parent.field_stock_lot__top_parent_location_ids | ||
| msgid "Physical Location" | ||
| msgstr "物理ロケーション" | ||
|
|
||
| #. module: stock_lot_top_parent | ||
| #: model:ir.model.fields,help:stock_lot_top_parent.field_stock_lot__top_parent_lot_id | ||
| msgid "Serial number of the top-level parent assembly this lot belongs to." | ||
| msgstr "このロットが属するトップレベル親アセンブリのシリアル番号。" | ||
|
|
||
| #. module: stock_lot_top_parent | ||
| #: model_terms:ir.ui.view,arch_db:stock_lot_top_parent.stock_lot_view_form | ||
| msgid "Top Level Parent" | ||
| msgstr "トップレベル親" | ||
|
|
||
| #. module: stock_lot_top_parent | ||
| #: model:ir.model.fields,field_description:stock_lot_top_parent.field_stock_lot__top_parent_product_id | ||
| msgid "Top lv Parent P/N" | ||
| msgstr "トップレベル親 P/N" | ||
|
|
||
| #. module: stock_lot_top_parent | ||
| #: model:ir.model.fields,field_description:stock_lot_top_parent.field_stock_lot__top_parent_lot_id | ||
| msgid "Top lv Parent S/N" | ||
| msgstr "トップレベル親 S/N" |
This file contains hidden or 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 stock_lot |
This file contains hidden or 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,44 @@ | ||||||||||||||||||||||||||||||
| # 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 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class StockLot(models.Model): | ||||||||||||||||||||||||||||||
| _inherit = "stock.lot" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| top_parent_lot_id = fields.Many2one( | ||||||||||||||||||||||||||||||
| "stock.lot", | ||||||||||||||||||||||||||||||
| string="Top lv Parent S/N", | ||||||||||||||||||||||||||||||
| help="Serial number of the top-level parent assembly this lot belongs to.", | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
nobuQuartile marked this conversation as resolved.
|
||||||||||||||||||||||||||||||
| top_parent_product_id = fields.Many2one( | ||||||||||||||||||||||||||||||
|
nobuQuartile marked this conversation as resolved.
|
||||||||||||||||||||||||||||||
| "product.product", | ||||||||||||||||||||||||||||||
| related="top_parent_lot_id.product_id", | ||||||||||||||||||||||||||||||
| string="Top lv Parent P/N", | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| top_parent_location_ids = fields.Many2many( | ||||||||||||||||||||||||||||||
|
nobuQuartile marked this conversation as resolved.
|
||||||||||||||||||||||||||||||
| "stock.location", | ||||||||||||||||||||||||||||||
| string="Physical Location", | ||||||||||||||||||||||||||||||
| compute="_compute_top_parent_location_ids", | ||||||||||||||||||||||||||||||
| help="Current internal locations of Top lv Parent S/N, or of this lot " | ||||||||||||||||||||||||||||||
| "itself when it has no parent. Empty when it is not stored in any " | ||||||||||||||||||||||||||||||
| "internal location.", | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| @api.depends("top_parent_lot_id") | ||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a major issue, but worth addressing it before we get hiccups.
Suggested change
|
||||||||||||||||||||||||||||||
| def _compute_top_parent_location_ids(self): | ||||||||||||||||||||||||||||||
| quant_model = self.env["stock.quant"] | ||||||||||||||||||||||||||||||
| for lot in self: | ||||||||||||||||||||||||||||||
| target_lot = lot.top_parent_lot_id or lot | ||||||||||||||||||||||||||||||
| if not target_lot.id: | ||||||||||||||||||||||||||||||
| lot.top_parent_location_ids = False | ||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||
| quants = quant_model.search( | ||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||
| ("lot_id", "=", target_lot.id), | ||||||||||||||||||||||||||||||
| ("location_id.usage", "=", "internal"), | ||||||||||||||||||||||||||||||
| ("quantity", ">", 0), | ||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+43
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| lot.top_parent_location_ids = quants.location_id | ||||||||||||||||||||||||||||||
This file contains hidden or 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 @@ | ||
| - [Quartile](https://www.quartile.co): | ||
| - Toshikimi Shigenobu |
This file contains hidden or 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,10 @@ | ||
| This module adds top-level parent traceability fields to lots/serials | ||
| (*Inventory > Products > Lots/Serial Numbers*): | ||
|
|
||
| - **Top lv Parent S/N**: the serial number (lot) of the top-level parent | ||
| assembly this lot belongs to. | ||
| - **Top lv Parent P/N**: the product of the top-level parent serial | ||
| (a related field, kept in sync automatically). | ||
| - **Physical Location**: the current internal location(s) of the top-level | ||
| parent serial, computed on the fly from stock quants. It is empty when | ||
| the parent serial is not stored in any internal location. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.