Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] sale_stock_mto_as_mts_orderpoint: Migration to 18.0 #1828

Open
wants to merge 31 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b7d860d
Create module sale_stock_mto_as_mts_orderpoint
grindtildeath Aug 13, 2020
629c611
Check move state in selection of delivery move
grindtildeath Aug 18, 2020
6a4d4f0
[UPD] Update sale_stock_mto_as_mts_orderpoint.pot
oca-travis Aug 27, 2020
6bc6cfc
[UPD] README.rst
OCA-git-bot Aug 27, 2020
56db516
[ADD] icon.png
OCA-git-bot Aug 27, 2020
2c80dac
sale_stock_mto_as_mts_orderpoint 13.0.1.2.1
OCA-git-bot Aug 27, 2020
d2417ac
[13.0][FIX] sale_stock_mto_as_mts_orderpoint
TDu Dec 9, 2020
bb92473
sale_stock_mto_as_mts_orderpoint 13.0.1.2.2
OCA-git-bot Dec 22, 2020
6356345
[IMP] sale_stock_mto_as_mts_orderpoint: black, isort, prettier
dzungtran89 Jan 11, 2021
142fa88
[MIG] sale_stock_mto_as_mts_orderpoint: Migration to 14.0
dzungtran89 Jan 11, 2021
e46b90f
[UPD] Update sale_stock_mto_as_mts_orderpoint.pot
oca-travis Oct 7, 2021
12cb107
[FIX] sale_stock_mto_as_mts_orderpoint: support product set
sebalix Sep 30, 2020
60dfa89
[IMP] sale_stock_mto_as_mts_orderpoint: test coverage
sebalix Jan 18, 2021
2c8dca1
sale_stock_mto_as_mts_orderpoint 14.0.1.0.1
OCA-git-bot Nov 30, 2021
2a2e008
[UPD] README.rst
OCA-git-bot Sep 3, 2023
b421cec
[FIX] black, isort, prettier
sergiocorato Oct 18, 2023
13ab074
[BOT] post-merge updates
OCA-git-bot Oct 24, 2023
bf36c74
Added translation using Weblate (Italian)
mymage Jan 22, 2024
d7aa951
[FIX] s-s-mto-as-mts-orderpoint
TDu Aug 12, 2024
f7c33d3
sale_stock_mto_as_mts_orderpoint: fix orderpoint creation
mmequignon Sep 6, 2024
321196e
[BOT] post-merge updates
OCA-git-bot Sep 6, 2024
d2c06d3
[BOT] post-merge updates
OCA-git-bot Sep 9, 2024
3e14f43
[IMP] sale_stock_mto_as_mts: add flag on warehouse
TDu Sep 9, 2024
1829268
[UPD] Update sale_stock_mto_as_mts_orderpoint.pot
Sep 9, 2024
0aa2ed5
[BOT] post-merge updates
OCA-git-bot Sep 9, 2024
f74b450
Update translation files
weblate Sep 9, 2024
1b4db14
sale_stock_mto_as_mts_orderpoint: fix orderpoint activation condition
mmequignon Sep 9, 2024
1e4474a
[BOT] post-merge updates
OCA-git-bot Sep 10, 2024
2be5f21
sale_stock_mto_as_mts_orderpoint: Add hooks
mmequignon Dec 22, 2023
9cf5534
[IMP] sale_stock_mto_as_mts_orderpoint: pre-commit auto fixes
chaule97 Jan 2, 2025
4e56965
[18.0][MIG] sale_stock_mto_as_mts_orderpoint: Migration to 18.0
chaule97 Jan 6, 2025
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
109 changes: 109 additions & 0 deletions sale_stock_mto_as_mts_orderpoint/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
================================
Sale Stock Mto As Mts Orderpoint
================================

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

.. |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%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/18.0/sale_stock_mto_as_mts_orderpoint
: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-18-0/stock-logistics-workflow-18-0-sale_stock_mto_as_mts_orderpoint
: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/stock-logistics-workflow&target_branch=18.0
:alt: Try me on Runboat

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

This module aims to materialize the triggering of another stock rule
through an orderpoint in the procurement of MTO products from a sale
order.

When a sales order is confirmed, if the delivery order move is generated
by the stock rule linked to the standard MTO route or the MTO route is
marked on the product, an orderpoint will be created on the Stock
location of the warehouse, with min/max quantities of zero.

Finally, orderpoints with min/max quantities of zero will be archived if
the MTO route is removed on the product.

.. 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:

Known issues / Roadmap
======================

- Do not rely on original MTO record and have something configurable
instead.

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20sale_stock_mto_as_mts_orderpoint%0Aversion:%2018.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

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

- Akim Juillerat <akim.juillerat@camptocamp.com>

Trobz:

- Dung Tran <dungtd@trobz.com>
- Chau Le <chaulb@trobz.com>

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

