Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6219 Lượt xem

Hi, I want to create a custom module and I need to remove the mandatory fields on the checkout address page. I just want to use [name, email]. How can I remove the mandatory ["street", "city", "country_id"]?


def _get_mandatory_fields_billing(self, country_id=False):
req = ["name", "email", "street", "city", "country_id"]
if country_id:
country = request.env['res.country'].browse(country_id)
if country.state_required:
req += ['state_id']
if country.zip_required:
req += ['zip']
return req

def _get_mandatory_fields_shipping(self, country_id=False):
req = ["name", "street", "city", "country_id"]
if country_id:
country = request.env['res.country'].browse(country_id)
if country.state_required:
req += ['state_id']
if country.zip_required:
req += ['zip']
return req
Ảnh đại diện
Huỷ bỏ
Tác giả

It worked! Thank you so much :D

Câu trả lời hay nhất

You can override both methods in website_sale controller as below:

from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteSale(WebsiteSale):

def _get_mandatory_fields_billing(self, country_id=False):
req = ["name", "email"]
return req

def _get_mandatory_fields_shipping(self, country_id=False):
req = ["name", "email"]
return req


Ảnh đại diện
Huỷ bỏ

This does not seem to work on Odoo 16. Although it does add additional required fields to the lists, it doesn't seem to over write it

[checkout_form_validate](https://github.com/odoo/odoo/blob/16.0/addons/website_sale/controllers/main.py#L974) seems to add additional ones, but it still seems that the previously required fields, like phone number, are still in the array.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 25
1122
1
thg 8 24
2119
4
thg 1 25
2497
2
thg 10 24
1543
0
thg 6 24
1316