İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
5819 Görünümler

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
Vazgeç
Üretici

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.

Üretici

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?

Üretici

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
En İyi Yanıt

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
Vazgeç
Üretici

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