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
104 changes: 104 additions & 0 deletions stock_whole_kit_constraint/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
==========================
Stock whole kit constraint
==========================

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

.. |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/17.0/stock_whole_kit_constraint
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-17-0/manufacture-17-0-stock_whole_kit_constraint
: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=17.0
:alt: Try me on Runboat

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

This module allows to configure a product that has a BoM of type kit to
disallow partial deliveries so that the components can't be partially
delivered.

**Table of contents**

.. contents::
:local:

Configuration
=============

To allow/disallow the partial delivery of kits:

1. Go to the kit product template or variant and then to the *Inventory*
tab, *Logistics* group.
2. The "Allow Partial Kit" check controls this. If marked, it will allow
it.
3. By default, the check is marked.

Usage
=====

To use this module, you need to:

1. Make a delivery picking with a kit product.
2. Try to deliver it partially.
3. An error will raise.

If you want to deliver other items in the picking you can do so and
leave the whole kit components units pending in a backorder.

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:%20stock_whole_kit_constraint%0Aversion:%2017.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
-------

* Tecnativa

Contributors
------------

- Tecnativa <https://www.tecnativa.com>\_\_

- David Vidal
- Pilar Vargas

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/17.0/stock_whole_kit_constraint>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_whole_kit_constraint/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions stock_whole_kit_constraint/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2021 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Stock whole kit constraint",
"summary": "Avoid to deliver a kit partially",
"version": "17.0.1.0.0",
"category": "Stock",
"website": "https://github.com/OCA/manufacture",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["mrp"],
"data": ["views/product_template_views.xml"],
}
63 changes: 63 additions & 0 deletions stock_whole_kit_constraint/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_whole_kit_constraint
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-03-19 10:39+0000\n"
"PO-Revision-Date: 2023-07-23 11:08+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: \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: Weblate 4.17\n"

#. module: stock_whole_kit_constraint
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_product_product__allow_partial_kit_delivery
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_product_template__allow_partial_kit_delivery
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_stock_move__allow_partial_kit_delivery
msgid "Allow Partial Kit Delivery"
msgstr "Permitir entrega parcial de kit"

#. module: stock_whole_kit_constraint
#: model:ir.model.fields,help:stock_whole_kit_constraint.field_product_product__allow_partial_kit_delivery
#: model:ir.model.fields,help:stock_whole_kit_constraint.field_product_template__allow_partial_kit_delivery
msgid ""
"If not set, and this product is delivered with a BoM of type kit, partial "
"deliveries of the components won't be allowed."
msgstr ""
"Si no se establece, y este producto se entrega con una lista de materiales "
"de tipo set, no se permitirán entregas parciales de los componentes."

#. module: stock_whole_kit_constraint
#: model:ir.model,name:stock_whole_kit_constraint.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"

#. module: stock_whole_kit_constraint
#: model:ir.model,name:stock_whole_kit_constraint.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"

#. module: stock_whole_kit_constraint
#: model:ir.model,name:stock_whole_kit_constraint.model_stock_picking
msgid "Transfer"
msgstr "Albarán"

#. module: stock_whole_kit_constraint
#: code:addons/stock_whole_kit_constraint/models/stock_picking.py:0
#, python-format
msgid "You can't make a partial delivery of components of the %s kit"
msgstr "No puede realizar una entrega parcial de los componentes del kit %s"

#~ msgid ""
#~ "If not set when a kit product components are delivered, it won't be "
#~ "allowed to do it partially."
#~ msgstr ""
#~ "No no está activo, cuando haya una entrega con un kit, no se permitirá la "
#~ "entrega parcial de sus componentes."
65 changes: 65 additions & 0 deletions stock_whole_kit_constraint/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_whole_kit_constraint
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-01-01 13:44+0000\n"
"Last-Translator: mymage <[email protected]>\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 4.14.1\n"

#. module: stock_whole_kit_constraint
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_product_product__allow_partial_kit_delivery
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_product_template__allow_partial_kit_delivery
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_stock_move__allow_partial_kit_delivery
msgid "Allow Partial Kit Delivery"
msgstr "Consenti consegna confezione parziale"

#. module: stock_whole_kit_constraint
#: model:ir.model.fields,help:stock_whole_kit_constraint.field_product_product__allow_partial_kit_delivery
#: model:ir.model.fields,help:stock_whole_kit_constraint.field_product_template__allow_partial_kit_delivery
msgid ""
"If not set, and this product is delivered with a BoM of type kit, partial "
"deliveries of the components won't be allowed."
msgstr ""
"Se non impostato e il prodotto viene consegnato con una DiBa di tipo "
"confezione, consegne parziali dei componenti non sono consentite."

