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 7, 2024
1 parent 6214dec commit 6205981
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion l10n_ar_edi_ux/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'name': 'Argentinian Electronic Invoicing UX',
'version': "16.0.1.7.0",
'version': "16.0.1.8.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA',
Expand Down
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
13 changes: 13 additions & 0 deletions l10n_ar_edi_ux/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,17 @@
</field>
</record>

<record id="res_partner_view_search" model="ir.ui.view">
<field name="name">res.partner.search.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/>
<field name="arch" type="xml">
<xpath expr="//filter[@name='l10n_ar_afip_responsibility_type_id_filter']" position="after">
<group expand="0" string="Extended Filters">
<filter string="Failed to Update" name="failed_to_update" domain="[('failed_to_update', '=', True), ('country_code', '=', 'AR')]"/>
</group>
</xpath>
<separator/>
</field>
</record>
</odoo>
20 changes: 17 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,15 @@ 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(self.partner_id)
try:
self.change_partner()
self._update()
self.partner_id.failed_to_update = False
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 +225,14 @@ 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()

self.partner_id.last_update = fields.Date.context_today(self.partner_id)
try:
self.change_partner()
self.partner_id.failed_to_update = False
except:
self.partner_id.failed_to_update = True
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 6205981

Please sign in to comment.