Skip to content

Commit a88437f

Browse files
author
Vicent-S73
committed
[MIG] website_sale_order_type: Migration to 19.0
1 parent d7dd8b2 commit a88437f

7 files changed

Lines changed: 90 additions & 37 deletions

File tree

website_sale_order_type/README.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
=======================
26
Website sale order type
37
=======================
@@ -13,17 +17,17 @@ Website sale order type
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github
20-
:target: https://github.com/OCA/e-commerce/tree/18.0/website_sale_order_type
24+
:target: https://github.com/OCA/e-commerce/tree/19.0/website_sale_order_type
2125
:alt: OCA/e-commerce
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_order_type
27+
:target: https://translation.odoo-community.org/projects/e-commerce-19-0/e-commerce-19-0-website_sale_order_type
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -61,7 +65,7 @@ Bug Tracker
6165
Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
6266
In case of trouble, please check there if your issue has already been reported.
6367
If you spotted it first, help us to smash it by providing a detailed and welcomed
64-
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_order_type%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
68+
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_order_type%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6569

6670
Do not contact contributors directly about support or help with technical issues.
6771

@@ -85,6 +89,10 @@ Contributors
8589
- Stefan Ungureanu
8690
- Carlos Lopez
8791

92+
- `Studio73 <https://www.studio73.es/>`__:
93+
94+
- Vicent Castells
95+
8896
Maintainers
8997
-----------
9098

@@ -106,6 +114,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
106114

107115
|maintainer-pilarvargas-tecnativa|
108116

109-
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/18.0/website_sale_order_type>`_ project on GitHub.
117+
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/19.0/website_sale_order_type>`_ project on GitHub.
110118

111119
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

website_sale_order_type/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Website sale order type",
66
"summary": "This module allows sale_order_type to work with website_sale.",
7-
"version": "18.0.1.0.0",
7+
"version": "19.0.1.0.0",
88
"development_status": "Beta",
99
"category": "Website",
1010
"website": "https://github.com/OCA/e-commerce",
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
# Copyright 2023 Tecnativa - Pilar Vargas
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

4-
from odoo import api, models
4+
from odoo import models
55

66

77
class Website(models.Model):
88
_inherit = "website"
99

10-
@api.model
11-
def sale_get_payment_term(self, partner):
12-
if partner.sale_type.payment_term_id:
13-
return partner.sale_type.payment_term_id.id
14-
return super().sale_get_payment_term(partner)
10+
def _prepare_sale_order_values(self, partner_sudo):
11+
self.ensure_one()
12+
so_data = super()._prepare_sale_order_values(partner_sudo)
1513

16-
def _get_current_pricelist(self):
17-
partner_sudo = self.env.user.partner_id
18-
if partner_sudo.sale_type.pricelist_id:
19-
return partner_sudo.sale_type.pricelist_id.id
20-
return super()._get_current_pricelist()
14+
sale_type = partner_sudo.sale_type
15+
if sale_type:
16+
so_data["type_id"] = sale_type.id
17+
if sale_type.payment_term_id:
18+
so_data["payment_term_id"] = sale_type.payment_term_id.id
19+
return so_data
20+
21+
def get_pricelist_available(self, show_visible=False):
22+
website = self.with_company(self.company_id)
23+
partner_sudo = website.env.user.partner_id
24+
sale_type_pricelist = partner_sudo.sale_type.pricelist_id
25+
country_code = website._get_geoip_country_code()
26+
if (
27+
sale_type_pricelist
28+
and sale_type_pricelist._is_available_on_website(website)
29+
and sale_type_pricelist._is_available_in_country(country_code)
30+
):
31+
return sale_type_pricelist
32+
return super().get_pricelist_available(show_visible)

