Skip to content

Commit 86b3d48

Browse files
committed
Merge PR #4101 into 18.0
Signed-off-by pedrobaeza
2 parents 2d0bbe2 + 968ddb0 commit 86b3d48

File tree

19 files changed

+876
-0
lines changed

19 files changed

+876
-0
lines changed

sale_procurement_group_by_line/model/sale.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def _action_launch_stock_rule(self, previous_product_uom_qty=False):
6767
if not group_id:
6868
vals = line._prepare_procurement_group_vals()
6969
group_id = self.env["procurement.group"].create(vals)
70+
line.order_id.procurement_group_id = group_id
7071
else:
7172
# In case the procurement group is already created and the
7273
# order was cancelled, we need to update certain values
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
================================
2+
Sale purchase stock auto confirm
3+
================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:cc367735f9a970e27b16260e3631eb0b445a5ba74987af63f8f137936a955297
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%2Fsale--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/sale-workflow/tree/18.0/sale_purchase_stock_auto_confirm
21+
:alt: OCA/sale-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_purchase_stock_auto_confirm
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/sale-workflow&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a company-level option to automatically confirm
32+
purchase orders generated from sale orders (by Dropship or MTO rules).
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Use Cases / Context
40+
===================
41+
42+
In some cases, a sale order can automatically generate a purchase order
43+
when the products use a Dropship or MTO logistic route, and the user
44+
expects these purchase orders to be confirmed automatically.
45+
46+
Usage
47+
=====
48+
49+
- Go to ``Sales > Configuration > Settings``.
50+
- Search and enable the option ``POs Auto Validation``.
51+
- Create a sale order and add a line with a product that uses the MTO or
52+
Dropship route.
53+
- Confirm the sale order.
54+
55+
The generated purchase order must be confirmed automatically.
56+
57+
Bug Tracker
58+
===========
59+
60+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
61+
In case of trouble, please check there if your issue has already been reported.
62+
If you spotted it first, help us to smash it by providing a detailed and welcomed
63+
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_purchase_stock_auto_confirm%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
65+
Do not contact contributors directly about support or help with technical issues.
66+
67+
Credits
68+
=======
69+
70+
Authors
71+
-------
72+
73+
* Tecnativa
74+
75+
Contributors
76+
------------
77+
78+
- `Tecnativa <https://www.tecnativa.com>`__:
79+
80+
- Pedro M. Baeza
81+
- Carlos Lopez
82+
83+
Maintainers
84+
-----------
85+
86+
This module is maintained by the OCA.
87+
88+
.. image:: https://odoo-community.org/logo.png
89+
:alt: Odoo Community Association
90+
:target: https://odoo-community.org
91+
92+
OCA, or the Odoo Community Association, is a nonprofit organization whose
93+
mission is to support the collaborative development of Odoo features and
94+
promote its widespread use.
95+
96+
.. |maintainer-carlos-lopez-tecnativa| image:: https://github.com/carlos-lopez-tecnativa.png?size=40px
97+
:target: https://github.com/carlos-lopez-tecnativa
98+
:alt: carlos-lopez-tecnativa
99+
100+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
101+
102+
|maintainer-carlos-lopez-tecnativa|
103+
104+
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/sale_purchase_stock_auto_confirm>`_ project on GitHub.
105+
106+
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Sale purchase stock auto confirm",
3+
"version": "18.0.1.0.0",
4+
"category": "Sales",
5+
"website": "https://github.com/OCA/sale-workflow",
6+
"author": "Tecnativa,Odoo Community Association (OCA)",
7+
"license": "AGPL-3",
8+
"depends": ["sale_purchase_stock"],
9+
"data": ["views/res_config_settings_views.xml"],
10+
"installable": True,
11+
"maintainers": ["carlos-lopez-tecnativa"],
12+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_purchase_stock_auto_confirm
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 18.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2026-01-08 19:10+0000\n"
10+
"PO-Revision-Date: 2026-01-08 14:13-0500\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"Language: es\n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Type: text/plain; charset=UTF-8\n"
16+
"Content-Transfer-Encoding: 8bit\n"
17+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
18+
"X-Generator: Poedit 3.8\n"
19+
20+
#. module: sale_purchase_stock_auto_confirm
21+
#: model_terms:ir.ui.view,arch_db:sale_purchase_stock_auto_confirm.res_config_settings_view_form
22+
msgid ""
23+
"Automatically validate purchase orders created from sales orders using MTO "
24+
"or Dropship rules."
25+
msgstr ""
26+
"Validar automáticamente los pedidos de compra creados a partir de pedidos "
27+
"de venta que usen reglas MTO o Dropship."
28+
29+
#. module: sale_purchase_stock_auto_confirm
30+
#: model:ir.model,name:sale_purchase_stock_auto_confirm.model_res_company
31+
msgid "Companies"
32+
msgstr "Compañías"
33+
34+
#. module: sale_purchase_stock_auto_confirm
35+
#: model:ir.model,name:sale_purchase_stock_auto_confirm.model_res_config_settings
36+
msgid "Config Settings"
37+
msgstr "Ajustes de configuración"
38+
39+
#. module: sale_purchase_stock_auto_confirm
40+
#: model:ir.model.fields,field_description:sale_purchase_stock_auto_confirm.field_res_company__purchase_auto_validation
41+
#: model:ir.model.fields,field_description:sale_purchase_stock_auto_confirm.field_res_config_settings__purchase_auto_validation
42+
msgid "POs Auto Validation"
43+
msgstr "Auto validación de compras"
44+
45+
#. module: sale_purchase_stock_auto_confirm
46+
#: model_terms:ir.ui.view,arch_db:sale_purchase_stock_auto_confirm.res_config_settings_view_form
47+
msgid "Purchase stock"
48+
msgstr "Compras/Stock"
49+
50+
#. module: sale_purchase_stock_auto_confirm
51+
#. odoo-python
52+
#: code:addons/sale_purchase_stock_auto_confirm/tests/test_sale_purchase_stock_auto_confirm.py:0
53+
msgid "Replenish on Order (MTO)"
54+
msgstr ""
55+
56+
#. module: sale_purchase_stock_auto_confirm
57+
#: model:ir.model,name:sale_purchase_stock_auto_confirm.model_sale_order
58+
msgid "Sales Order"
59+
msgstr "Pedido de venta"
60+
61+
#. module: sale_purchase_stock_auto_confirm
62+
#: model:ir.model.fields,help:sale_purchase_stock_auto_confirm.field_res_company__purchase_auto_validation
63+
#: model:ir.model.fields,help:sale_purchase_stock_auto_confirm.field_res_config_settings__purchase_auto_validation
64+
msgid ""
65+
"When a purchase order is created from a sales order using the MTO or "
66+
"Dropship rule for this company, it will be automatically validated."
67+
msgstr ""
68+
"Cuando se crea un pedido de compra a partir de un pedido de venta "
69+
"utilizando reglas MTO o Dropship para esta compañía, se validará "
70+
"automáticamente."
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_purchase_stock_auto_confirm
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 18.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2026-01-08 19:10+0000\n"
10+
"PO-Revision-Date: 2026-01-08 19:10+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: sale_purchase_stock_auto_confirm
19+
#: model_terms:ir.ui.view,arch_db:sale_purchase_stock_auto_confirm.res_config_settings_view_form
20+
msgid ""
21+
"Automatically validate purchase orders created from sales orders using MTO "
22+
"or Dropship rules."
23+
msgstr ""
24+
25+
#. module: sale_purchase_stock_auto_confirm
26+
#: model:ir.model,name:sale_purchase_stock_auto_confirm.model_res_company
27+
msgid "Companies"
28+
msgstr ""
29+
30+
#. module: sale_purchase_stock_auto_confirm
31+
#: model:ir.model,name:sale_purchase_stock_auto_confirm.model_res_config_settings
32+
msgid "Config Settings"
33+
msgstr ""
34+
35+
#. module: sale_purchase_stock_auto_confirm
36+
#: model:ir.model.fields,field_description:sale_purchase_stock_auto_confirm.field_res_company__purchase_auto_validation
37+
#: model:ir.model.fields,field_description:sale_purchase_stock_auto_confirm.field_res_config_settings__purchase_auto_validation
38+
msgid "POs Auto Validation"
39+
msgstr ""
40+
41+
#. module: sale_purchase_stock_auto_confirm
42+
#: model_terms:ir.ui.view,arch_db:sale_purchase_stock_auto_confirm.res_config_settings_view_form
43+
msgid "Purchase stock"
44+
msgstr ""
45+
46+
#. module: sale_purchase_stock_auto_confirm
47+
#. odoo-python
48+
#: code:addons/sale_purchase_stock_auto_confirm/tests/test_sale_purchase_stock_auto_confirm.py:0
49+
msgid "Replenish on Order (MTO)"
50+
msgstr ""
51+
52+
#. module: sale_purchase_stock_auto_confirm
53+
#: model:ir.model,name:sale_purchase_stock_auto_confirm.model_sale_order
54+
msgid "Sales Order"
55+
msgstr ""
56+
57+
#. module: sale_purchase_stock_auto_confirm
58+
#: model:ir.model.fields,help:sale_purchase_stock_auto_confirm.field_res_company__purchase_auto_validation
59+
#: model:ir.model.fields,help:sale_purchase_stock_auto_confirm.field_res_config_settings__purchase_auto_validation
60+
msgid ""
61+
"When a purchase order is created from a sales order using the MTO or "
62+
"Dropship rule for this company, it will be automatically validated."
63+
msgstr ""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import res_company
2+
from . import res_config_settings
3+
from . import sale_order
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2026 Tecnativa - Carlos Lopez
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResCompany(models.Model):
8+
_inherit = "res.company"
9+
10+
purchase_auto_validation = fields.Boolean(
11+
string="POs Auto Validation",
12+
help="When a purchase order is created from a sales order "
13+
"using the MTO or Dropship rule for this company, "
14+
"it will be automatically validated.",
15+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2026 Tecnativa - Carlos Lopez
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResConfigSettings(models.TransientModel):
8+
_inherit = "res.config.settings"
9+
10+
purchase_auto_validation = fields.Boolean(
11+
related="company_id.purchase_auto_validation",
12+
help="When a purchase order is created from a sales order "
13+
"using the MTO or Dropship rule for this company, "
14+
"it will be automatically validated.",
15+
readonly=False,
16+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2026 Tecnativa - Carlos Lopez
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class SaleOrder(models.Model):
8+
_inherit = "sale.order"
9+
10+
def _action_confirm(self):
11+
res = super()._action_confirm()
12+
for order in self:
13+
# Get the purchase orders using sudo,
14+
# as a sales user may not have access to the purchase order lines
15+
purchase_orders = order.sudo()._get_purchase_orders()
16+
for purchase in purchase_orders.filtered(
17+
lambda po: po.state == "draft"
18+
and po.company_id.purchase_auto_validation
19+
):
20+
purchase.button_confirm()
21+
return res

0 commit comments

Comments
 (0)