Skip to content

Commit

Permalink
Merge commit 'refs/pull/121443/head' of https://github.com/odoo/odoo
Browse files Browse the repository at this point in the history
…into 16.0-2542
  • Loading branch information
docker-odoo committed May 30, 2023
2 parents 9bf3336 + a919af0 commit 0afd49f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 8 additions & 4 deletions addons/l10n_ar_website_sale/controllers/main.py
Expand Up @@ -8,14 +8,16 @@ class L10nARWebsiteSale(WebsiteSale):

def _get_mandatory_fields_billing(self, country_id=False):
"""Extend mandatory fields to add new identification and responsibility fields when company is argentina"""
order = request.website.sale_get_order(force_create=True)
res = super()._get_mandatory_fields_billing(country_id)
if request.website.sudo().company_id.country_id.code == "AR":
if order.sudo().company_id.country_id.code == "AR":
res += ["l10n_latam_identification_type_id", "l10n_ar_afip_responsibility_type_id", "vat"]
return res

def _get_country_related_render_values(self, kw, render_values):
res = super()._get_country_related_render_values(kw, render_values)
if request.website.sudo().company_id.country_id.code == "AR":
order = request.website.sale_get_order(force_create=True)
if order.sudo().company_id.country_id.code == "AR":
res.update({'identification': kw.get('l10n_latam_identification_type_id'),
'responsibility': kw.get('l10n_ar_afip_responsibility_type_id'),
'responsibility_types': request.env['l10n_ar.afip.responsibility.type'].search([]),
Expand All @@ -25,7 +27,8 @@ def _get_country_related_render_values(self, kw, render_values):

def _get_vat_validation_fields(self, data):
res = super()._get_vat_validation_fields(data)
if request.website.sudo().company_id.country_id.code == "AR":
order = request.website.sale_get_order(force_create=True)
if order.sudo().company_id.country_id.code == "AR":
res.update({'l10n_latam_identification_type_id': int(data['l10n_latam_identification_type_id'])
if data.get('l10n_latam_identification_type_id') else False})
res.update({'name': data['name'] if data.get('name') else False})
Expand All @@ -39,7 +42,8 @@ def checkout_form_validate(self, mode, all_form_values, data):
error, error_message = super().checkout_form_validate(mode, all_form_values, data)

# Identification type and AFIP Responsibility Combination
if request.website.sudo().company_id.country_id.code == "AR":
order = request.website.sale_get_order(force_create=True)
if order.sudo().company_id.country_id.code == "AR":
if mode[1] == 'billing':
if error and any(field in error for field in ['l10n_latam_identification_type_id', 'l10n_ar_afip_responsibility_type_id']):
return error, error_message
Expand Down
6 changes: 3 additions & 3 deletions addons/l10n_ar_website_sale/views/templates.xml
Expand Up @@ -46,17 +46,17 @@
<template id="address" inherit_id="website_sale.address">
<xpath expr="//input[@name='vat']/.." position="before">
<t t-if="mode[1] == 'billing'" positon="inside">
<t t-if="res_company.country_id.code == 'AR'">
<t t-if="website_sale_order.company_id.country_id.code == 'AR'">
<t t-set="partner" t-value="website_sale_order.partner_id"/>
<t t-call="l10n_ar_website_sale.partner_info"/>
</t>
</t>
</xpath>
<label for="vat" position="attributes">
<attribute name="t-if">res_company.country_id.code != 'AR'</attribute>
<attribute name="t-if">website_sale_order.company_id.country_id.code != 'AR'</attribute>
</label>
<label for="vat" position="after">
<label t-if="res_company.country_id.code == 'AR'" class="col-form-label label-optional" for="vat">Number</label>
<label t-if="website_sale_order.company_id.country_id.code == 'AR'" class="col-form-label label-optional" for="vat">Number</label>
</label>
</template>

Expand Down
3 changes: 2 additions & 1 deletion doc/cla/corporate/adhoc.md
Expand Up @@ -21,4 +21,5 @@ Juan Ignacio Carreras jc@adhoc.com.ar https://github.com/jcadhoc
Joel Zilli joz@adhoc.com.ar https://github.com/JoelZilli
Augusto Weiss awe@adhoc.com.ar https://github.com/augusto-weiss
Pablo Montenegro pam@adhoc.com.ar https://github.com/pablohmontenegro
Ignacio Cainelli ica@adhoc.com.ar https://github.com/ica-adhoc
Ignacio Cainelli ica@adhoc.com.ar https://github.com/ica-adhoc
Martin Quinteros maq@adhoc.com.ar https://github.com/maq-adhoc

0 comments on commit 0afd49f

Please sign in to comment.