Skip to Content
Menú
This question has been flagged
1 Respondre
5792 Vistes

Hello together,

how it is possible to change the required fields in checkout form in ecommerce. For example in the standard the phone number is a required field but ZIP code not. I want set phone as not required and ZIP code as required field in the checkout form.


Thanks in advanced

cakbulut

Avatar
Descartar
Autor

I am using odoo 13.

In the class /odoo/odoo-server/addons/website_sale/controllers/main.py I have found following lines:

def _get_mandatory_billing_fields(self): return ["name", "email", "street", "city", "country_id"]

def _get_mandatory_shipping_fields(self): return ["name", "street", "city", "country_id"]

What I do not understand is that phone is not in the mandatory list.

Autor

Even phone is not in the array it is mandatory. Why?

Hello Cetin,

It appears that the fields aren't being returned on that line of code it is the line before.

# Required fields from form

required_fields = [f for f in (all_form_values.get('field_required') or '').split(',') iff]

raise Warning(required_fields)

I raised a warning to see what is going on and this is what is returned:

Warning: ['phone', 'name']

It appears they are being sent as "required fields" as they come straight from the KW variable?

Autor

Hi Jack, 

million thanks for your advise. I have not seen the line in the QWeb. Now I changed the line as follows, so that zip is required, but phone not.

<input type="hidden" name="field_required" t-att-value="'zip,name'"/>

Thanks again. Have a good day.
Cetin
Best Answer

Those sneaky Odoo people!

There is a input field lower down in the QWeb form.

<input type="hidden" name="field_required" t-att-value="'phone,name'"/>
I assume if you remove phone from this you should be all good!

Thanks,

Avatar
Descartar
Autor

Hi Jack,

million thanks for your advise. I have not seen the line in the QWeb. Now I changed the line as follows, so that zip is required, but phone not.

<input type="hidden" name="field_required" t-att-value="'zip,name'"/>

Thanks again. Have a good day.

Cetin

1 Réponse