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
21 changes: 15 additions & 6 deletions stock_owner_restriction/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
Stock Owner Restriction
=======================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
Expand All @@ -19,11 +22,11 @@ Stock Owner Restriction
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_owner_restriction
: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/16.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

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

This module extends the functionality of stock module to allow restriction
of product quantities (quants) for stock operations such as reserve quantities
Expand All @@ -46,6 +49,12 @@ To configure this module you need to:
#. Select an operation type, or create a new one, and set *Owner Restriction*
field to the desired value.

Developers notes

This module update the context dependency of product quantity available to be computed
correctly. If you need get product quantity available for an owner yo need set the
context key "force_restricted_owner_id".

Usage
=====

Expand Down Expand Up @@ -91,7 +100,7 @@ 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
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_owner_restriction%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.
Expand Down
2 changes: 1 addition & 1 deletion stock_owner_restriction/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Stock Owner Restriction",
"summary": "Do not reserve quantity with assigned owner",
"version": "16.0.1.0.0",
"version": "16.0.1.1.2",
"development_status": "Beta",
"category": "stock",
"website": "https://github.com/OCA/stock-logistics-workflow",
Expand Down
31 changes: 21 additions & 10 deletions stock_owner_restriction/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-10 20:46+0000\n"
"PO-Revision-Date: 2020-11-10 21:48+0100\n"
"Last-Translator: Sergio Teruel <sergio.teruel@tecnativa.com>\n"
"PO-Revision-Date: 2023-10-15 20:38+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: \n"
"Language: es_ES\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.3\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: stock_owner_restriction
#: model:ir.model.fields,field_description:stock_owner_restriction.field_stock_picking__owner_restriction
#: model:ir.model.fields,field_description:stock_owner_restriction.field_stock_picking_type__owner_restriction
msgid "Owner restriction"
msgstr "Restricción de cantidad disponible"
msgid "Owner Restriction"
msgstr "Restricción del propietario"

#. module: stock_owner_restriction
#: model_terms:ir.ui.view,arch_db:stock_owner_restriction.view_picking_type_form
Expand All @@ -38,15 +38,20 @@ msgstr "Tipo de operación"
msgid "Picking partner"
msgstr "Dirección de entrega del albarán"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__partner_or_unassigned
msgid "Picking partner or unassigned owner"
msgstr ""

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_product_product
msgid "Product"
msgstr "Producto"
msgid "Product Variant"
msgstr "Variante del Producto"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_quant
msgid "Quants"
msgstr "Quants"
msgstr "Cants"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__standard_behavior
Expand All @@ -67,3 +72,9 @@ msgstr "Transferir"
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__unassigned_owner
msgid "Unassigned owner"
msgstr "Propietario no asignado"

#~ msgid "Owner restriction"
#~ msgstr "Restricción de cantidad disponible"

#~ msgid "Product"
#~ msgstr "Producto"
73 changes: 73 additions & 0 deletions stock_owner_restriction/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_owner_restriction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-01-31 16:05+0000\n"
"Last-Translator: Arnaud LAYEC <arnaudlayec@gmail.com>\n"
"Language-Team: none\n"
"Language: fr\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: stock_owner_restriction
#: model:ir.model.fields,field_description:stock_owner_restriction.field_stock_picking__owner_restriction
#: model:ir.model.fields,field_description:stock_owner_restriction.field_stock_picking_type__owner_restriction
msgid "Owner Restriction"
msgstr "Restriction de propriétaire"

#. module: stock_owner_restriction
#: model_terms:ir.ui.view,arch_db:stock_owner_restriction.view_picking_type_form
msgid "Owner settings"
msgstr "Paramètres de propriétaire"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_picking_type
msgid "Picking Type"
msgstr "Type de transfert"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__picking_partner
msgid "Picking partner"
msgstr "Contact du transfert"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__partner_or_unassigned
msgid "Picking partner or unassigned owner"
msgstr ""

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_product_product
msgid "Product Variant"
msgstr "Variante de produit"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_quant
msgid "Quants"
msgstr "Quantités"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__standard_behavior
msgid "Standard behavior"
msgstr "Comportement standard"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_move
msgid "Stock Move"
msgstr "Mouvement de stock"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_picking
msgid "Transfer"
msgstr "Transfert"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__unassigned_owner
msgid "Unassigned owner"
msgstr "Propriétaire non assigné"
73 changes: 73 additions & 0 deletions stock_owner_restriction/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_owner_restriction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-01-22 12: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: stock_owner_restriction
#: model:ir.model.fields,field_description:stock_owner_restriction.field_stock_picking__owner_restriction
#: model:ir.model.fields,field_description:stock_owner_restriction.field_stock_picking_type__owner_restriction
msgid "Owner Restriction"
msgstr "Restrizione proprietario"

