Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Change required field in Checkout form in ecommerce

形象
odoo
4 注释
形象
丢弃
形象
odoo
-

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.

形象
odoo
-

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

形象
odoo
-

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?

形象
odoo
-

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 答案
0
形象
odoo
最佳答案

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,

1 备注
形象
丢弃
形象
odoo
-

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