Skip to content

Commit 66bf67c

Browse files
[ADD/MIG] Added migrated moduels ecommerce_first_last_name from v15 to v18
1 parent 92d0cde commit 66bf67c

File tree

13 files changed

+394
-0
lines changed

13 files changed

+394
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
=========================
2+
Ecommerce First Last Name
3+
=========================
4+
5+
This module Ecommerce First Last Name module is a part of Ecommerce and used in
6+
website to modify first name and last name of current user based on company type
7+
8+
**Table of contents**
9+
10+
.. contents::
11+
:local:
12+
13+
Usage
14+
=====
15+
16+
To check functionality of this module,
17+
18+
1) Go to "Website" > "My Account" > "Edit Your Account"
19+
2) You will see two edit box which are "First Name" and "Last Name" based on type of company.
20+
21+
Bug Tracker
22+
===========
23+
24+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
25+
In case of trouble, please check there if your issue has already been reported.
26+
If you spotted it first, help us smashing it by providing a detailed and welcomed.
27+
28+
Do not contact contributors directly about support or help with technical issues.
29+
30+
Credits
31+
=======
32+
33+
Authors
34+
~~~~~~~
35+
36+
* Nitrokey GmbH
37+
38+
Contributors
39+
~~~~~~~~~~~~
40+
41+
* Dhara Solanki <dsolanki@initos.com>
42+
43+
44+
Maintainers
45+
~~~~~~~~~~~
46+
47+
This module is maintained by the OCA.
48+
49+
.. image:: https://odoo-community.org/logo.png
50+
:alt: Odoo Community Association
51+
:target: https://odoo-community.org
52+
53+
OCA, or the Odoo Community Association, is a nonprofit organization whose
54+
mission is to support the collaborative development of Odoo features and
55+
promote its widespread use.
56+
57+
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/15.0/ecommerce_first_last_name>`_ project on GitHub.
58+
59+
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, models
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Ecommerce First last name",
3+
"category": "other",
4+
"version": "18.0.1.0.0",
5+
"author": "Nitrokey GmbH," "Odoo Community Association (OCA)",
6+
"summary": """Ecommerce First last name""",
7+
"sequence": "1",
8+
"website": "https://github.com/OCA/e-commerce",
9+
"license": "AGPL-3",
10+
"depends": ["website_sale"],
11+
"data": [
12+
"views/templates.xml",
13+
],
14+
"assets": {
15+
"web.assets_frontend": [
16+
"ecommerce_first_last_name/static/src/js/**/*",
17+
],
18+
},
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import logging
2+
3+
from odoo.addons.website_sale.controllers.main import WebsiteSale
4+
from odoo.tools.translate import _
5+
6+
_logger = logging.getLogger(__name__)
7+
8+
9+
class WebsiteSaleFirstLastname(WebsiteSale):
10+
def _validate_address_values(
11+
self,
12+
address_values,
13+
partner_sudo,
14+
address_type,
15+
use_delivery_as_billing,
16+
required_fields,
17+
is_main_address,
18+
**kwargs,
19+
):
20+
"""Raise validation save time"""
21+
invalid_fields, missing_fields, error_messages = super()._validate_address_values(
22+
address_values,
23+
partner_sudo,
24+
address_type,
25+
use_delivery_as_billing,
26+
required_fields,
27+
is_main_address,
28+
**kwargs
29+
)
30+
# Change first or last name
31+
if partner_sudo and not partner_sudo._can_edit_name():
32+
full_name = partner_sudo.name or ""
33+
old_first, old_last = (full_name.split(" ", 1) + [""])[:2]
34+
35+
new_first = address_values.get("name", "").split(" ", 1)[0]
36+
new_last = address_values.get("last_name", "")
37+
38+
first_name_changed = new_first != old_first
39+
last_name_changed = new_last != old_last
40+
41+
# Case 1: both changed
42+
if first_name_changed and last_name_changed:
43+
invalid_fields.update("name")
44+
invalid_fields.add("last_name")
45+
# Case 2: only first name changed
46+
elif first_name_changed and not last_name_changed:
47+
invalid_fields.discard("last_name")
48+
invalid_fields.add("name")
49+
# Case 3: only last name changed
50+
elif last_name_changed and not first_name_changed:
51+
invalid_fields.discard("name")
52+
invalid_fields.add("last_name")
53+
54+
return invalid_fields, missing_fields, error_messages
55+
56+
def _parse_form_data(self, form_data):
57+
"""Call the method when save the address"""
58+
address_values, extra_form_data = super()._parse_form_data(form_data)
59+
# Added the first and last name in full name
60+
last_name = extra_form_data.get("last_name")
61+
if last_name and address_values.get("name"):
62+
extra_form_data["first_name"] = address_values.get("name")
63+
address_values["name"] = address_values.get("name") + " " + last_name
64+
elif last_name:
65+
address_values["name"] = last_name
66+
# Set company type
67+
company_type = "person"
68+
if company_type:
69+
address_values["company_type"] = company_type
70+
if last_name:
71+
address_values["last_name"] = last_name
72+
return address_values, extra_form_data
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * ecommerce_first_last_name
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-07-18 09:15+0000\n"
10+
"PO-Revision-Date: 2025-07-18 09:15+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: ecommerce_first_last_name
19+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
20+
msgid "Business Customer"
21+
msgstr "Geschäftskunde"
22+
23+
#. module: ecommerce_first_last_name
24+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
25+
msgid ""
26+
"Changing VAT number is not allowed once document(s) have been issued for your account. Please\n"
27+
" contact us directly for this operation."
28+
msgstr "Das Ändern der Umsatzsteuer-Identifikationsnummer ist nicht zulässig, sobald Dokumente für Ihr Konto ausgestellt wurden.\n"
29+
"Bitte kontaktieren Sie uns direkt für diesen Vorgang."
30+
31+
#. module: ecommerce_first_last_name
32+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
33+
msgid ""
34+
"Changing company name is not allowed once document(s) have been issued for your account. Please contact\n"
35+
" us directly for this operation."
36+
msgstr "Das Ändern der Firmenbezeichnung ist nicht zulässig, sobald Dokumente für Ihr Konto ausgestellt wurden.\n"
37+
"Bitte kontaktieren Sie uns direkt für diesen Vorgang."
38+
39+
#. module: ecommerce_first_last_name
40+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
41+
msgid "Company Name"
42+
msgstr "Unternehmensname"
43+
44+
#. module: ecommerce_first_last_name
45+
#: model:ir.model,name:ecommerce_first_last_name.model_res_partner
46+
msgid "Contact"
47+
msgstr "Kontakt"
48+
49+
#. module: ecommerce_first_last_name
50+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
51+
msgid "First name"
52+
msgstr "Vorname"
53+
54+
#. module: ecommerce_first_last_name
55+
#: model:ir.model.fields,field_description:ecommerce_first_last_name.field_res_partner__last_name
56+
#: model:ir.model.fields,field_description:ecommerce_first_last_name.field_res_users__last_name
57+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
58+
msgid "Last Name"
59+
msgstr "Nachname"
60+
61+
#. module: ecommerce_first_last_name
62+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
63+
msgid "Private Customer"
64+
msgstr "Privatkunde"
65+
66+
#. module: ecommerce_first_last_name
67+
#: model_terms:ir.ui.view,arch_db:ecommerce_first_last_name.address_inherit
68+
msgid "TIN / VAT"
69+
msgstr "USt-IdNr."
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_partner
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from odoo import fields, models
2+
3+
4+
class ResPartner(models.Model):
5+
_inherit = "res.partner"
6+
7+
last_name = fields.Char()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Dhara Solanki <dsolanki@initos.com>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ecommerce First Last Name module is a part of Ecommerce and used in website to
2+
modify first name and last name of current user based on company type

0 commit comments

Comments
 (0)