website_sale_order_type/readme/CONTRIBUTORS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
> - Pilar Vargas
77
> - Stefan Ungureanu
88
> - Carlos Lopez
9+
10+
- [Studio73](https://www.studio73.es/):
11+
> - Vicent Castells

website_sale_order_type/static/description/index.html

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Website sale order type</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="website-sale-order-type">
364-
<h1 class="title">Website sale order type</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="website-sale-order-type">
370+
<h1>Website sale order type</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370375
!! source digest: sha256:5f6d6f491b82d69808d11f2b0bc9db9610384f5e9b7c312b7c94712b26abcbec
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/e-commerce/tree/18.0/website_sale_order_type"><img alt="OCA/e-commerce" src="https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/e-commerce-18-0/e-commerce-18-0-website_sale_order_type"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/e-commerce/tree/19.0/website_sale_order_type"><img alt="OCA/e-commerce" src="https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/e-commerce-19-0/e-commerce-19-0-website_sale_order_type"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>This module allows
374379
<a class="reference external" href="https://github.com/OCA/sale-workflow/tree/17.0/sale_order_type">sale_order_type</a>
375380
to work with websitesale.</p>
@@ -393,7 +398,7 @@ <h1 class="title">Website sale order type</h1>
393398
</ul>
394399
</div>
395400
<div class="section" id="usage">
396-
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
401+
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
397402
<ol class="arabic simple">
398403
<li>In the backend (Sales -&gt; Customers) set a sale order type in any
399404
contact;</li>
@@ -404,23 +409,23 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
404409
</ol>
405410
</div>
406411
<div class="section" id="bug-tracker">
407-
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
412+
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
408413
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/e-commerce/issues">GitHub Issues</a>.
409414
In case of trouble, please check there if your issue has already been reported.
410415
If you spotted it first, help us to smash it by providing a detailed and welcomed
411-
<a class="reference external" href="https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_order_type%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
416+
<a class="reference external" href="https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_order_type%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
412417
<p>Do not contact contributors directly about support or help with technical issues.</p>
413418
</div>
414419
<div class="section" id="credits">
415-
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
420+
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
416421
<div class="section" id="authors">
417-
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
422+
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
418423
<ul class="simple">
419424
<li>Agile Business Group</li>
420425
</ul>
421426
</div>
422427
<div class="section" id="contributors">
423-
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
428+
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
424429
<ul>
425430
<li><p class="first">Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;agilebg.com">simone.rubino&#64;agilebg.com</a>&gt;</p>
426431
</li>
@@ -434,10 +439,17 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
434439
</ul>
435440
</blockquote>
436441
</li>
442+
<li><p class="first"><a class="reference external" href="https://www.studio73.es/">Studio73</a>:</p>
443+
<blockquote>
444+
<ul class="simple">
445+
<li>Vicent Castells</li>
446+
</ul>
447+
</blockquote>
448+
</li>
437449
</ul>
438450
</div>
439451
<div class="section" id="maintainers">
440-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
452+
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
441453
<p>This module is maintained by the OCA.</p>
442454
<a class="reference external image-reference" href="https://odoo-community.org">
443455
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -447,10 +459,11 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
447459
promote its widespread use.</p>
448460
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
449461
<p><a class="reference external image-reference" href="https://github.com/pilarvargas-tecnativa"><img alt="pilarvargas-tecnativa" src="https://github.com/pilarvargas-tecnativa.png?size=40px" /></a></p>
450-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/e-commerce/tree/18.0/website_sale_order_type">OCA/e-commerce</a> project on GitHub.</p>
462+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/e-commerce/tree/19.0/website_sale_order_type">OCA/e-commerce</a> project on GitHub.</p>
451463
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
452464
</div>
453465
</div>
454466
</div>
467+
</div>
455468
</body>
456469
</html>

website_sale_order_type/static/tests/tours/website_sale_order_type_tour.esm.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
/** @odoo-module */
21
/* Copyright 2020 Tecnativa - João Marques
32
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
43

54
import {registry} from "@web/core/registry";
65

76
registry.category("web_tour.tours").add("website_sale_order_type_tour", {
87
test: true,
9-
url: "/shop",
8+
url: "/shop?search=Test Product SO Type",
109
steps: () => [
1110
{
12-
trigger: ".oe_product_cart a:contains('Test Product SO Type')",
11+
trigger: ".oe_product_cart a:text(Test Product SO Type)",
1312
run: "click",
13+
expectUnloadPage: true,
1414
},
1515
{
1616
trigger: "#add_to_cart",
1717
run: "click",
1818
},
19-
{
20-
trigger: "a[href='/shop/cart']",
21-
},
2219
{
2320
trigger: "sup.my_cart_quantity:contains('1')",
2421
run: "click",
22+
expectUnloadPage: true,
2523
},
2624
{
2725
trigger: ".btn:contains('Checkout')",

website_sale_order_type/tests/test_website_sale_order_type.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ def setUpClass(cls):
1818
}
1919
)
2020
cls.partner = cls.env.ref("base.partner_admin")
21+
cls.website = cls.env["website"].search(
22+
[("company_id", "=", cls.env.company.id)], limit=1
23+
)
2124
cls.sale_pricelist = cls.env["product.pricelist"].create(
22-
{"name": "Test Pricelist"}
25+
{
26+
"name": "Test Pricelist",
27+
"website_id": cls.website.id,
28+
}
2329
)
2430
cls.sale_type = cls.create_sale_type()
2531

@@ -62,3 +68,16 @@ def test_website_sale_order_type(self):
6268
self.assertEqual(created_order.type_id, self.sale_type)
6369
self.assertEqual(created_order.payment_term_id, self.sale_type.payment_term_id)
6470
self.assertEqual(created_order.pricelist_id, self.sale_type.pricelist_id)
71+
72+
def test_get_pricelist_available_filtered_by_sale_type(self):
73+
if not self.env["res.groups"]._is_feature_enabled(
74+
"product.group_product_pricelist"
75+
):
76+
self.skipTest("Pricelist feature is disabled.")
77+
self.partner.sale_type = self.sale_type
78+
admin = self.env.ref("base.user_admin")
79+
website = self.env["website"].get_current_website().with_user(admin)
80+
81+
pricelists = website.get_pricelist_available()
82+
83+
self.assertEqual(pricelists, self.sale_type.pricelist_id)

0 commit comments

Comments
 (0)