#. module: stock_owner_restriction
#: model_terms:ir.ui.view,arch_db:stock_owner_restriction.view_picking_type_form
msgid "Owner settings"
msgstr "Impostazioni proprietario"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipo prelievo"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__picking_partner
msgid "Picking partner"
msgstr "Partner prelievo"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__partner_or_unassigned
msgid "Picking partner or unassigned owner"
msgstr "Partner prelievo o proprietario non assegnato"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_product_product
msgid "Product Variant"
msgstr "Variante prodotto"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_quant
msgid "Quants"
msgstr "Quanti"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__standard_behavior
msgid "Standard behavior"
msgstr "Comportamento standard"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_move
msgid "Stock Move"
msgstr "Movimento di magazzino"

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_stock_picking
msgid "Transfer"
msgstr "Trasferimento"

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__unassigned_owner
msgid "Unassigned owner"
msgstr "Prprietario non assegnato"
9 changes: 7 additions & 2 deletions stock_owner_restriction/i18n/stock_owner_restriction.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down Expand Up @@ -34,9 +34,14 @@ msgstr ""
msgid "Picking partner"
msgstr ""

#. module: stock_owner_restriction
#: model:ir.model.fields.selection,name:stock_owner_restriction.selection__stock_picking_type__owner_restriction__partner_or_unassigned
msgid "Picking partner or unassigned owner"
msgstr ""

#. module: stock_owner_restriction
#: model:ir.model,name:stock_owner_restriction.model_product_product
msgid "Product"
msgid "Product Variant"
msgstr ""

#. module: stock_owner_restriction
Expand Down
10 changes: 9 additions & 1 deletion stock_owner_restriction/models/product.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2020 Carlos Dauden - Tecnativa
# Copyright 2020 Sergio Teruel - Tecnativa
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
from odoo import api, models


class ProductProduct(models.Model):
Expand Down Expand Up @@ -34,3 +34,11 @@ def _search_qty_available_new(
return super(ProductProduct, new_self)._search_qty_available_new(
operator, value, lot_id=lot_id, owner_id=owner_id, package_id=package_id
)

@api.depends_context("force_restricted_owner_id")
def _compute_quantities(self):
# Add force_restricted_owner_id to depends_context to compute qty when this
# key change.
# For example, in a report you want to print all stock available from a product
# and stock available from one owner.
return super()._compute_quantities()
36 changes: 21 additions & 15 deletions stock_owner_restriction/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2020 Carlos Dauden - Tecnativa
# Copyright 2020 Sergio Teruel - Tecnativa
# Copyright 2023-2024 Quartile Limited
# Copyright 2023-2024 Quartile
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from collections import defaultdict

Expand All @@ -24,22 +24,15 @@ def _compute_restrict_partner_id(self):
else:
move.restrict_partner_id = False

# pylint: disable=W8110
@api.depends("restrict_partner_id")
def _compute_forecast_information(self):
for move in self:
if move.picking_type_id.owner_restriction == "picking_partner":
move = move.with_context(owner_id=move.restrict_partner_id.id)
super(StockMove, move)._compute_forecast_information()

def _get_moves_to_assign_with_standard_behavior(self):
"""This method is expected to be extended as necessary. e.g. you may not want to
handle subcontracting receipts (whose picking type is normal incoming receipt
unless configured otherwise) with standard behavior, and you can filter out
those moves.
"""
return self.filtered(
lambda m: m.picking_type_id.owner_restriction == "standard_behavior"
lambda m: not m.picking_type_id
or m.picking_type_id.owner_restriction == "standard_behavior"
)

def _get_owner_restriction(self):
Expand All @@ -54,11 +47,10 @@ def _get_owner_for_assign(self):
needs to be applied to moves in manufacturing orders.
"""
self.ensure_one()
return (
self.move_dest_ids.restrict_partner_id
or self.picking_id.owner_id
or self.picking_id.partner_id
)
partner = self.move_dest_ids.picking_id.owner_id
if not partner:
partner = self.picking_id.owner_id or self.picking_id.partner_id
return partner

def _action_assign(self, force_qty=False):
# Split moves by picking type owner behavior restriction to process
Expand All @@ -78,6 +70,20 @@ def _action_assign(self, force_qty=False):
StockMove,
moves_to_assign.with_context(force_restricted_owner_id=owner_id),
)._action_assign(force_qty=force_qty)
if (
owner_id
and moves_to_assign.picking_type_id.owner_restriction
== "partner_or_unassigned"
and sum(
move.reserved_availability - move.product_uom_qty
for move in moves_to_assign
)
< 0
):
super(
StockMove,
moves_to_assign.with_context(force_restricted_owner_id=False),
)._action_assign(force_qty=force_qty)
return res

def _update_reserved_quantity(
Expand Down
Loading
Loading