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

[MIG] stock_orderpoint_route: Migration to 18.0 #33

Open
wants to merge 11 commits into
base: 18.0
Choose a base branch
from
96 changes: 96 additions & 0 deletions stock_orderpoint_route/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
======================
Stock Orderpoint Route
======================

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

.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-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/stock_orderpoint_route
: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-stock_orderpoint_route
: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 allows to restrict a specific route to be used in the
reordering rules. This route will be used instead of the default
determined by default.

**Table of contents**

.. contents::
:local:

Usage
=====

Go to the reordering rule and change the route. Only the routes
applicable for this location or locations above it can be selected.

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:%20stock_orderpoint_route%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
-------

* ForgeFlow
* Camptocamp

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

- Jordi Ballester Alomar <[email protected]>
- Lois Rilo <[email protected]>
- Guewen Baconnier <[email protected]>
- `Trobz <https://trobz.com>`__:

- Dung Tran <[email protected]>

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

The migration of this module from 13.0 to 14.0 was 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-orderpoint <https://github.com/OCA/stock-logistics-orderpoint/tree/18.0/stock_orderpoint_route>`_ 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_orderpoint_route/__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_orderpoint_route/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": "Stock Orderpoint Route",
"summary": "Allows to force a route to be used when procuring from orderpoints",
"version": "18.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-orderpoint",
"author": "ForgeFlow, Camptocamp, Odoo Community Association (OCA)",
"category": "Warehouse",
"depends": ["stock"],
"data": ["views/stock_warehouse_orderpoint_views.xml"],
"installable": True,
}
49 changes: 49 additions & 0 deletions stock_orderpoint_route/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_orderpoint_route
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-15 11:33+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.17\n"

#. module: stock_orderpoint_route
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint__route_ids
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint_template__route_ids
msgid "Allowed routes"
msgstr "Rotte consentite"

#. module: stock_orderpoint_route
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: stock_orderpoint_route
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint__id
msgid "ID"
msgstr "ID"

#. module: stock_orderpoint_route
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: stock_orderpoint_route
#: model:ir.model,name:stock_orderpoint_route.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr "Regola giacenza minima"

#. module: stock_orderpoint_route
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint__route_id
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint_template__route_id
msgid "Route"
msgstr "Percorso"
29 changes: 29 additions & 0 deletions stock_orderpoint_route/i18n/stock_orderpoint_route.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_orderpoint_route
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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_orderpoint_route
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint__route_ids
msgid "Allowed routes"
msgstr ""

#. module: stock_orderpoint_route
#: model:ir.model,name:stock_orderpoint_route.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr ""

#. module: stock_orderpoint_route
#: model:ir.model.fields,field_description:stock_orderpoint_route.field_stock_warehouse_orderpoint__route_id
msgid "Route"
msgstr ""
1 change: 1 addition & 0 deletions stock_orderpoint_route/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_warehouse_orderpoint
53 changes: 53 additions & 0 deletions stock_orderpoint_route/models/stock_warehouse_orderpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2019 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import api, fields, models


class StockWarehouseOrderpoint(models.Model):
_inherit = "stock.warehouse.orderpoint"

route_ids = fields.Many2many(
"stock.route", string="Allowed routes", compute="_compute_route_ids"
)
route_id = fields.Many2one(
"stock.route",
string="Route",
domain="[('id', 'in', route_ids)]",
ondelete="restrict",
)

@api.depends("product_id", "warehouse_id", "warehouse_id.route_ids", "location_id")
def _compute_route_ids(self):
route_obj = self.env["stock.route"]
for record in self:
wh_routes = record.warehouse_id.route_ids
routes = route_obj.browse()
if record.product_id:
routes += record.product_id.mapped(
"route_ids"
) | record.product_id.mapped("categ_id").mapped("total_route_ids")
if record.warehouse_id:
routes |= wh_routes
parents = record.get_parents()
record.route_ids = self._get_location_routes_of_parents(routes, parents)

def _get_location_routes_of_parents(self, routes, parents):
return routes.filtered(
lambda route: any(
p.location_id in parents
for p in route.rule_ids.filtered(
lambda rule: rule.action in ("pull", "pull_push")
).mapped("location_src_id")
)
)

def get_parents(self):
return self.env["stock.location"].search(
[("id", "parent_of", self.location_id.id)]
)

def _prepare_procurement_values(self, date=False, group=False):
res = super()._prepare_procurement_values(date=date, group=group)
res["route_ids"] = self.route_id
return res
3 changes: 3 additions & 0 deletions stock_orderpoint_route/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions stock_orderpoint_route/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Jordi Ballester Alomar \<<[email protected]>\>
- Lois Rilo \<<[email protected]>\>
- Guewen Baconnier \<<[email protected]>\>
- [Trobz](https://trobz.com):
- Dung Tran \<<[email protected]>\>
2 changes: 2 additions & 0 deletions stock_orderpoint_route/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The migration of this module from 13.0 to 14.0 was financially supported
by Camptocamp
3 changes: 3 additions & 0 deletions stock_orderpoint_route/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module allows to restrict a specific route to be used in the
reordering rules. This route will be used instead of the default
determined by default.
2 changes: 2 additions & 0 deletions stock_orderpoint_route/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Go to the reordering rule and change the route. Only the routes
applicable for this location or locations above it can be selected.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading