diff --git a/l10n_ar_ux/__manifest__.py b/l10n_ar_ux/__manifest__.py
index 8711eb7b4..fcc569e49 100644
--- a/l10n_ar_ux/__manifest__.py
+++ b/l10n_ar_ux/__manifest__.py
@@ -1,6 +1,6 @@
{
'name': 'Argentinian Accounting UX',
- 'version': "16.0.1.11.0",
+ 'version': "16.0.1.12.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA',
diff --git a/l10n_ar_ux/controllers/portal.py b/l10n_ar_ux/controllers/portal.py
index 1a0038bfd..704b7d900 100644
--- a/l10n_ar_ux/controllers/portal.py
+++ b/l10n_ar_ux/controllers/portal.py
@@ -32,15 +32,34 @@ def details_form_validate(self, data):
error_message.extend(write_message)
return error, error_message
+ def values_preprocess_ar(self, values):
+ new_values = dict()
+ partner_fields = request.env['res.partner']._fields
+ ar_camp = ['vat', 'l10n_ar_afip_responsibility_type_id', 'l10n_latam_identification_type_id', 'commercial_partner_id']
+
+ for k, v in values.items():
+ # Convert the values for many2one fields to integer since they are used as IDs
+ if k in partner_fields and k in ar_camp and partner_fields[k].type == 'many2one':
+ new_values[k] = bool(v) and int(v)
+ # Store empty fields as `False` instead of empty strings `''` for consistency with other applications like
+ # Contacts.
+ elif v == '':
+ new_values[k] = False
+ else:
+ new_values[k] = v
+
+ return new_values
+
@route()
def account(self, redirect=None, **post):
- if post:
+
+ #Procesamos los datos del post para asignar correctamente los valores de los campos many2one
+ if post and request.httprequest.method == 'POST':
+ post = self.values_preprocess_ar(post)
+
+ #Solamente queremos chequear los datos cuando vamos a editarlos y posteamos
+ if post and request.httprequest.method != 'POST':
error, _error_message = self.details_form_validate(post)
- if not error:
- post.pop('commercial_partner_id', False)
- post.pop('vat', False)
- post.pop('l10n_latam_identification_type_id', False)
- post.pop('l10n_ar_afip_responsibility_type_id', False)
response = super().account(redirect=redirect, **post)
identification_types = request.env['l10n_latam.identification.type'].sudo().search([])
@@ -49,7 +68,11 @@ def account(self, redirect=None, **post):
partner = request.env['res.users'].browse(uid).partner_id if uid else request.env['res.partner']
partner = partner.with_context(show_address=1).sudo()
response.qcontext.update({
+ 'afip_respo_type': post.get('l10n_ar_afip_responsibility_type_id') or partner.l10n_ar_afip_responsibility_type_id.id,
+ 'latam_ident_type': post.get('l10n_latam_identification_type_id') or partner.l10n_latam_identification_type_id.id,
'identification_types': identification_types,
'afip_responsibilities': afip_responsibilities,
- 'partner': partner})
+ 'partner': partner,
+ 'partner_can_edit_vat': partner.can_edit_vat()})
+
return response
diff --git a/l10n_ar_ux/models/res_partner.py b/l10n_ar_ux/models/res_partner.py
index 27912a930..8d486e436 100644
--- a/l10n_ar_ux/models/res_partner.py
+++ b/l10n_ar_ux/models/res_partner.py
@@ -65,13 +65,13 @@ def try_write_commercial(self, data):
l10n_ar_afip_responsibility_type_id = data.get('l10n_ar_afip_responsibility_type_id', False)
if vat and l10n_latam_identification_type_id:
- commercial_partner = self.env['res.partner'].sudo().browse(int(data.get('commercial_partner_id')))
+ commercial_partner = self.env['res.partner'].sudo().browse(data.get('commercial_partner_id'))
try:
values = {
'vat': vat,
- 'l10n_latam_identification_type_id': int(l10n_latam_identification_type_id),
+ 'l10n_latam_identification_type_id': l10n_latam_identification_type_id,
'l10n_ar_afip_responsibility_type_id':
- int(l10n_ar_afip_responsibility_type_id) if l10n_ar_afip_responsibility_type_id else False}
+ l10n_ar_afip_responsibility_type_id if l10n_ar_afip_responsibility_type_id else False}
commercial_fields = ['vat', 'l10n_latam_identification_type_id', 'l10n_ar_afip_responsibility_type_id']
values = commercial_partner.remove_readonly_required_fields(commercial_fields, values)
with self.env.cr.savepoint():
diff --git a/l10n_ar_ux/views/portal_templates.xml b/l10n_ar_ux/views/portal_templates.xml
index b9c52b57a..d091bc90e 100644
--- a/l10n_ar_ux/views/portal_templates.xml
+++ b/l10n_ar_ux/views/portal_templates.xml
@@ -19,7 +19,7 @@
-
+
@@ -27,7 +27,7 @@