The development 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.

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/18.0/sale_stock_mto_as_mts_orderpoint>`_ 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 sale_stock_mto_as_mts_orderpoint/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions sale_stock_mto_as_mts_orderpoint/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Sale Stock Mto As Mts Orderpoint",
"summary": "Materialize need from MTO route through orderpoint",
"version": "18.0.1.0.0",
"development_status": "Alpha",
"category": "Operations/Inventory/Delivery",
"website": "https://github.com/OCA/stock-logistics-workflow",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["sale_stock", "purchase_stock"],
"data": [
"data/stock_data.xml",
"views/stock_warehouse_views.xml",
],
}
6 changes: 6 additions & 0 deletions sale_stock_mto_as_mts_orderpoint/data/stock_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="stock.route_warehouse0_mto" model="stock.route">
<field name="active" eval="True" />
</record>
</odoo>
69 changes: 69 additions & 0 deletions sale_stock_mto_as_mts_orderpoint/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_stock_mto_as_mts_orderpoint
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\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"

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_product_template__display_name
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_sale_order_line__display_name
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move__display_name
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse__display_name
msgid "Display Name"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_product_template__id
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_sale_order_line__id
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move__id
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse__id
msgid "ID"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move__is_from_mto_route
msgid "Is From Mto Route"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_product_template____last_update
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_sale_order_line____last_update
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move____last_update
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse__mto_as_mts
msgid "Mto As Mts"
msgstr ""

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

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model,name:sale_stock_mto_as_mts_orderpoint.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

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

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model,name:sale_stock_mto_as_mts_orderpoint.model_stock_warehouse
msgid "Warehouse"
msgstr ""
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:
# * sale_stock_mto_as_mts_orderpoint
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_product_template__display_name
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_sale_order_line__display_name
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move__display_name
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse__display_name
msgid "Display Name"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_product_template__id
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_sale_order_line__id
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move__id
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse__id
msgid "ID"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move__is_from_mto_route
msgid "Is From Mto Route"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_product_template____last_update
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_sale_order_line____last_update
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_move____last_update
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model.fields,field_description:sale_stock_mto_as_mts_orderpoint.field_stock_warehouse__mto_as_mts
msgid "Mto As Mts"
msgstr ""

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

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model,name:sale_stock_mto_as_mts_orderpoint.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

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

#. module: sale_stock_mto_as_mts_orderpoint
#: model:ir.model,name:sale_stock_mto_as_mts_orderpoint.model_stock_warehouse
msgid "Warehouse"
msgstr ""
6 changes: 6 additions & 0 deletions sale_stock_mto_as_mts_orderpoint/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from . import product_template
from . import product_product
from . import sale_order
from . import stock_move
from . import stock_warehouse_orderpoint
from . import stock_warehouse
16 changes: 16 additions & 0 deletions sale_stock_mto_as_mts_orderpoint/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import models


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

def _variant_is_mto(self):
self.ensure_one()
mto_route = self.env.ref("stock.route_warehouse0_mto", raise_if_not_found=False)
return mto_route in self.route_ids

Check warning on line 13 in sale_stock_mto_as_mts_orderpoint/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

sale_stock_mto_as_mts_orderpoint/models/product_product.py#L11-L13

Added lines #L11 - L13 were not covered by tests

def _variant_is_not_mto(self):
return not self._variant_is_mto()

Check warning on line 16 in sale_stock_mto_as_mts_orderpoint/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

sale_stock_mto_as_mts_orderpoint/models/product_product.py#L16

Added line #L16 was not covered by tests
50 changes: 50 additions & 0 deletions sale_stock_mto_as_mts_orderpoint/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models


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

def write(self, vals):
# Archive orderpoints when MTO route is removed
if "route_ids" not in vals:
return super().write(vals)
mto_products = self._filter_mto_products()
res = super().write(vals)
not_mto_products = self._filter_mto_products(mto=False)
# products to update are the intersection of both recordsets
products_to_update = mto_products & not_mto_products
if products_to_update:
products_to_update._archive_orderpoints_on_mto_removal()
return res

def _template_is_mto(self):
self.ensure_one()
mto_route = self.env.ref("stock.route_warehouse0_mto", raise_if_not_found=False)
return mto_route in self.route_ids

def _template_is_not_mto(self):
self.ensure_one()
return not self._template_is_mto()

def _filter_mto_products(self, mto=True):
if mto:
return self.filtered(lambda t: t._template_is_mto())
return self.filtered(lambda t: t._template_is_not_mto())

def _get_orderpoints_to_archive_domain(self):
warehouses = self.env["stock.warehouse"].search([])
locations = warehouses._get_locations_for_mto_orderpoints()
return [
("product_id", "in", self.mapped("product_variant_ids").ids),
("product_min_qty", "=", 0.0),
("product_max_qty", "=", 0.0),
("location_id", "in", locations.ids),
]

def _archive_orderpoints_on_mto_removal(self):
domain = self._get_orderpoints_to_archive_domain()
ops = self.env["stock.warehouse.orderpoint"].search(domain)
if ops:
ops.write({"active": False})
Loading
Loading