Skip to content

Commit bb53c4a

Browse files
[ADD] website_form_partner_website
1 parent 83fcd63 commit bb53c4a

11 files changed

Lines changed: 631 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../website_form_partner_website
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
============================
2+
Website Form Partner Website
3+
============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:2e500aa333d78504c4193278e7dcc9109518c14d7bb60052e41f51baa0777d78
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-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite-lightgray.png?logo=github
20+
:target: https://github.com/OCA/website/tree/15.0/website_form_partner_website
21+
:alt: OCA/website
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/website-15-0/website-15-0-website_form_partner_website
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/website&target_branch=15.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module assigns the current website to partners used by website
32+
forms and ensures partner lookup and assignment are restricted to that
33+
website.
34+
35+
In standard Odoo, partner searches triggered from the website may lead
36+
to incorrect assignments. For example, the partner assignment does not
37+
take the website into account and may assign the wrong partner when
38+
“Specific User Account” is enabled, which allows a separate user account
39+
to be created for each website even if they share the same email
40+
address.
41+
42+
This module addresses this issue.
43+
44+
**Table of contents**
45+
46+
.. contents::
47+
:local:
48+
49+
Known issues / Roadmap
50+
======================
51+
52+
Partner email is currently inferred from multiple possible form fields
53+
(email_from, partner_email, email).
54+
55+
Bug Tracker
56+
===========
57+
58+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/website/issues>`_.
59+
In case of trouble, please check there if your issue has already been reported.
60+
If you spotted it first, help us to smash it by providing a detailed and welcomed
61+
`feedback <https://github.com/OCA/website/issues/new?body=module:%20website_form_partner_website%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
62+
63+
Do not contact contributors directly about support or help with technical issues.
64+
65+
Credits
66+
=======
67+
68+
Authors
69+
-------
70+
71+
* Quartile
72+
73+
Contributors
74+
------------
75+
76+
- ``Quartile <https://www.quartile.co>``\ \_\_:
77+
78+
- Aung Ko Ko Lin
79+
80+
Maintainers
81+
-----------
82+
83+
This module is maintained by the OCA.
84+
85+
.. image:: https://odoo-community.org/logo.png
86+
:alt: Odoo Community Association
87+
:target: https://odoo-community.org
88+
89+
OCA, or the Odoo Community Association, is a nonprofit organization whose
90+
mission is to support the collaborative development of Odoo features and
91+
promote its widespread use.
92+
93+
.. |maintainer-yostashiro| image:: https://github.com/yostashiro.png?size=40px
94+
:target: https://github.com/yostashiro
95+
:alt: yostashiro
96+
.. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px
97+
:target: https://github.com/aungkokolin1997
98+
:alt: aungkokolin1997
99+
100+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
101+
102+
|maintainer-yostashiro| |maintainer-aungkokolin1997|
103+
104+
This module is part of the `OCA/website <https://github.com/OCA/website/tree/15.0/website_form_partner_website>`_ 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 controllers
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
3+
4+
{
5+
"name": "Website Form Partner Website",
6+
"version": "15.0.1.0.0",
7+
"category": "Website",
8+
"license": "LGPL-3",
9+
"author": "Quartile, Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/website",
11+
"depends": ["website"],
12+
"maintainers": ["yostashiro", "aungkokolin1997"],
13+
"installable": True,
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
3+
4+
from odoo.addons.website.controllers.form import WebsiteForm
5+
6+
7+
class WebsiteForm(WebsiteForm):
8+
def insert_record(self, request, model, values, custom, meta=None):
9+
website = request.website
10+
if not website.specific_user_account:
11+
return super().insert_record(request, model, values, custom, meta)
12+
partner_id = values.get("partner_id")
13+
if not partner_id:
14+
return super().insert_record(request, model, values, custom, meta)
15+
Partner = request.env["res.partner"].sudo()
16+
partner = Partner.browse(partner_id)
17+
if not partner.exists():
18+
return super().insert_record(request, model, values, custom, meta)
19+
email = (
20+
values.get("email_from")
21+
or values.get("partner_email")
22+
or values.get("email")
23+
)
24+
if not partner.website_id:
25+
partner.website_id = website.id
26+
if email and partner.website_id != website:
27+
website_partner = Partner.search(
28+
[
29+
("email", "=", email),
30+
("website_id", "=", website.id),
31+
],
32+
limit=1,
33+
)
34+
if not website_partner and values.get("partner_name"):
35+
website_partner = Partner.create(
36+
{
37+
"email": email,
38+
"name": values.get("partner_name"),
39+
"website_id": website.id,
40+
}
41+
)
42+
if website_partner:
43+
values["partner_id"] = website_partner.id
44+
return super().insert_record(request, model, values, custom, meta)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `Quartile <https://www.quartile.co>`__:
2+
3+
* Aung Ko Ko Lin
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This module assigns the current website to partners used by website forms and ensures
2+
partner lookup and assignment are restricted to that website.
3+
4+
In standard Odoo, partner searches triggered from the website may lead to incorrect
5+
assignments. For example, the partner assignment does not take the website into
6+
account and may assign the wrong partner when “Specific User Account” is enabled,
7+
which allows a separate user account to be created for each website even if they share
8+
the same email address.
9+
10+
This module addresses this issue.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Partner email is currently inferred from multiple possible form fields
2+
(email_from, partner_email, email).

0 commit comments

Comments
 (0)