Skip to content

Commit

Permalink
[ADD] integrator: self to locals dict
Browse files Browse the repository at this point in the history
  • Loading branch information
augusto-weiss committed Jan 10, 2025
1 parent c2ff313 commit aa21b40
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions integrator/models/integrator_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,10 @@ def get_external_id(model_name, rec_id):
# Generate XML ids for M2O Fields
for m2o_field in m2o_fields or []:
if item[m2o_field]:
rec_id = item[m2o_field].id
rec_id = item[m2o_field][0]
# esta operacion no tiene ejecuta ninguna ninguna llamada rpc, lo resuelve localmente odooly
rel_model_name = item[m2o_field]._model._name
# rel_model_name = item[m2o_field]._model._name
rel_model_name = self.env['ir.model.fields'].search([('name', '=', m2o_field), ('model', '=', model_name)], limit=1).relation
item[m2o_field] = get_external_id(rel_model_name, rec_id)
else:
item[m2o_field] = False
Expand All @@ -382,7 +383,8 @@ def get_external_id(model_name, rec_id):
for m2m_field in m2m_fields or []:
if item[m2m_field]:
rec_ids = item[m2m_field]
rel_model_name = item[m2m_field]._model._name
# rel_model_name = item[m2m_field]._model._name
rel_model_name = self.env['ir.model.fields'].search([('name', '=', m2m_field), ('model', '=', model_name)], limit=1).relation
item[m2m_field] = ','.join([get_external_id(rel_model_name, rec_id) for rec_id in rec_ids.ids])
else:
item[m2m_field] = False
Expand Down Expand Up @@ -444,6 +446,7 @@ def get_external_id(model_name, rec_id):
# The following libraries and variables
# will be available for any job.
locals_dict = {
"self": self,
"db2": self.odoo_db2._odoo_get_client(),
"last_cron_execution": self.last_cron_execution,
"last_sync_start": self.last_sync_start,
Expand Down

0 comments on commit aa21b40

Please sign in to comment.