Skip to content

Commit 0972ad5

Browse files
[ADD] website_form_partner_specific_user_account
1 parent 83fcd63 commit 0972ad5

13 files changed

Lines changed: 722 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_specific_user_account
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: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
==========================================
2+
Website Form Partner Specific User Account
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-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%2Fwebsite-lightgray.png?logo=github
20+
:target: https://github.com/OCA/website/tree/15.0/website_form_partner_specific_user_account
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_specific_user_account
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 is intended for use when the “Specific User Account” setting
32+
is enabled on a website.
33+
34+
It assigns the current website to partners used by website forms and
35+
ensures partner lookup and assignment are restricted to that website.
36+
37+
In standard Odoo, partner resolution from website forms does not
38+
consider the current website. When “Specific User Account” is enabled,
39+
this may result in a partner from another website being assigned if the
40+
same email address exists across multiple websites.
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+
Note: The module assigns the current website to partners missing
56+
``website_id``, affecting not only newly created partners from website
57+
forms but also existing partners when they are used in a website form.
58+
59+
Bug Tracker
60+
===========
61+
62+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/website/issues>`_.
63+
In case of trouble, please check there if your issue has already been reported.
64+
If you spotted it first, help us to smash it by providing a detailed and welcomed
65+
`feedback <https://github.com/OCA/website/issues/new?body=module:%20website_form_partner_specific_user_account%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
66+
67+
Do not contact contributors directly about support or help with technical issues.
68+
69+
Credits
70+
=======
71+
72+
Authors
73+
-------
74+
75+
* Quartile
76+
77+
Contributors
78+
------------
79+
80+
- ``Quartile <https://www.quartile.co>``\ \_\_:
81+
82+
- Aung Ko Ko Lin
83+
- Yoshi Tashiro
84+
85+
Maintainers
86+
-----------
87+
88+
This module is maintained by the OCA.
89+
90+
.. image:: https://odoo-community.org/logo.png
91+
:alt: Odoo Community Association
92+
:target: https://odoo-community.org
93+
94+
OCA, or the Odoo Community Association, is a nonprofit organization whose
95+
mission is to support the collaborative development of Odoo features and
96+
promote its widespread use.
97+
98+
.. |maintainer-yostashiro| image:: https://github.com/yostashiro.png?size=40px
99+
:target: https://github.com/yostashiro
100+
:alt: yostashiro
101+
.. |maintainer-aungkokolin1997| image:: https://github.com/aungkokolin1997.png?size=40px
102+
:target: https://github.com/aungkokolin1997
103+
:alt: aungkokolin1997
104+
105+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
106+
107+
|maintainer-yostashiro| |maintainer-aungkokolin1997|
108+
109+
This module is part of the `OCA/website <https://github.com/OCA/website/tree/15.0/website_form_partner_specific_user_account>`_ project on GitHub.
110+
111+
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 AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Website Form Partner Specific User Account",
6+
"version": "15.0.1.0.0",
7+
"category": "Website",
8+
"license": "AGPL-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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
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+
# Intended for newly created partners, but applies to any partner without website_id
25+
if not partner.website_id:
26+
partner.website_id = website.id
27+
if email and partner.website_id != website:
28+
website_partner = Partner.search(
29+
[
30+
("email", "=", email),
31+
("website_id", "=", website.id),
32+
],
33+
limit=1,
34+
)
35+
if not website_partner and values.get("partner_name"):
36+
website_partner = Partner.create(
37+
{
38+
"email": email,
39+
"name": values.get("partner_name"),
40+
"website_id": website.id,
41+
}
42+
)
43+
if website_partner:
44+
values["partner_id"] = website_partner.id
45+
return super().insert_record(request, model, values, custom, meta)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* `Quartile <https://www.quartile.co>`__:
2+
3+
* Aung Ko Ko Lin
4+
* Yoshi Tashiro
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
This module is intended for use when the “Specific User Account” setting is enabled
2+
on a website.
3+
4+
It assigns the current website to partners used by website forms and ensures partner
5+
lookup and assignment are restricted to that website.
6+
7+
In standard Odoo, partner resolution from website forms does not consider the
8+
current website. When “Specific User Account” is enabled, this may result in a
9+
partner from another website being assigned if the same email address exists
10+
across multiple websites.
11+
12+
This module addresses this issue.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Partner email is currently inferred from multiple possible form fields
2+
(email_from, partner_email, email).
3+
4+
Note: The module assigns the current website to partners missing `website_id`, affecting
5+
not only newly created partners from website forms but also existing partners when they
6+
are used in a website form.

0 commit comments

Comments
 (0)