Skip to content

Commit 55b4f32

Browse files
[MIG]stock_orderpoint_procure_location to v15
1 parent eaeabb2 commit 55b4f32

12 files changed

Lines changed: 583 additions & 39 deletions
Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1-
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2-
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
3-
:alt: License: AGPL-3
4-
51
=================================
62
Stock Orderpoint Procure Location
73
=================================
84

5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:73b3a40fdbb04ac7fc276faa02e2d1bf0019c894d861d78ee9f970fe2ef87cb5
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%2Fstock--logistics--warehouse-lightgray.png?logo=github
20+
:target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_orderpoint_procure_location
21+
:alt: OCA/stock-logistics-warehouse
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_orderpoint_procure_location
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/stock-logistics-warehouse&target_branch=15.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
931
This module allows users to define the procure location to be used
1032
in procurements created from minimum stock rules.
1133

@@ -14,49 +36,63 @@ the movement to stock is created either manually or through a push rule.
1436
Thus I need to take into account the qty in stock but I prefer to receive in
1537
input location first.
1638

39+
**Table of contents**
40+
41+
.. contents::
42+
:local:
43+
1744
Usage
1845
=====
1946

2047
Go to 'Inventory > Master Data > Reordering Rules' and indicate a Procurement
2148
Location.
2249

23-
24-
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
25-
:alt: Try me on Runbot
26-
:target: https://runbot.odoo-community.org/runbot/153/11.0
27-
2850
Bug Tracker
2951
===========
3052

31-
Bugs are tracked on `GitHub Issues
32-
<https://github.com/OCA/stock-logistics-warehouse/issues>`_. In case of trouble, please
33-
check there if your issue has already been reported. If you spotted it first,
34-
help us smashing it by providing a detailed and welcomed feedback.
53+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
54+
In case of trouble, please check there if your issue has already been reported.
55+
If you spotted it first, help us to smash it by providing a detailed and welcomed
56+
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_orderpoint_procure_location%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
57+
58+
Do not contact contributors directly about support or help with technical issues.
3559

3660
Credits
3761
=======
3862

39-
Images
40-
------
63+
Authors
64+
~~~~~~~
4165

42-
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
66+
* ForgeFlow
4367

4468
Contributors
45-
------------
69+
~~~~~~~~~~~~
70+
71+
* ForgeFlow S.L. <contact@forgeflow.com>
4672

47-
* Aaron Henriquez <ahenriquez@forgeflow.com>
73+
- Aaron Henriquez <aaron.henriquez@forgeflow.com>
4874

49-
Maintainer
50-
----------
75+
Maintainers
76+
~~~~~~~~~~~
77+
78+
This module is maintained by the OCA.
5179

5280
.. image:: https://odoo-community.org/logo.png
5381
:alt: Odoo Community Association
5482
:target: https://odoo-community.org
5583

56-
This module is maintained by the OCA.
57-
5884
OCA, or the Odoo Community Association, is a nonprofit organization whose
5985
mission is to support the collaborative development of Odoo features and
6086
promote its widespread use.
6187

