-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[16.0][ADD] stock_lot_last_move_locations: In stock lot new field "La…
…st Move Locations".
- Loading branch information
1 parent
7e09fff
commit d2b2eb9
Showing
14 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_lot_last_move_locations/odoo/addons/stock_lot_last_move_locations
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 @@ | ||
../../../../stock_lot_last_move_locations |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=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,29 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
============================= | ||
Stock lot last move locations | ||
============================= | ||
|
||
* In lots, new field "Last Move Locations", with the from and to locations of | ||
the last "stock move line" performed for that lot. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Ana Juaristi <anajuaristi@avanzosc.es> | ||
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es> |
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,18 @@ | ||
from . import models | ||
from odoo import api, SUPERUSER_ID | ||
|
||
|
||
def _post_install_put_last_move_locations_in_lots(cr, registry): | ||
""" | ||
This method will set the production cost on already done manufacturing orders. | ||
""" | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
lots = env["stock.lot"].search([]) | ||
for lot in lots: | ||
cond = [("qty_done", ">", 0), ("state", "=", "done"), ("lot_id", "=", lot.id)] | ||
lines = env["stock.move.line"].search(cond) | ||
if lines: | ||
latest_line = lines.sorted(key=lambda line: line.write_date, reverse=True)[ | ||
0 | ||
] | ||
latest_line._put_last_move_locations_in_lots() |
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,16 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Stock Lot Last Move Locations", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Avanzosc", | ||
"category": "Inventory/Inventory", | ||
"website": "https://github.com/avanzosc/odoo-addons", | ||
"depends": ["product", "stock"], | ||
"data": [ | ||
"views/stock_lot_views.xml", | ||
], | ||
"installable": True, | ||
"post_init_hook": "_post_install_put_last_move_locations_in_lots", | ||
} |
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,32 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_lot_last_move_locations | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-02 10:47+0000\n" | ||
"PO-Revision-Date: 2024-12-02 10: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_last_move_locations | ||
#: model:ir.model.fields,field_description:stock_lot_last_move_locations.field_stock_lot__last_move_locations | ||
#: model_terms:ir.ui.view,arch_db:stock_lot_last_move_locations.search_product_lot_filter | ||
msgid "Last Move Locations" | ||
msgstr "" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_lot | ||
msgid "Lot/Serial" | ||
msgstr "Lot/núm. de sèrie" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "Moviment del producte (línia de moviment d'estoc)" |
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,32 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_lot_last_move_locations | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-02 10:47+0000\n" | ||
"PO-Revision-Date: 2024-12-02 10: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_last_move_locations | ||
#: model:ir.model.fields,field_description:stock_lot_last_move_locations.field_stock_lot__last_move_locations | ||
#: model_terms:ir.ui.view,arch_db:stock_lot_last_move_locations.search_product_lot_filter | ||
msgid "Last Move Locations" | ||
msgstr "" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_lot | ||
msgid "Lot/Serial" | ||
msgstr "" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "" |
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,32 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_lot_last_move_locations | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-02 10:48+0000\n" | ||
"PO-Revision-Date: 2024-12-02 10:48+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_last_move_locations | ||
#: model:ir.model.fields,field_description:stock_lot_last_move_locations.field_stock_lot__last_move_locations | ||
#: model_terms:ir.ui.view,arch_db:stock_lot_last_move_locations.search_product_lot_filter | ||
msgid "Last Move Locations" | ||
msgstr "Ubic. Último Mvto." | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_lot | ||
msgid "Lot/Serial" | ||
msgstr "Lote/Número de serie" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "Movimientos de Producto (Stock Move 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,32 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_lot_last_move_locations | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-02 10:48+0000\n" | ||
"PO-Revision-Date: 2024-12-02 10:48+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_last_move_locations | ||
#: model:ir.model.fields,field_description:stock_lot_last_move_locations.field_stock_lot__last_move_locations | ||
#: model_terms:ir.ui.view,arch_db:stock_lot_last_move_locations.search_product_lot_filter | ||
msgid "Last Move Locations" | ||
msgstr "" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_lot | ||
msgid "Lot/Serial" | ||
msgstr "Lot/série" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "Mouvements de stock" |
32 changes: 32 additions & 0 deletions
32
stock_lot_last_move_locations/i18n/stock_lot_last_move_locations.pot
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,32 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_lot_last_move_locations | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-02 10:47+0000\n" | ||
"PO-Revision-Date: 2024-12-02 10: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_last_move_locations | ||
#: model:ir.model.fields,field_description:stock_lot_last_move_locations.field_stock_lot__last_move_locations | ||
#: model_terms:ir.ui.view,arch_db:stock_lot_last_move_locations.search_product_lot_filter | ||
msgid "Last Move Locations" | ||
msgstr "" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_lot | ||
msgid "Lot/Serial" | ||
msgstr "" | ||
|
||
#. module: stock_lot_last_move_locations | ||
#: model:ir.model,name:stock_lot_last_move_locations.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "" |
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 @@ | ||
from . import stock_lot | ||
from . import stock_move_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,9 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import fields, models | ||
|
||
|
||
class StockLot(models.Model): | ||
_inherit = "stock.lot" | ||
|
||
last_move_locations = fields.Char(copy=False) |
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,21 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
def write(self, vals): | ||
result = super().write(vals) | ||
if "qty_done" in vals: | ||
self._put_last_move_locations_in_lots() | ||
return result | ||
|
||
def _put_last_move_locations_in_lots(self): | ||
for line in self.filtered(lambda x: x.move_id.state == "done" and x.lot_id): | ||
last_move_locations = ("%s - %s") % ( | ||
line.location_id.name, | ||
line.location_dest_id.name, | ||
) | ||
line.lot_id.last_move_locations = last_move_locations |
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,40 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="view_production_lot_form" model="ir.ui.view"> | ||
<field name="model">stock.lot</field> | ||
<field name="inherit_id" ref="stock.view_production_lot_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="company_id" position="after"> | ||
<field name="last_move_locations" readonly="1" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="view_production_lot_tree" model="ir.ui.view"> | ||
<field name="model">stock.lot</field> | ||
<field name="inherit_id" ref="stock.view_production_lot_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="company_id" position="before"> | ||
<field name="last_move_locations" readonly="1" optional="show" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="search_product_lot_filter" model="ir.ui.view"> | ||
<field name="model">stock.lot</field> | ||
<field name="inherit_id" ref="stock.search_product_lot_filter" /> | ||
<field name="arch" type="xml"> | ||
<field name="product_id" position="after"> | ||
<field name="last_move_locations" /> | ||
</field> | ||
<filter name="group_by_product" position="after"> | ||
<filter | ||
name="group_last_move_locations" | ||
string="Last Move Locations" | ||
domain="[]" | ||
context="{'group_by': 'last_move_locations'}" | ||
/> | ||
</filter> | ||
</field> | ||
</record> | ||
</odoo> |