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
105 changes: 105 additions & 0 deletions product_variant_route_mto/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
=========================
Product Variant Route MTO
=========================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/17.0/product_variant_route_mto
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-product_variant_route_mto
: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/product-attribute&target_branch=17.0
:alt: Try me on Runboat

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

This module allows to set a product variant as MTO (enabling the Make To
Order route on that variant only) while the related product is not MTO.
However, you cannot mark a variant has non MTO when the template is MTO.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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/product-attribute/issues/new?body=module:%20product_variant_route_mto%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
-------

* Camptocamp SA

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

- Matthieu Méquignon <matthieu.mequignon@camptocamp.com>
- Akim Juillerat <akim.juillerat@camptocamp.com>
- Chau Le <chaulb@trobz.com>
- Jacques-Etienne Baudoux (BCIM) <je@bcim.be>

Other credits
-------------

The development and migration of this module has been financially
supported by:

- Camptocamp

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.

.. |maintainer-mmequignon| image:: https://github.com/mmequignon.png?size=40px
:target: https://github.com/mmequignon
:alt: mmequignon
.. |maintainer-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px
:target: https://github.com/jbaudoux
:alt: jbaudoux

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mmequignon| |maintainer-jbaudoux|

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/17.0/product_variant_route_mto>`_ 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 product_variant_route_mto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions product_variant_route_mto/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 Camptocamp SA
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

{
"name": "Product Variant Route MTO",
"summary": "Allow to individually set variants as MTO",
"version": "17.0.1.0.0",
"development_status": "Alpha",
"category": "Inventory",
"website": "https://github.com/OCA/product-attribute",
"author": "Camptocamp SA, Odoo Community Association (OCA)",
"maintainers": ["mmequignon", "jbaudoux"],
"license": "AGPL-3",
"installable": True,
"auto_install": False,
"depends": ["product_route_mto"],
"data": ["views/product_product.xml"],
}
86 changes: 86 additions & 0 deletions product_variant_route_mto/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_variant_route_mto
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-06-25 10:25+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.10.4\n"

#. module: product_variant_route_mto
#: model:ir.model.fields,help:product_variant_route_mto.field_product_product__is_mto
msgid ""
"\n"
" Check or Uncheck this field to enable the Make To Order on the variant,\n"
" independantly from its template configuration.\n"
"\n"
" Please note that activating or deactivating Make To Order on the template,\n"
" will reset this setting on its variants.\n"
msgstr ""
"\n"
" Selezionare o deselezionare questo campo per abilitare la funzione "
"\"Produci su ordine\" sulla variante, \n"
" indipendentemente dalla configurazione del modello.\n"
"\n"
" Si fa di notare che l'attivazione o la disattivazione della funzione "
"\"Produci su ordine\" sul modello \n"
" reimposterà questa impostazione sulle relative varianti.\n"

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_template.py:0
msgid ""
"Activating MTO route will reset `Variant is MTO` setting on the variants."
msgstr ""
"L'attivazione della rotta MTO reimposterà l'impostazione `Variante è MTO` "
"nelle varianti."

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_template.py:0
msgid ""
"Deactivating MTO route will reset `Variant is MTO` setting on the variants."
msgstr ""
"Disattivando la rotta MTO reimposterà l'impostazione `Variante è MTO` nelle "
"varianti."

#. module: product_variant_route_mto
#: model:ir.model,name:product_variant_route_mto.model_product_template
msgid "Product"
msgstr "Prodotto"

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

#. module: product_variant_route_mto
#: model:ir.model.fields,field_description:product_variant_route_mto.field_product_product__route_ids
msgid "Route"
msgstr "Percorso"

#. module: product_variant_route_mto
#: model:ir.model.fields,field_description:product_variant_route_mto.field_product_product__is_mto
msgid "Variant is MTO"
msgstr "Variante è MTO"

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_template.py:0
msgid "Warning"
msgstr "Attenzione"

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_product.py:0
msgid "You cannot mark a variant as non MTO when the product is MTO"
msgstr "Una variante non può non essere MTO se il prodotto è MTO"
71 changes: 71 additions & 0 deletions product_variant_route_mto/i18n/product_variant_route_mto.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_variant_route_mto
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.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: product_variant_route_mto
#: model:ir.model.fields,help:product_variant_route_mto.field_product_product__is_mto
msgid ""
"\n"
" Check or Uncheck this field to enable the Make To Order on the variant,\n"
" independantly from its template configuration.\n"
"\n"
" Please note that activating or deactivating Make To Order on the template,\n"
" will reset this setting on its variants.\n"
msgstr ""

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_template.py:0
msgid ""
"Activating MTO route will reset `Variant is MTO` setting on the variants."
msgstr ""

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_template.py:0
msgid ""
"Deactivating MTO route will reset `Variant is MTO` setting on the variants."
msgstr ""

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

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

#. module: product_variant_route_mto
#: model:ir.model.fields,field_description:product_variant_route_mto.field_product_product__route_ids
msgid "Route"
msgstr ""

#. module: product_variant_route_mto
#: model:ir.model.fields,field_description:product_variant_route_mto.field_product_product__is_mto
msgid "Variant is MTO"
msgstr ""

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_template.py:0
msgid "Warning"
msgstr ""

#. module: product_variant_route_mto
#. odoo-python
#: code:addons/product_variant_route_mto/models/product_product.py:0
msgid "You cannot mark a variant as non MTO when the product is MTO"
msgstr ""
2 changes: 2 additions & 0 deletions product_variant_route_mto/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_product
from . import product_template
68 changes: 68 additions & 0 deletions product_variant_route_mto/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2023 Camptocamp SA
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError

IS_MTO_HELP = """
Check or Uncheck this field to enable the Make To Order on the variant,
independantly from its template configuration.\n
Please note that activating or deactivating Make To Order on the template,
will reset this setting on its variants.
"""


class ProductProduct(models.Model):
_inherit = "product.product"

is_mto = fields.Boolean(
string="Variant is MTO",
compute="_compute_is_mto",
store=True,
readonly=False,
help=IS_MTO_HELP,
)

route_ids = fields.Many2many(
"stock.route",
compute="_compute_route_ids",
domain="[('product_selectable', '=', True)]",
store=False,
search="_search_route_ids",
)

def _compute_is_mto(self):
for product in self:
product.is_mto = product.product_tmpl_id.is_mto

@api.depends("is_mto", "product_tmpl_id.route_ids")
def _compute_route_ids(self):
mto_routes = self.env["stock.route"].search([("is_mto", "=", True)])
for product in self:
routes = product.product_tmpl_id.route_ids
if product.is_mto:
routes += mto_routes
product.route_ids = routes

def _search_route_ids(self, operator, value):
mto_routes = self.env["stock.route"].search([("is_mto", "=", True)])
if operator in ("=", "!=") and value in mto_routes:
return [("is_mto", operator, True)]
domain = []
route_ids = value.copy()
for idx, route_id in enumerate(route_ids):
if route_id in mto_routes.ids:
route_ids.pop(idx)
domain = [("is_mto", "=" if operator == "in" else "!=", True)]
if route_ids:
domain += [("product_tmpl_id.route_ids", operator, route_ids)]
return domain

@api.constrains("is_mto")
def _check_template_is_mto(self):
for product in self:
if not product.is_mto and product.product_tmpl_id.is_mto:
raise ValidationError(
_("You cannot mark a variant as non MTO when the product is MTO")
)
Loading