Browse Source

Merge pull request #114 into 12.0

pull/137/head 12.0-2020-11-15.00
Rémy Taymans 3 years ago
parent
commit
0a862bc6ee
  1. 3
      .flake8
  2. 5
      easy_my_coop/models/coop.py
  3. 22
      easy_my_coop_website/controllers/main.py
  4. 64
      easy_my_coop_website/views/subscription_template.xml

3
.flake8

@ -7,4 +7,5 @@ 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
# C901: Function is too complex
ignore = E203,E501,W503,C901

5
easy_my_coop/models/coop.py

@ -10,12 +10,14 @@ from addons.base_iban.models.res_partner_bank import validate_iban
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
# This structure is only used in easy_my_coop_webstite's controller
_REQUIRED = [
"email",
"firstname",
"lastname",
"birthdate",
"address",
"street_name",
"house_number",
"share_product_id",
"ordered_parts",
"zip_code",
@ -36,6 +38,7 @@ class SubscriptionRequest(models.Model):
_name = "subscription.request"
_description = "Subscription Request"
# This function is only used in easy_my_coop_webstite's controller
def get_required_field(self):
required_fields = _REQUIRED
company = self.env["res.company"]._company_default_get()

22
easy_my_coop_website/controllers/main.py

@ -8,6 +8,10 @@ from odoo.tools.translate import _
# Only use for behavior, don't stock it
_TECHNICAL = ["view_from", "view_callback"]
# transient fields used to compute the address field
_EXTRA_FIELDS = ["street_name", "house_number"]
# Allow in description
_BLACKLIST = [
"id",
@ -27,7 +31,8 @@ _COOP_FORM_FIELD = [
"birthdate",
"iban",
"share_product_id",
"address",
"street_name",
"house_number",
"city",
"zip_code",
"country_id",
@ -50,7 +55,8 @@ _COMPANY_FORM_FIELD = [
"birthdate",
"iban",
"share_product_id",
"address",
"street_name",
"house_number",
"city",
"zip_code",
"country_id",
@ -324,6 +330,9 @@ class WebsiteSubscription(http.Controller):
)
return request.render(redirect, values)
# There's no issue with the email, so we can remember the confirmation email
values["confirm_email"] = email
company = request.website.company_id
if company.allow_id_card_upload:
if not post_file:
@ -412,6 +421,8 @@ class WebsiteSubscription(http.Controller):
and field_name not in _BLACKLIST
):
values[field_name] = field_value
elif field_name in _EXTRA_FIELDS and field_name not in _BLACKLIST:
values[field_name] = field_value
# allow to add some free fields or blacklisted field like ID
elif field_name not in _TECHNICAL:
post_description.append(
@ -458,6 +469,13 @@ class WebsiteSubscription(http.Controller):
values["share_product_id"] = self.get_selected_share(kwargs).id
values["address"] = "{street}, {number}".format(
street=kwargs.get("street_name", ""),
number=kwargs.get("house_number", ""),
)
del values["street_name"]
del values["house_number"]
if is_company:
if kwargs.get("company_register_number", is_company):
values["company_register_number"] = re.sub(

64
easy_my_coop_website/views/subscription_template.xml

@ -256,18 +256,34 @@
style="margin-left:25%;margin-top:35px;width:59%"></div>
</div>
<div t-attf-class="form-group #{error and 'address' in error and 'has-error' or ''}">
<div t-attf-class="form-group #{error and 'house_number' in error and 'has-error' or ''}">
<label class="col-md-3 col-sm-4 control-label"
for="address">Address
for="house_number">Address
</label>
<div class="col-md-7 col-sm-8">
<input type="text"
class="form-control mandatory-field"
name="address"
required="True"
t-att-readonly="logged"
t-attf-value="#{address or ''}"
placeholder="rue Van Hove, 19"/>
<table>
<tr>
<td width="15%">
<input type="text"
class="form-control mandatory-field"
name="house_number"
required="True"
t-att-readonly="logged"
t-attf-value="#{house_number or ''}"
placeholder="19"/>
</td>
<td width="3%"></td>
<td>
<input type="text"
class="form-control mandatory-field"
name="street_name"
required="True"
t-att-readonly="logged"
t-attf-value="#{street_name or ''}"
placeholder="rue Van Hove"/>
</td>
</tr>
</table>
</div>
</div>
@ -675,13 +691,29 @@
for="address">Address
</label>
<div class="col-md-7 col-sm-8">
<input type="text"
class="form-control mandatory-field"
name="address"
required="True"
t-att-readonly="logged"
t-attf-value="#{address or ''}"
placeholder="rue Van Hove, 19"/>
<table>
<tr>
<td width="15%">
<input type="text"
class="form-control mandatory-field"
name="house_number"
required="True"
t-att-readonly="logged"
t-attf-value="#{street_number or ''}"
placeholder="19"/>
</td>
<td width="3%"></td>
<td>
<input type="text"
class="form-control mandatory-field"
name="street_name"
required="True"
t-att-readonly="logged"
t-attf-value="#{street_name or ''}"
placeholder="rue Van Hove"/>
</td>
</tr>
</table>
</div>
</div>

Loading…
Cancel
Save