[REF] all: pass pre-commit on the whole repo
Needed for the lint job of the CI to go green. Mostly automatic hook fixes (black, isort, prettier, pyupgrade, autoflake, whitespace). By hand: - flake8: two unused imports, an ambiguous variable name `l`. - pylint-odoo mandatory: manifest keys equal to their default value (installable, application, data, external_dependencies). - end-of-file-fixer skips *.patch too, like trailing-whitespace: the upstream patches stay as git format-patch wrote them. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d9d9e8be2d
commit
fbd43bb459
45 changed files with 330 additions and 295 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import main
|
||||
from . import website_sale
|
||||
from . import website_sale
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, http
|
||||
from odoo.addons.auth_signup.controllers.main import AuthSignupHome
|
||||
from odoo.addons.web.controllers.home import SIGN_UP_REQUEST_PARAMS
|
||||
from odoo import _
|
||||
from odoo import http
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.http import request
|
||||
|
||||
from odoo.addons.auth_signup.controllers.main import AuthSignupHome
|
||||
from odoo.addons.web.controllers.home import SIGN_UP_REQUEST_PARAMS
|
||||
|
||||
# partner_firstname exposes `firstname` / `lastname` on res.users and
|
||||
# res.partner; we need them as accepted qcontext params so the signup form
|
||||
# roundtrips them transparently through `get_auth_signup_qcontext`.
|
||||
|
|
@ -18,7 +20,10 @@ SIGN_UP_REQUEST_PARAMS.add("lastname")
|
|||
SIGN_UP_REQUEST_PARAMS.add("accepted_terms")
|
||||
|
||||
# Session keys used by the membership signup flow.
|
||||
MEMBERSHIP_SIGNUP_SESSION_KEYS = ("membership_signup_active", "membership_signup_product_id")
|
||||
MEMBERSHIP_SIGNUP_SESSION_KEYS = (
|
||||
"membership_signup_active",
|
||||
"membership_signup_product_id",
|
||||
)
|
||||
|
||||
|
||||
class AuthSignupHomeMembership(AuthSignupHome):
|
||||
|
|
@ -71,9 +76,7 @@ class AuthSignupHomeMembership(AuthSignupHome):
|
|||
values["firstname"] = firstname
|
||||
values["lastname"] = lastname
|
||||
partner_model = request.env["res.partner"]
|
||||
values["name"] = partner_model._get_computed_name(
|
||||
lastname, firstname
|
||||
)
|
||||
values["name"] = partner_model._get_computed_name(lastname, firstname)
|
||||
return values
|
||||
|
||||
@http.route()
|
||||
|
|
@ -134,4 +137,4 @@ class AuthSignupHomeMembership(AuthSignupHome):
|
|||
# Drop the markers: the membership flow is now complete.
|
||||
for key in MEMBERSHIP_SIGNUP_SESSION_KEYS:
|
||||
request.session.pop(key, None)
|
||||
return request.redirect("/shop/cart")
|
||||
return request.redirect("/shop/cart")
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
from urllib.parse import urlencode
|
||||
|
||||
from odoo import http
|
||||
from odoo.addons.website_sale.controllers.main import WebsiteSale
|
||||
from odoo.http import request
|
||||
|
||||
from odoo.addons.website_sale.controllers.main import WebsiteSale
|
||||
|
||||
SIGNUP_FLAG = "membership_signup=1"
|
||||
|
||||
|
||||
|
|
@ -36,24 +37,37 @@ class WebsiteSaleMembershipSignup(WebsiteSale):
|
|||
|
||||
@http.route()
|
||||
def cart_update(
|
||||
self, product_id, add_qty=1, set_qty=0,
|
||||
self,
|
||||
product_id,
|
||||
add_qty=1,
|
||||
set_qty=0,
|
||||
product_custom_attribute_values=None,
|
||||
no_variant_attribute_value_ids=None, **kwargs
|
||||
no_variant_attribute_value_ids=None,
|
||||
**kwargs,
|
||||
):
|
||||
if self._membership_signup_is_required(product_id):
|
||||
self._membership_signup_mark_session(product_id)
|
||||
return request.redirect(self._membership_signup_redirect_url(product_id))
|
||||
return super().cart_update(
|
||||
product_id=product_id, add_qty=add_qty, set_qty=set_qty,
|
||||
product_id=product_id,
|
||||
add_qty=add_qty,
|
||||
set_qty=set_qty,
|
||||
product_custom_attribute_values=product_custom_attribute_values,
|
||||
no_variant_attribute_value_ids=no_variant_attribute_value_ids,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@http.route()
|
||||
def cart_update_json(
|
||||
self, product_id, line_id=None, add_qty=None, set_qty=None, display=True,
|
||||
product_custom_attribute_values=None, no_variant_attribute_value_ids=None, **kwargs
|
||||
self,
|
||||
product_id,
|
||||
line_id=None,
|
||||
add_qty=None,
|
||||
set_qty=None,
|
||||
display=True,
|
||||
product_custom_attribute_values=None,
|
||||
no_variant_attribute_value_ids=None,
|
||||
**kwargs,
|
||||
):
|
||||
if self._membership_signup_is_required(product_id):
|
||||
self._membership_signup_mark_session(product_id)
|
||||
|
|
@ -90,11 +104,14 @@ class WebsiteSaleMembershipSignup(WebsiteSale):
|
|||
"notification_info": {"lines": [], "warning": ""},
|
||||
}
|
||||
return super().cart_update_json(
|
||||
product_id=product_id, line_id=line_id, add_qty=add_qty,
|
||||
set_qty=set_qty, display=display,
|
||||
product_id=product_id,
|
||||
line_id=line_id,
|
||||
add_qty=add_qty,
|
||||
set_qty=set_qty,
|
||||
display=display,
|
||||
product_custom_attribute_values=product_custom_attribute_values,
|
||||
no_variant_attribute_value_ids=no_variant_attribute_value_ids,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def _get_mandatory_address_fields(self, country_sudo):
|
||||
|
|
@ -122,4 +139,4 @@ class WebsiteSaleMembershipSignup(WebsiteSale):
|
|||
# So even after we drop 'phone' from the address set above, the
|
||||
# portal set re-adds it for billing. We need to drop it here too.
|
||||
fields = list(super()._get_mandatory_fields())
|
||||
return [f for f in fields if f != "phone"]
|
||||
return [f for f in fields if f != "phone"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue