diff --git a/l10n_ar_ux/__manifest__.py b/l10n_ar_ux/__manifest__.py index dba9da2a3..c751a40ab 100644 --- a/l10n_ar_ux/__manifest__.py +++ b/l10n_ar_ux/__manifest__.py @@ -1,6 +1,6 @@ { 'name': 'Argentinian Accounting UX', - 'version': "17.0.1.3.0", + 'version': "17.0.1.4.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 1f725b4b8..d3974c942 100644 --- a/l10n_ar_ux/controllers/portal.py +++ b/l10n_ar_ux/controllers/portal.py @@ -32,6 +32,19 @@ def details_form_validate(self, data): error_message.extend(write_message) return error, error_message + def values_preprocess_ar(self, values): + """ We preprocess the ar-post data to ensure the correct assignment of many2one fields.""" + new_values = dict() + partner_fields = request.env['res.partner']._fields + ar_camp = ['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) or False + + return new_values + @route() def account(self, redirect=None, **post): partner = request.env.user.partner_id @@ -39,11 +52,8 @@ def account(self, redirect=None, **post): if not partner.can_edit_vat(): post['country_id'] = str(partner.country_id.id) 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) + #Procesamos los datos del post para asignar correctamente los valores de los campos many2one + post.update(self.values_preprocess_ar(post)) response = super().account(redirect=redirect, **post) identification_types = request.env['l10n_latam.identification.type'].sudo().search([]) @@ -52,7 +62,10 @@ 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/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 @@ +

- +

@@ -53,7 +53,7 @@