[FIX] website_portal: fix key error on edit form
Fix 'Key error' dues to prematured access {key: post[key] for key in optional...
Replace street2 by company name
This commit is contained in:
@@ -11,8 +11,8 @@ from odoo.fields import Date
|
||||
|
||||
class website_account(http.Controller):
|
||||
|
||||
MANDATORY_BILLING_FIELDS = ["name", "phone", "email", "street2", "city", "country_id"]
|
||||
OPTIONAL_BILLING_FIELDS = ["zipcode", "state_id", "vat", "street"]
|
||||
MANDATORY_BILLING_FIELDS = ["name", "phone", "email", "street", "city", "country_id"]
|
||||
OPTIONAL_BILLING_FIELDS = ["zipcode", "state_id", "vat", "company_name"]
|
||||
|
||||
_items_per_page = 20
|
||||
|
||||
@@ -57,7 +57,7 @@ class website_account(http.Controller):
|
||||
|
||||
@http.route(['/my/account'], type='http', auth='user', website=True)
|
||||
def details(self, redirect=None, **post):
|
||||
partner = request.env['res.users'].browse(request.uid).partner_id
|
||||
partner = request.env.user.partner_id
|
||||
values = {
|
||||
'error': {},
|
||||
'error_message': []
|
||||
@@ -68,7 +68,8 @@ class website_account(http.Controller):
|
||||
values.update({'error': error, 'error_message': error_message})
|
||||
values.update(post)
|
||||
if not error:
|
||||
values = {key: post[key] for key in self.MANDATORY_BILLING_FIELDS + self.OPTIONAL_BILLING_FIELDS}
|
||||
values = {key: post[key] for key in self.MANDATORY_BILLING_FIELDS}
|
||||
values.update({key: post[key] for key in self.OPTIONAL_BILLING_FIELDS if key in post})
|
||||
values.update({'zip': values.pop('zipcode', '')})
|
||||
partner.sudo().write(values)
|
||||
if redirect:
|
||||
|
||||
@@ -132,9 +132,9 @@
|
||||
</div>
|
||||
|
||||
<div class="clearfix" />
|
||||
<div t-attf-class="form-group #{error.get('street') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label label-optional" for="street">Company Name</label>
|
||||
<input type="text" name="street" class="form-control" t-att-value="street or partner.street"/>
|
||||
<div t-attf-class="form-group #{error.get('company_name') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label label-optional" for="company_name">Company Name</label>
|
||||
<input type="text" name="company_name" class="form-control" t-att-value="company_name or partner.company_name"/>
|
||||
</div>
|
||||
<div t-if="has_check_vat" t-attf-class="form-group #{error.get('vat') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label label-optional" for="vat">VAT Number</label>
|
||||
@@ -143,8 +143,8 @@
|
||||
|
||||
<div class="clearfix" />
|
||||
<div t-attf-class="form-group #{error.get('street') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label" for="street">Street</label>
|
||||
<input type="text" name="street2" class="form-control" t-att-value="street2 or partner.street2" />
|
||||
<label class="control-label label-optional" for="street">Street</label>
|
||||
<input type="text" name="street" class="form-control" t-att-value="street or partner.street"/>
|
||||
</div>
|
||||
<div t-attf-class="form-group #{error.get('city') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label" for="city">City</label>
|
||||
|
||||
Reference in New Issue
Block a user