Skip to content

Commit

Permalink
T1851 [ADD] partner matching during checkout
Browse files Browse the repository at this point in the history
- This avoids partner duplications when someone is donating through the website
  • Loading branch information
ecino committed Sep 26, 2024
1 parent fa62389 commit db44673
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 11 deletions.
8 changes: 8 additions & 0 deletions website_sale_donation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Helper module to manage donations in the e-commerce platform.
.. contents::
:local:

Changelog
=========

14.0.1.1.0
----------

- [ADD] Automatically match partner during checkout.

Bug Tracker
===========

Expand Down
1 change: 1 addition & 0 deletions website_sale_donation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
from . import controllers
3 changes: 2 additions & 1 deletion website_sale_donation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Website - Sale donation",
"summary": "Allows to have a product considered as a donation",
"version": "14.0.1.0.0",
"version": "14.0.1.1.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/CompassionCH/compassion-website",
Expand All @@ -19,6 +19,7 @@
"website_sale",
"mass_mailing",
"base_automation",
"partner_auto_match",
],
"data": [
"data/base_automation.xml",
Expand Down
1 change: 1 addition & 0 deletions website_sale_donation/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import website_sale
17 changes: 17 additions & 0 deletions website_sale_donation/controllers/website_sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo.http import request

from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteSaleDonation(WebsiteSale):
def _checkout_form_save(self, mode, checkout, all_values):
# Try to match existing partner if possible
if mode[0] == "new":
partner = (
request.env["res.partner.match"]
.sudo()
.match_values_to_partner(checkout, match_create=False)
)
if partner:
return partner[:1].id
return super()._checkout_form_save(mode, checkout, all_values)
3 changes: 3 additions & 0 deletions website_sale_donation/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 14.0.1.1.0

- [ADD] Automatically match partner during checkout.
33 changes: 23 additions & 10 deletions website_sale_donation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,39 +373,52 @@ <h1 class="title">Website - Sale donation</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#changelog" id="toc-entry-1">Changelog</a><ul>
<li><a class="reference internal" href="#section-1" id="toc-entry-2">14.0.1.1.0</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#toc-entry-1">Changelog</a></h1>
<div class="section" id="section-1">
<h2><a class="toc-backref" href="#toc-entry-2">14.0.1.1.0</a></h2>
<ul class="simple">
<li>[ADD] Automatically match partner during checkout.</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/CompassionCH/compassion-website/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/CompassionCH/compassion-website/issues/new?body=module:%20website_sale_donation%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Compassion Switzerland</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Emanuel Cino <a class="reference external" href="mailto:ecino&#64;compassion.ch">ecino&#64;compassion.ch</a></li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>Current maintainer:</p>
<p><a class="reference external image-reference" href="https://github.com/ecino"><img alt="ecino" src="https://github.com/ecino.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/CompassionCH/compassion-website/tree/14.0/website_sale_donation">CompassionCH/compassion-website</a> project on GitHub.</p>
Expand Down

0 comments on commit db44673

Please sign in to comment.