Browse Source

[MIG] beesdoo_website_portal: adaptation to 12.0

pull/156/head
Vincent Van Rossem 5 years ago
parent
commit
a6bebc8cbd
  1. 8
      beesdoo_website_portal/__manifest__.py
  2. 35
      beesdoo_website_portal/controllers/main.py
  3. 21
      beesdoo_website_portal/views/portal_website_templates.xml

8
beesdoo_website_portal/__manifest__.py

@ -4,8 +4,8 @@
{
'name': 'BEES coop Website Portal',
'description': """
Extension of the Website Portal that prevent modification of sensible data by the users
'summary': """
Extension of the Portal that prevent modification of sensible data by the users
""",
'author': 'Coop IT Easy SCRLfs',
'license': 'AGPL-3',
@ -13,8 +13,8 @@
'website': "https://www.coopiteasy.be",
'category': 'Cooperative management',
'depends': [
'website',
'website_portal_extend',
'portal',
'website'
],
'data': [
'views/portal_website_templates.xml',

35
beesdoo_website_portal/controllers/main.py

@ -3,25 +3,32 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.addons.website_portal_extend.controllers.main import ExtendWebsiteAccountController
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal
class BeesdooAccountWebsiteController(ExtendWebsiteAccountController):
mandatory_billing_fields = [
"phone",
class BeesdooAccountWebsiteController(CustomerPortal):
# override from `portal` module
CustomerPortal.MANDATORY_BILLING_FIELDS = [
"city",
"country_id",
"phone",
"street",
"zipcode",
]
optional_billing_fields = [
"state_id",
]
CustomerPortal.OPTIONAL_BILLING_FIELDS = ["state_id"]
def details_form_validate(self, data):
error, error_message = super().details_form_validate(data)
# since we override mandatory and optional billing fields,
# parent method will insert the following key/value in `error` dict and `error_message` list,
# preventing from saving the form. Workaround is to clear both dict and list.
if (
error.get("common")
and error["common"] == "Unknown field"
and "Unknown field 'name,email,company_name,vat'" in error_message
):
error.pop("common")
error_message.remove("Unknown field 'name,email,company_name,vat'")
def _set_mandatory_fields(self, data):
"""This is not useful as the field 'company_name' is not present
anymore.
"""
pass
return error, error_message

21
beesdoo_website_portal/views/portal_website_templates.xml

@ -6,26 +6,29 @@
<odoo>
<!-- Modifying the form -->
<template
id="beesdoo_website_portal_details_form"
<template id="beesdoo_website_portal_details_form"
name="Beesdoo Website Portal Details Form"
inherit_id="website_portal_extend.website_portal_details_form">
inherit_id="portal.portal_my_details">
<xpath expr="//input[@name='name']/.." position="before">
<div class="col-md-12">
<div class="col-lg-12">
<div class="alert alert-info">
<strong>Info !</strong>
To modify information that is not present in this form,
To modify information that cannot be edited in this form,
please contact us.
</div>
</div>
</xpath>
<xpath expr="//input[@name='name']/.." position="replace">
<xpath expr="//input[@name='name']" position="attributes">
<attribute name="t-att-readonly">True</attribute>
</xpath>
<xpath expr="//input[@name='email']/.." position="replace">
<xpath expr="//input[@name='email']" position="attributes">
<attribute name="t-att-readonly">True</attribute>
</xpath>
<xpath expr="//input[@name='company_name']/.." position="replace">
<xpath expr="//input[@name='company_name']" position="attributes">
<attribute name="t-att-readonly">True</attribute>
</xpath>
<xpath expr="//input[@name='vat']/.." position="replace">
<xpath expr="//input[@name='vat']" position="attributes">
<attribute name="t-att-readonly">True</attribute>
</xpath>
</template>

Loading…
Cancel
Save