62-
To contribute to this module, please visit https://odoo-community.org.
88+
.. |maintainer-AaronHForgeFlow| image:: https://github.com/AaronHForgeFlow.png?size=40px
89+
:target: https://github.com/AaronHForgeFlow
90+
:alt: AaronHForgeFlow
91+
92+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
93+
94+
|maintainer-AaronHForgeFlow|
95+
96+
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_orderpoint_procure_location>`_ project on GitHub.
97+
98+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
# Copyright 2020 ForgeFlow S.L.
1+
# Copyright 2020-22 ForgeFlow S.L.
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
33
{
44
"name": "Stock Orderpoint Procure Location",
55
"summary": "Allows to create procurement orders in a different location"
66
"the orderpoint",
7-
"version": "13.0.1.0.0",
7+
"version": "15.0.1.0.0",
88
"author": "ForgeFlow, " "Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/stock-logistics-warehouse",
1010
"category": "Warehouse Management",
11-
"depends": ["purchase", "stock"],
11+
"depends": ["purchase_stock"],
1212
"data": ["views/stock_warehouse_orderpoint_view.xml"],
1313
"license": "AGPL-3",
1414
"development_status": "Beta",
15+
"maintainers": ["AaronHForgeFlow"],
1516
"installable": True,
1617
}

stock_orderpoint_procure_location/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
from . import stock_warehouse_orderpoint
44
from . import procurement_group
5+
from . import purchase_order_line
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020 ForgeFlow S.L.
1+
# Copyright 2020-22 ForgeFlow S.L.
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
33

44
from odoo import api, models
@@ -8,7 +8,8 @@ class ProcurementGroup(models.Model):
88
_inherit = "procurement.group"
99

1010
@api.model
11-
def run(self, procurements):
12-
if procurements and "procure_location_id" in procurements:
13-
procurements["location_id"] = procurements.get("procure_location_id")
14-
return super(ProcurementGroup, self).run(procurements)
11+
def _get_rule(self, product_id, location_id, values):
12+
procure_location = values.get("procure_location_id", False)
13+
if procure_location:
14+
location_id = procure_location
15+
return super()._get_rule(product_id, location_id, values)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2022 ForgeFlow S.L.
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
from odoo import models
4+
5+
6+
class PurchaseOrderLine(models.Model):
7+
_inherit = "purchase.order.line"
8+
9+
def _prepare_stock_move_vals(
10+
self, picking, price_unit, product_uom_qty, product_uom
11+
):
12+
res = super()._prepare_stock_move_vals(
13+
picking, price_unit, product_uom_qty, product_uom
14+
)
15+
if self.orderpoint_id and self.orderpoint_id.procure_location_id:
16+
res["location_dest_id"] = self.orderpoint_id.procure_location_id.id
17+
return res

stock_orderpoint_procure_location/models/stock_warehouse_orderpoint.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020 ForgeFlow S.L.
1+
# Copyright 2020-22 ForgeFlow S.L.
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
33

44
from odoo import fields, models
@@ -13,11 +13,32 @@ class Orderpoint(models.Model):
1313
domain="[('usage', '=', 'internal')]",
1414
)
1515

16-
def _prepare_procurement_values(self, product_qty, date=False, group=False):
16+
def _prepare_procurement_values(self, date=False, group=False):
1717
"""Set the procure location"""
18-
res = super(Orderpoint, self)._prepare_procurement_values(
19-
product_qty, date, group
20-
)
18+
res = super(Orderpoint, self)._prepare_procurement_values(date, group)
2119
if self.procure_location_id:
2220
res["procure_location_id"] = self.procure_location_id
2321
return res
22+
23+
def _quantity_in_progress(self):
24+
res = super()._quantity_in_progress()
25+
not_count_states = ["done", "cancel"]
26+
for orderpoint in self:
27+
for sm in (
28+
self.env["purchase.order.line"]
29+
.search(
30+
[
31+
("state", "=", "purchase"),
32+
("product_id", "=", orderpoint.product_id.id),
33+
]
34+
)
35+
.mapped("move_ids")
36+
.filtered(
37+
lambda m: m.location_dest_id == orderpoint.procure_location_id
38+
and m.state not in not_count_states
39+
)
40+
):
41+
res[orderpoint.id] += sm.product_uom._compute_quantity(
42+
sm.product_qty, sm.product_uom, round=False
43+
)
44+
return res
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* ForgeFlow S.L. <contact@forgeflow.com>
2+
3+
- Aaron Henriquez <aaron.henriquez@forgeflow.com>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This module allows users to define the procure location to be used
2+
in procurements created from minimum stock rules.
3+
4+
A typical use case would be the procurement location is Input location. And
5+
the movement to stock is created either manually or through a push rule.
6+
Thus I need to take into account the qty in stock but I prefer to receive in
7+
input location first.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Go to 'Inventory > Master Data > Reordering Rules' and indicate a Procurement
2+
Location.

0 commit comments

Comments
 (0)