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_product_variant: Migration to 18.0 #29

Draft
wants to merge 4 commits into
base: 18.0
Choose a base branch
from
Draft
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
99 changes: 99 additions & 0 deletions sale_stock_mto_as_mts_orderpoint_product_variant/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
================================================
Sale Stock MTO as MTS Orderpoint Product Variant
================================================

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

.. |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--orderpoint-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-orderpoint/tree/18.0/sale_stock_mto_as_mts_orderpoint_product_variant
:alt: OCA/stock-logistics-orderpoint
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-orderpoint-18-0/stock-logistics-orderpoint-18-0-sale_stock_mto_as_mts_orderpoint_product_variant
: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-orderpoint&target_branch=18.0
:alt: Try me on Runboat

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

This module extends the sale_stock_mto_as_mts_orderpoint module, in
order to handle the orderpoints at variant level.

.. 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/stock-logistics-orderpoint/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-orderpoint/issues/new?body=module:%20sale_stock_mto_as_mts_orderpoint_product_variant%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
------------

- Matthieu Méquignon <[email protected]>
- Chau Le <[email protected]>

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

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

|maintainer-mmequignon|

This module is part of the `OCA/stock-logistics-orderpoint <https://github.com/OCA/stock-logistics-orderpoint/tree/18.0/sale_stock_mto_as_mts_orderpoint_product_variant>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
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_product_variant/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

{
"name": "Sale Stock MTO as MTS Orderpoint Product Variant",
"version": "18.0.1.0.0",
"development_status": "Alpha",
"category": "Operations/Inventory/Delivery",
"website": "https://github.com/OCA/stock-logistics-orderpoint",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["mmequignon"],
"license": "AGPL-3",
"installable": True,
"auto_install": True,
"depends": [
"sale_stock_mto_as_mts_orderpoint",
"stock_product_variant_mto",
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_product
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models


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

is_mto = fields.Boolean(inverse="_inverse_is_mto")

def _variant_is_mto(self):
self.ensure_one()
return self.is_mto

Check warning on line 14 in sale_stock_mto_as_mts_orderpoint_product_variant/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

sale_stock_mto_as_mts_orderpoint_product_variant/models/product_product.py#L13-L14

Added lines #L13 - L14 were not covered by tests

def _inverse_is_mto(self):
self._archive_orderpoints_on_mto_removal()

def _compute_is_mto(self):
# Archive orderpoints when variant becomes not mto
res = super()._compute_is_mto()
self._archive_orderpoints_on_mto_removal()
return res

def _get_orderpoints_to_archive_domain(self):
# Orderpoints to archive are those where
warehouses = self.env["stock.warehouse"].search([])
locations = warehouses._get_locations_for_mto_orderpoints()
return [
("product_id", "in", self.ids),
("product_min_qty", "=", 0.0),
("product_max_qty", "=", 0.0),
("location_id", "in", locations.ids),
("product_id.is_mto", "=", False),
]

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})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Matthieu Méquignon \<<[email protected]>\>
- Chau Le \<<[email protected]>\>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development and migration of this module has been financially supported by:

- Camptocamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the sale_stock_mto_as_mts_orderpoint module, in
order to handle the orderpoints at variant level.
Loading
Loading