Skip to content
Extraits de code Groupes Projets
Valider f0f7a9e2 rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[ADD] fields on portal /my/account and change license

parent b0501864
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de avec 546 ajouts et 149 suppressions
......@@ -22,6 +22,7 @@ globals:
odoo: readonly
openerp: readonly
owl: readonly
luxon: readonly
# Styling is handled by Prettier, so we only need to enable AST rules;
# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890
......
[flake8]
max-line-length = 88
max-complexity = 16
# B = bugbear
# B9 = bugbear opinionated (incl line length)
select = C,E,F,W,B,B9
# E203: whitespace before ':' (black behaviour)
# E501: flake8 line length (covered by bugbear B950)
# W503: line break before binary operator (black behaviour)
ignore = E203,E501,W503
per-file-ignores=
__init__.py:F401
......@@ -3,6 +3,7 @@ __pycache__/
*.py[cod]
/.venv
/.pytest_cache
/.ruff_cache
# C extensions
*.so
......@@ -23,6 +24,7 @@ var/
.installed.cfg
*.egg
*.eggs
.copier-answers.yml
# Installer logs
pip-log.txt
......
[settings]
; see https://github.com/psf/black
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
use_parentheses=True
line_length=88
known_odoo=odoo
known_odoo_addons=odoo.addons
sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
ensure_newline_before_comments = True
......@@ -12,6 +12,10 @@ exclude: |
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
^docs/_templates/.*\.html$|
# Don't bother non-technical authors with formatting issues in docs
readme/.*\.(rst|md)$|
# Ignore build and dist directories in addons
/build/|/dist/|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
......@@ -33,27 +37,25 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: 4cd2b852214dead80822e93e6749b16f2785b2fe
rev: f71041f22b8cd68cf7c77b73a14ca8d8cd190a60
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["https://le-filament.com"]
- repo: https://github.com/myint/autoflake
rev: v1.6.1
hooks:
- id: autoflake
- id: oca-gen-addon-readme
args:
- --expand-star-imports
- --ignore-init-module-imports
- --in-place
- --remove-all-unused-imports
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/psf/black
rev: 22.8.0
- --addons-dir=.
- --branch=16.0
- --org-name=lefilament
- --repo-name=template_module
- --if-source-changed
- --keep-source-digest
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.25
hooks:
- id: black
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
......@@ -95,27 +97,14 @@ repos:
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.2
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==21.9.2"]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/OCA/pylint-odoo
rev: 7.0.2
rev: v8.0.19
hooks:
- id: pylint_odoo
name: pylint with optional checks
......
......@@ -4,12 +4,12 @@ load-plugins=pylint_odoo
score=n
[ODOOLINT]
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest_required_authors=Le Filament
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid_odoo_versions=16.0
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest-required-authors=Le Filament
manifest-required-keys=license
manifest-deprecated-keys=description,active
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid-odoo-versions=16.0
[MESSAGES CONTROL]
disable=all
......
target-version = "py310"
fix = true
[lint]
extend-select = [
"B",
"C90",
"E501", # line too long (default 88)
"I", # isort
"UP", # pyupgrade
]
exclude = ["setup/*"]
[format]
exclude = ["setup/*"]
[per-file-ignores]
"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py
"__manifest__.py" = ["B018"] # useless expression
[isort]
section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"]
[isort.sections]
"odoo" = ["odoo"]
"odoo-addons" = ["odoo.addons"]
[mccabe]
max-complexity = 16
Ce diff est replié.
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl.html
:alt: License: AGPL-3
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl.html
:alt: License: LGPL-3
==================
......
from . import models
from . import controllers, models
{
"name": "Solagro - Contacts",
"author": "Le Filament",
"author": "Le Filament, Odoo S.A.",
"website": "https://le-filament.com",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"license": "LGPL-3",
"depends": ["contacts", "l10n_fr_siret"],
"data": [
"security/ir.model.access.csv",
"data/res_partner_domain_data.xml",
"views/event_old_view.xml",
"views/journalist_topic_view.xml",
"views/portal_details_template.xml",
"views/res_partner_view.xml",
"views/res_partner_interest_view.xml",
"views/res_partner_theme_view.xml",
......
from . import portal
# Copyright 2024- Le Filame:qnt (https://le-filament.com)
# Copyright Odoo S.A. (https://odoo.com)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
# Functions in this modules could not be inherited and are therefore copied
# from Odoo code (https://github.com/odoo/odoo/blob/16.0/addons/portal/controllers/portal.py)
# and modified to change fields displayed on portal
from odoo import _, tools
from odoo.exceptions import ValidationError
from odoo.http import request, route
from odoo.addons.portal.controllers import portal
class CustomerPortal(portal.CustomerPortal):
# Added new lists with mandatory / optional fields
MANDATORY_CONTACT_FIELDS = ["name", "email"]
OPTIONAL_CONTACT_FIELDS = [
"zipcode",
"phone",
"street",
"city",
"country_id",
"state_id",
"vat",
"company_name",
"department",
"function",
]
@route(["/my/account"], type="http", auth="user", website=True)
def account(self, redirect=None, **post):
values = self._prepare_portal_layout_values()
partner = request.env.user.partner_id
values.update(
{
"error": {},
"error_message": [],
}
)
# Added list of thematics and domains
thematics = request.env["res.partner.theme"].sudo().search([])
domains = request.env["res.partner.domain"].sudo().search([])
if post and request.httprequest.method == "POST":
error, error_message = self.details_form_validate(post)
values.update({"error": error, "error_message": error_message})
values.update(post)
if not error:
# Updated to get mandatory and optional fields from this
# module instead of Odoo default
values = {key: post[key] for key in self.MANDATORY_CONTACT_FIELDS}
values.update(
{
key: post[key]
for key in self.OPTIONAL_CONTACT_FIELDS
if key in post
}
)
for field in {"country_id", "state_id"} & set(values.keys()):
try:
values[field] = int(values[field])
except Exception:
values[field] = False
# Added compute of m2m thematic_ids and domain_ids
values.update(
{
"thematic_ids": [
(
6,
0,
[
int(post.get(f"theme-{theme_id}", ""))
for theme_id in thematics.ids
if f"theme-{theme_id}" in post
],
)
]
}
)
values.update(
{
"domain_ids": [
(
6,
0,
[
int(post.get(f"domain-{domain_id}", ""))
for domain_id in domains.ids
if f"domain-{domain_id}" in post
],
)
]
}
)
values.update({"zip": values.pop("zipcode", "")})
self.on_account_update(values, partner)
partner.sudo().write(values)
if redirect:
return request.redirect(redirect)
return request.redirect("/my/home")
countries = request.env["res.country"].sudo().search([])
states = request.env["res.country.state"].sudo().search([])
values.update(
{
"partner": partner,
"countries": countries,
"states": states,
# Added list of thematics and themes
"thematics": thematics,
"domains": domains,
"has_check_vat": hasattr(request.env["res.partner"], "check_vat"),
"partner_can_edit_vat": partner.can_edit_vat(),
"redirect": redirect,
"page_name": "my_details",
}
)
response = request.render("portal.portal_my_details", values)
response.headers["X-Frame-Options"] = "SAMEORIGIN"
response.headers["Content-Security-Policy"] = "frame-ancestors 'self'"
return response
def details_form_validate(self, data, partner_creation=False):
error = dict()
error_message = []
# Validation
# Updated to use this module mandatory fields variable iso Odoo default
for field_name in self.MANDATORY_CONTACT_FIELDS:
if not data.get(field_name):
error[field_name] = "missing"
# email validation
if data.get("email") and not tools.single_email_re.match(data.get("email")):
error["email"] = "error"
error_message.append(
_("Invalid Email! Please enter a valid email address.")
)
# vat validation
partner = request.env.user.partner_id
if data.get("vat") and partner and partner.vat != data.get("vat"):
# Check the VAT if it is the public user too.
if partner_creation or partner.can_edit_vat():
if hasattr(partner, "check_vat"):
if data.get("country_id"):
data["vat"] = request.env["res.partner"].fix_eu_vat_number(
int(data.get("country_id")), data.get("vat")
)
partner_dummy = partner.new(
{
"vat": data["vat"],
"country_id": (
int(data["country_id"])
if data.get("country_id")
else False
),
}
)
try:
partner_dummy.check_vat()
except ValidationError as e:
error["vat"] = "error"
error_message.append(e.args[0])
else:
error_message.append(
_(
"Changing VAT number is not allowed once document(s) have been "
"issued for your account. "
"Please contact us directly for this operation."
)
)
# error message for empty required fields
if [err for err in error.values() if err == "missing"]:
error_message.append(_("Some required fields are empty."))
# Compute list of thematics and domains expected in values
# (so that they are not considered unknown fields)
thematics = request.env["res.partner.theme"].sudo().search([])
domains = request.env["res.partner.domain"].sudo().search([])
theme_ids = [f"theme-{theme_id}" for theme_id in thematics.ids]
domain_ids = [f"domain-{domain_id}" for domain_id in domains.ids]
unknown = [
k
for k in data
if k
not in self.MANDATORY_CONTACT_FIELDS
+ self.OPTIONAL_CONTACT_FIELDS
+ theme_ids
+ domain_ids
]
if unknown:
error["common"] = "Unknown field"
error_message.append("Unknown field '%s'" % ",".join(unknown))
return error, error_message
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import event_old
from . import journalist_topic
from . import main_date
......
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models
......
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models
......
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models
......
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models
......
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
from odoo import fields, models
......
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
from random import randint
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter