Skip to content

Commit

Permalink
[ADD] l10n_ar_edi_ux: mejora de rendimiento en actualizacion masiva d…
Browse files Browse the repository at this point in the history
…e partners

Task: 37730
  • Loading branch information
mem-adhoc committed May 6, 2024
1 parent 6214dec commit 97d1870
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 9 additions & 0 deletions l10n_ar_edi_ux/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
class ResPartner(models.Model):
_inherit = 'res.partner'


failed_to_update = fields.Boolean(
default=False,
string="Failed to update",
help="Este campo nos va a ayudar para saber que contactos fallaron al actualizar")

last_update = fields.Date(
help='Ultima fecha de actualizacion masiva')

def update_partner_data_from_afip(self):
""" Funcion que llama al wizard para actualizar data de partners desde afip sin abrir wizard.
Podríamos mejorar pasando un argumento para sobreescribir o no valores que esten o no definidos
Expand Down
15 changes: 12 additions & 3 deletions l10n_ar_edi_ux/wizards/res_partner_update_from_padron_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,14 @@ def _update(self):
def automatic_process_cb(self):
for partner in self.partner_ids:
self.partner_id = partner.id
self.change_partner()
self._update()
self.partner_id.last_update = fields.Date.context_today()
try:
self.change_partner()
self._update()
except:
self.partner_id.failed_to_update = True
continue

self.write({'state': 'finished'})
return {
'type': 'ir.actions.act_window',
Expand Down Expand Up @@ -218,7 +224,10 @@ def _next_screen(self):
self.write(values)
# because field is not changed, view is distroyed and reopen, on change
# is not called an we call it manually
self.change_partner()
try:
self.change_partner()
except:
raise UserError('No se pudo actualizar el contacto: %s. Por favor quitelo de la lista e intente de nuevo' % self.partner_ids[0].name )
return {
'type': 'ir.actions.act_window',
'res_model': self._name,
Expand Down

0 comments on commit 97d1870

Please sign in to comment.