forked from OCA/stock-logistics-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '12.0-add-module-stock_picking_filter_lot_qty' of git+ss…
…h://github.com/efatto/stock-logistics-workflow into 12.0
- Loading branch information
Showing
16 changed files
with
730 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_picking_filter_lot_qty/odoo/addons/stock_picking_filter_lot_qty
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_picking_filter_lot_qty |
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,82 @@ | ||
============================ | ||
Stock picking filter lot qty | ||
============================ | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fstock--logistics--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-workflow/tree/12.0/stock_picking_filter_lot_qty | ||
:alt: OCA/stock-logistics-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-12-0/stock-logistics-workflow-12-0-stock_picking_filter_lot_qty | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/154/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends the functionality of stock: in a picking out or a scrap the user can only select the lots with available quantity in the origin location, depending on the option enabled in picking type. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To use this module: | ||
|
||
#. Go in a Picking type operation and enable `Use available lots`, which automatically enable `Use existing lots`, and/or `Use location lots`. | ||
#. Go to an open picking or a scrap with products that are tracked by lots, which uses the Picking operation type above. | ||
#. When you enter detailed operations you will notice that the lots available to select are filtered by available qty and the origin of the operation, depending on the option enabled in the picking type. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_picking_filter_lot_qty%0Aversion:%2012.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 | ||
~~~~~~~ | ||
|
||
* Sergio Corato | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Sergio Corato <https://github.com/sergiocorato> | ||
|
||
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/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/12.0/stock_picking_filter_lot_qty>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 @@ | ||
from . import models |
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 2022 Sergio Corato <https://github.com/sergiocorato> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Stock picking filter lot qty", | ||
"summary": "Stock lot filter only available", | ||
"version": "12.0.1.0.0", | ||
"category": "Warehouse", | ||
"website": "https://github.com/OCA/stock-logistics-workflow" | ||
"12.0/stock_picking_filter_lot_qty", | ||
"author": "Sergio Corato," | ||
"Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"stock_picking_filter_lot", | ||
], | ||
"data": [ | ||
"views/stock_view.xml", | ||
], | ||
} |
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,68 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_picking_filter_lot_qty | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2022-11-07 08:36+0000\n" | ||
"PO-Revision-Date: 2022-11-07 08:36+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_picking_filter_lot_qty | ||
#: model:ir.model.fields,field_description:stock_picking_filter_lot_qty.field_stock_move_line__available_lot_ids | ||
msgid "Available Lot" | ||
msgstr "Lotti Disponibili" | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model.fields,help:stock_picking_filter_lot_qty.field_stock_picking_type__use_available_lots | ||
msgid "Extends the Use existing lots option by filtering only those with available quantity." | ||
msgstr "Estende l'opzione Usa lotti esistenti filtrando solo quelli con quantità disponibile." | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model.fields,help:stock_picking_filter_lot_qty.field_stock_picking_type__use_location_lots | ||
msgid "Filters only the lots on origin location and its children." | ||
msgstr "Filtra solo i lotti nell'ubicazione di origine e sue figlie." | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model,name:stock_picking_filter_lot_qty.model_stock_production_lot | ||
msgid "Lot/Serial" | ||
msgstr "Lotto/Serie" | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model,name:stock_picking_filter_lot_qty.model_stock_picking_type | ||
msgid "Picking Type" | ||
msgstr "Tipo di prelievo" | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model,name:stock_picking_filter_lot_qty.model_stock_move_line | ||
msgid "Product Moves (Stock Move Line)" | ||
msgstr "Movimenti prodotto (riga movimento magazzino)" | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model.fields,field_description:stock_picking_filter_lot_qty.field_stock_production_lot__product_qty | ||
msgid "Quantity" | ||
msgstr "Quantità" | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model.fields,field_description:stock_picking_filter_lot_qty.field_stock_picking_type__use_available_lots | ||
msgid "Use Available Lots" | ||
msgstr "Utilizza Lotti Disponibili" | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: model:ir.model.fields,field_description:stock_picking_filter_lot_qty.field_stock_picking_type__use_location_lots | ||
msgid "Use Location Lots" | ||
msgstr "Usa Lotti in Ubicazione" | ||
|
||
#. module: stock_picking_filter_lot_qty | ||
#: code:addons/stock_picking_filter_lot_qty/models/stock_picking_type.py:26 | ||
#, python-format | ||
msgid "Use available lots can be activated only if Use existing lots is enabled." | ||
msgstr "Utilizza lotti disponibili può essere attivato solo se attivo Utilizza lotti esistenti." | ||
|
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,3 @@ | ||
from . import stock_move_line | ||
from . import stock_picking_type | ||
from . import stock_production_lot |
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,20 @@ | ||
from odoo import api, fields, models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = 'stock.move.line' | ||
|
||
available_lot_ids = fields.Many2many( | ||
'stock.production.lot', | ||
compute='_compute_available_lot_ids' | ||
) | ||
|
||
@api.depends('product_id') | ||
def _compute_available_lot_ids(self): | ||
for line in self: | ||
domain = [('product_id', '=', line.product_id.id)] | ||
if line.picking_id.picking_type_id.use_location_lots: | ||
domain.extend([('location_ids', 'child_of', line.location_id.id)]) | ||
if line.picking_id.picking_type_id.use_available_lots: | ||
domain.extend([('product_qty', '>', 0)]) | ||
line.available_lot_ids = self.env['stock.production.lot'].search(domain).ids |
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 @@ | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class StockPickingType(models.Model): | ||
_inherit = 'stock.picking.type' | ||
|
||
use_available_lots = fields.Boolean( | ||
help="Extends the Use existing lots option by filtering only those with " | ||
"available quantity." | ||
) | ||
use_location_lots = fields.Boolean( | ||
help="Filters only the lots on origin location and its children." | ||
) | ||
|
||
@api.onchange('use_available_lots') | ||
def onchange_use_available_lots(self): | ||
if self.use_available_lots: | ||
self.use_existing_lots = True | ||
|
||
@api.multi | ||
@api.constrains('use_available_lots', 'use_existing_lots') | ||
def check_available_lots(self): | ||
for record in self: | ||
if record.use_available_lots and not record.use_existing_lots: | ||
raise ValidationError(_( | ||
"Use available lots can be activated only if Use existing lots is " | ||
"enabled." | ||
)) |
21 changes: 21 additions & 0 deletions
21
stock_picking_filter_lot_qty/models/stock_production_lot.py
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 2022 Sergio Corato <https://github.com/sergiocorato> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
from odoo.addons.stock.models.product import OPERATORS | ||
|
||
|
||
class ProductionLot(models.Model): | ||
_inherit = 'stock.production.lot' | ||
|
||
product_qty = fields.Float(search='_search_product_qty') | ||
|
||
def _search_product_qty(self, operator, value): | ||
lot_ids = [] | ||
quants = self.env['stock.quant'].read_group([ | ||
('location_id.usage', 'in', ['internal', 'transit']), | ||
('lot_id', '!=', False), | ||
], ['lot_id', 'quantity'], ['lot_id']) | ||
if operator in OPERATORS: | ||
lot_ids = [x['lot_id'][0] for x in quants if OPERATORS[operator]( | ||
x['quantity'], value)] | ||
return [('id', 'in', lot_ids)] |
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 @@ | ||
* Sergio Corato <https://github.com/sergiocorato> |
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 @@ | ||
This module extends the functionality of stock: in a picking out or a scrap the user can only select the lots with available quantity in the origin location, depending on the option enabled in picking type. |
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,5 @@ | ||
To use this module: | ||
|
||
#. Go in a Picking type operation and enable `Use available lots`, which automatically enable `Use existing lots`, and/or `Use location lots`. | ||
#. Go to an open picking or a scrap with products that are tracked by lots, which uses the Picking operation type above. | ||
#. When you enter detailed operations you will notice that the lots available to select are filtered by available qty and the origin of the operation, depending on the option enabled in the picking type. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.