Merge pull request #226 from odoo-dev/master-website_sale-add-vat-chm
[IMP] website_sale: add vat field on checkout + validate it if base_vat module is installed
This commit is contained in:
commit
d42840a6f8
|
@ -310,7 +310,7 @@ class website_sale(http.Controller):
|
|||
return values
|
||||
|
||||
mandatory_billing_fields = ["name", "phone", "email", "street", "city", "country_id", "zip"]
|
||||
optional_billing_fields = ["street2", "state_id"]
|
||||
optional_billing_fields = ["street2", "state_id", "vat"]
|
||||
mandatory_shipping_fields = ["name", "phone", "street", "city", "country_id", "zip"]
|
||||
optional_shipping_fields = ["state_id"]
|
||||
|
||||
|
@ -355,6 +355,17 @@ class website_sale(http.Controller):
|
|||
if not data.get(field_name):
|
||||
error[field_name] = 'missing'
|
||||
|
||||
if data.get("vat") and hasattr(registry["res.partner"], "check_vat"):
|
||||
if request.website.company_id.vat_check_vies:
|
||||
# force full VIES online check
|
||||
check_func = registry["res.partner"].vies_vat_check
|
||||
else:
|
||||
# quick and partial off-line checksum validation
|
||||
check_func = registry["res.partner"].simple_vat_check
|
||||
vat_country, vat_number = registry["res.partner"]._split_vat(data.get("vat"))
|
||||
if not check_func(cr, uid, vat_country, vat_number, context=None): # simple_vat_check
|
||||
error["vat"] = 'error'
|
||||
|
||||
if data.get("shipping_different"):
|
||||
for field_name in self.mandatory_shipping_fields:
|
||||
field_name = 'shipping_' + field_name
|
||||
|
|
|
@ -704,6 +704,11 @@
|
|||
<label class="control-label" for="street2" style="font-weight: normal">Company Name</label>
|
||||
<input type="text" name="street2" class="form-control" t-att-value="checkout.get('street2')"/>
|
||||
</div>
|
||||
<div class="col-lg-6"> </div>
|
||||
<div t-attf-class="form-group #{error.get('vat') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label" for="vat" style="font-weight: normal">VAT Number</label>
|
||||
<input type="text" name="vat" class="form-control" t-att-value="checkout.get('vat')"/>
|
||||
</div>
|
||||
<div t-attf-class="form-group #{error.get('email') and 'has-error' or ''} col-lg-6">
|
||||
<label class="control-label" for="contact_name">Email</label>
|
||||
<input type="email" name="email" class="form-control" t-att-value="checkout.get('email')"/>
|
||||
|
|
Loading…
Reference in New Issue