#. module: stock_whole_kit_constraint
#: model:ir.model,name:stock_whole_kit_constraint.model_product_template
msgid "Product Template"
msgstr "Modello prodotto"

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

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

#. module: stock_whole_kit_constraint
#: code:addons/stock_whole_kit_constraint/models/stock_picking.py:0
#, python-format
msgid "You can't make a partial delivery of components of the %s kit"
msgstr ""
"Non si può fare una consegna parziale di componenti della confezione %s"

#~ msgid "Display Name"
#~ msgstr "Nome visualizzato"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"
50 changes: 50 additions & 0 deletions stock_whole_kit_constraint/i18n/stock_whole_kit_constraint.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_whole_kit_constraint
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \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_whole_kit_constraint
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_product_product__allow_partial_kit_delivery
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_product_template__allow_partial_kit_delivery
#: model:ir.model.fields,field_description:stock_whole_kit_constraint.field_stock_move__allow_partial_kit_delivery
msgid "Allow Partial Kit Delivery"
msgstr ""

#. module: stock_whole_kit_constraint
#: model:ir.model.fields,help:stock_whole_kit_constraint.field_product_product__allow_partial_kit_delivery
#: model:ir.model.fields,help:stock_whole_kit_constraint.field_product_template__allow_partial_kit_delivery
msgid ""
"If not set, and this product is delivered with a BoM of type kit, partial "
"deliveries of the components won't be allowed."
msgstr ""

#. module: stock_whole_kit_constraint
#: model:ir.model,name:stock_whole_kit_constraint.model_product_template
msgid "Product Template"
msgstr ""

#. module: stock_whole_kit_constraint
#: model:ir.model,name:stock_whole_kit_constraint.model_stock_move
msgid "Stock Move"
msgstr ""

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

#. module: stock_whole_kit_constraint
#: code:addons/stock_whole_kit_constraint/models/stock_picking.py:0
#, python-format
msgid "You can't make a partial delivery of components of the %s kit"
msgstr ""
3 changes: 3 additions & 0 deletions stock_whole_kit_constraint/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import product_template
from . import stock_move
from . import stock_picking
23 changes: 23 additions & 0 deletions stock_whole_kit_constraint/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2021 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

allow_partial_kit_delivery = fields.Boolean(
default=True,
help="If not set, and this product is delivered with a BoM of type "
"kit, partial deliveries of the components won't be allowed.",
)
display_allow_partial_kit_delivery = fields.Boolean(
compute="_compute_display_allow_partial_kit_delivery",
)

@api.depends("bom_count", "type")
def _compute_display_allow_partial_kit_delivery(self):
for record in self:
record.display_allow_partial_kit_delivery = (
record.bom_count > 0 and record.type in ["consu", "product"]
)
52 changes: 52 additions & 0 deletions stock_whole_kit_constraint/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2021 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class StockMove(models.Model):
_inherit = "stock.move"

allow_partial_kit_delivery = fields.Boolean(
compute="_compute_allow_partial_kit_delivery",
compute_sudo=True,
)

@api.depends("product_id.product_tmpl_id.allow_partial_kit_delivery", "state")
def _compute_allow_partial_kit_delivery(self):
"""Take it from the product only if it's a kit"""
self.write({"allow_partial_kit_delivery": True})
for move in self.filtered(
lambda x: x.product_id and x.state not in ["done", "cancel"]
):
# If it isn't a kit it will always be True
if not move.bom_line_id or move.bom_line_id.bom_id.type != "phantom":
move.allow_partial_kit_delivery = True
continue
move.allow_partial_kit_delivery = (
move.bom_line_id.bom_id.product_tmpl_id.allow_partial_kit_delivery
)

def _check_backorder_moves(self):
"""Check if there are partial deliveries on any set of moves. The
computing is done in the same way the main picking method does it"""
quantity_todo = {}
quantity_done = {}
for move in self:
quantity_todo.setdefault(move.product_id.id, 0)
quantity_done.setdefault(move.product_id.id, 0)
quantity_todo[move.product_id.id] += move.product_uom_qty
quantity_done[move.product_id.id] += move.quantity
for ops in self.mapped("move_line_ids").filtered(
lambda x: x.package_id and not x.product_id and not x.move_id
):
for quant in ops.package_id.quant_ids:
quantity_done.setdefault(quant.product_id.id, 0)
quantity_done[quant.product_id.id] += quant.quantity
for pack in self.mapped("move_line_ids").filtered(
lambda x: x.product_id and not x.move_id
):
quantity_done.setdefault(pack.product_id.id, 0)
quantity_done[pack.product_id.id] += pack.product_uom_id._compute_quantity(
pack.quantity, pack.product_id.uom_id
)
return any(quantity_done[x] < quantity_todo.get(x, 0) for x in quantity_done)
Loading