Skip to content

Commit 77950c8

Browse files
committed
Merge PR #2465 into 16.0
Signed-off-by sebastienbeau
2 parents 8f15bdb + 46f6e9f commit 77950c8

File tree

15 files changed

+772
-0
lines changed

15 files changed

+772
-0
lines changed

purchase_split_by_route/README.rst

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
====================
2+
Purchase Split Route
3+
====================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:1679d1ffb6e608db2dac3887451673e17077113039e4bb701b2159d3bf55b06c
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/purchase-workflow/tree/16.0/purchase_split_by_route
21+
:alt: OCA/purchase-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/purchase-workflow-16-0/purchase-workflow-16-0-purchase_split_by_route
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows you to separate automatic purchases by sale order route
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Bug Tracker
39+
===========
40+
41+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
42+
In case of trouble, please check there if your issue has already been reported.
43+
If you spotted it first, help us to smash it by providing a detailed and welcomed
44+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_split_by_route%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
45+
46+
Do not contact contributors directly about support or help with technical issues.
47+
48+
Credits
49+
=======
50+
51+
Authors
52+
~~~~~~~
53+
54+
* Akretion
55+
56+
Contributors
57+
~~~~~~~~~~~~
58+
59+
* `Akretion <https://akretion.com>`_:
60+
* Mathieu DELVA <[email protected]>
61+
62+
Maintainers
63+
~~~~~~~~~~~
64+
65+
This module is maintained by the OCA.
66+
67+
.. image:: https://odoo-community.org/logo.png
68+
:alt: Odoo Community Association
69+
:target: https://odoo-community.org
70+
71+
OCA, or the Odoo Community Association, is a nonprofit organization whose
72+
mission is to support the collaborative development of Odoo features and
73+
promote its widespread use.
74+
75+
.. |maintainer-mathieudelva| image:: https://github.com/mathieudelva.png?size=40px
76+
:target: https://github.com/mathieudelva
77+
:alt: mathieudelva
78+
79+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
80+
81+
|maintainer-mathieudelva|
82+
83+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/purchase_split_by_route>`_ project on GitHub.
84+
85+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2024 Akretion France (http://www.akretion.com/)
2+
# @author: Mathieu Delva <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
{
6+
"name": "Purchase Split Route",
7+
"summary": """""",
8+
"version": "16.0.1.0.0",
9+
"license": "AGPL-3",
10+
"maintainers": ["mathieudelva"],
11+
"author": "Akretion,Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/purchase-workflow",
13+
"depends": [
14+
"purchase_stock",
15+
"sale_order_global_stock_route",
16+
"stock_mts_mto_rule",
17+
],
18+
"data": ["views/stock_route.xml"],
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import purchase_order
2+
from . import stock_route
3+
from . import stock_rule
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2024 Akretion France (http://www.akretion.com/)
2+
# @author: Mathieu Delva <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
import re
6+
7+
from odoo import api, fields, models
8+
9+
10+
class PurchaseOrder(models.Model):
11+
_inherit = "purchase.order"
12+
13+
default_route_id = fields.Many2one("stock.route", store=True)
14+
15+
16+
class PurchaseOrderLine(models.Model):
17+
_inherit = "purchase.order.line"
18+
19+
@api.model
20+
def _prepare_purchase_order_line_from_procurement(
21+
self, product_id, product_qty, product_uom, company_id, values, po
22+
):
23+
vals = super()._prepare_purchase_order_line_from_procurement(
24+
product_id, product_qty, product_uom, company_id, values, po
25+
)
26+
origin = values["move_dest_ids"].origin
27+
if origin:
28+
origin = re.search(r"S\d+", origin)
29+
if origin:
30+
order_id = self.env["sale.order"].search([("name", "=", origin[0])])
31+
if order_id:
32+
po.default_route_id = order_id.route_id.id
33+
elif "orderpoint_id" in values:
34+
po.default_route_id = values["orderpoint_id"].route_id.id
35+
36+
return vals
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2024 Akretion France (http://www.akretion.com/)
2+
# @author: Mathieu Delva <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from odoo import fields, models
6+
7+
8+
class StockRoute(models.Model):
9+
_inherit = "stock.route"
10+
11+
split_purchase_by_route = fields.Boolean()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (C) 2024 Akretion (<http://www.akretion.com>).
2+
# @author Mathieu Delva <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from odoo import models
6+
7+
8+
class StockRule(models.Model):
9+
_inherit = "stock.rule"
10+
11+
def _make_po_get_domain(self, company_id, values, partner):
12+
""" """
13+
domain = super()._make_po_get_domain(company_id, values, partner)
14+
if "move_dest_ids" in values:
15+
origin = values["move_dest_ids"].origin
16+
order_id = self.env["sale.order"].search([("name", "=", origin)])
17+
if order_id:
18+
values["group_id"] = False
19+
default_route_id = order_id.route_id
20+
if not default_route_id.split_purchase_by_route:
21+
domain = tuple(filter(lambda r: r[0] != "group_id", domain))
22+
domain += (
23+
(
24+
"default_route_id",
25+
"=",
26+
default_route_id.id,
27+
),
28+
)
29+
return domain
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* `Akretion <https://akretion.com>`_:
2+
* Mathieu DELVA <[email protected]>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows you to separate automatic purchases by sale order route

0 commit comments

Comments
 (0)