Skip to content

Commit 267b63b

Browse files
committed
[19.0][ADD] website_sale_stock_picking_policy
1 parent be018cf commit 267b63b

10 files changed

Lines changed: 736 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
5+
===================================
6+
Website Sale - Stock Picking Policy
7+
===================================
8+
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
!! This file is generated by oca-gen-addon-readme !!
12+
!! changes will be overwritten. !!
13+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:e18d544c66eaee59fd1877c66b5a0bfac6789648fd5b4594a1f8e0143ab47dc6
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
17+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
18+
:target: https://odoo-community.org/page/development-status
19+
:alt: Beta
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
21+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
22+
:alt: License: AGPL-3
23+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github
24+
:target: https://github.com/OCA/e-commerce/tree/19.0/website_sale_stock_picking_policy
25+
:alt: OCA/e-commerce
26+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27+
:target: https://translation.odoo-community.org/projects/e-commerce-19-0/e-commerce-19-0-website_sale_stock_picking_policy
28+
:alt: Translate me on Weblate
29+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=19.0
31+
:alt: Try me on Runboat
32+
33+
|badge1| |badge2| |badge3| |badge4| |badge5|
34+
35+
Website Sale - Picking Policy
36+
-----------------------------
37+
38+
This module extends Odoo eCommerce checkout to let customers choose how
39+
deliverable products are shipped from their cart.
40+
41+
At checkout, a **Shipping Policy** section is added with the available
42+
``picking_policy`` options from the sale order (for example,
43+
consolidated delivery in one shipment).
44+
45+
When the customer changes the policy:
46+
47+
- The cart ``picking_policy`` is updated immediately through a JSON
48+
route.
49+
- The estimated delivery date shown in checkout is refreshed when
50+
relevant.
51+
52+
The policy selector is only displayed when the cart contains deliverable
53+
products.
54+
55+
**Table of contents**
56+
57+
.. contents::
58+
:local:
59+
60+
Bug Tracker
61+
===========
62+
63+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
64+
In case of trouble, please check there if your issue has already been reported.
65+
If you spotted it first, help us to smash it by providing a detailed and welcomed
66+
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_stock_picking_policy%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
67+
68+
Do not contact contributors directly about support or help with technical issues.
69+
70+
Credits
71+
=======
72+
73+
Authors
74+
-------
75+
76+
* Camptocamp
77+
78+
Maintainers
79+
-----------
80+
81+
This module is maintained by the OCA.
82+
83+
.. image:: https://odoo-community.org/logo.png
84+
:alt: Odoo Community Association
85+
:target: https://odoo-community.org
86+
87+
OCA, or the Odoo Community Association, is a nonprofit organization whose
88+
mission is to support the collaborative development of Odoo features and
89+
promote its widespread use.
90+
91+
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/19.0/website_sale_stock_picking_policy>`_ project on GitHub.
92+
93+
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 controllers
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2026 Camptocamp SA (https://www.camptocamp.com).
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Website Sale - Stock Picking Policy",
6+
"summary": "Let customers choose consolidated delivery at checkout",
7+
"version": "19.0.1.0.0",
8+
"author": "Camptocamp, Odoo Community Association (OCA)",
9+
"license": "AGPL-3",
10+
"website": "https://github.com/OCA/e-commerce",
11+
"category": "Website/Website",
12+
"depends": [
13+
"website_sale",
14+
],
15+
"data": [
16+
"views/templates.xml",
17+
],
18+
"assets": {
19+
"web.assets_frontend": [
20+
"website_sale_stock_picking_policy/static/src/js/picking_policy.esm.js",
21+
],
22+
},
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2026 Camptocamp SA (https://www.camptocamp.com).
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields
5+
from odoo.exceptions import UserError
6+
from odoo.http import request, route
7+
8+
from odoo.addons.website_sale.controllers.main import WebsiteSale
9+
10+
11+
class WebsiteSalePickingPolicy(WebsiteSale):
12+
def _prepare_checkout_page_values(self, order_sudo, **kwargs):
13+
# Prepare checkout page values including picking policy selection.
14+
result = super()._prepare_checkout_page_values(order_sudo, **kwargs)
15+
16+
picking_policy_selection = dict(
17+
order_sudo._fields["picking_policy"]._description_selection(request.env)
18+
)
19+
20+
result.update(
21+
{
22+
"picking_policy_selection_values": picking_policy_selection,
23+
}
24+
)
25+
26+
return result
27+
28+
@route(
29+
"/shop/update_picking_policy",
30+
type="jsonrpc",
31+
auth="public",
32+
website=True,
33+
methods=["POST"],
34+
)
35+
def update_picking_policy(self, picking_policy, **kwargs):
36+
"""Update the picking policy field on the current cart."""
37+
38+
order = request.cart
39+
if not order:
40+
raise UserError(request.env._("No active cart found."))
41+
42+
order.write({"picking_policy": picking_policy})
43+
44+
result = {}
45+
if order.expected_date:
46+
result["expected_date"] = fields.Date.to_string(
47+
fields.Date.context_today(order, order.expected_date)
48+
)
49+
else:
50+
result["expected_date"] = False
51+
52+
return result
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Website Sale - Picking Policy
2+
3+
This module extends Odoo eCommerce checkout to let customers choose how
4+
deliverable products are shipped from their cart.
5+
6+
At checkout, a **Shipping Policy** section is added with the available
7+
`picking_policy` options from the sale order (for example, consolidated
8+
delivery in one shipment).
9+
10+
When the customer changes the policy:
11+
12+
- The cart `picking_policy` is updated immediately through a JSON route.
13+
- The estimated delivery date shown in checkout is refreshed when
14+
relevant.
15+
16+
The policy selector is only displayed when the cart contains deliverable
17+
products.

0 commit comments

Comments
 (0)