From afb92403dad5eff6319bfa6b7c15623c5f53bc90 Mon Sep 17 00:00:00 2001 From: Pablo Quesada Barriuso Date: Wed, 3 Oct 2018 19:43:42 +0200 Subject: [PATCH] [WIP] Using with_context for synchronizing --- hotel_node_master/models/hotel_node.py | 8 +++----- hotel_node_master/models/hotel_node_user.py | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hotel_node_master/models/hotel_node.py b/hotel_node_master/models/hotel_node.py index dfeaa0fad..c059c4ae0 100644 --- a/hotel_node_master/models/hotel_node.py +++ b/hotel_node_master/models/hotel_node.py @@ -155,7 +155,6 @@ class HotelNode(models.Model): 'email': user['email'], 'active': user['active'], 'remote_user_id': user['id'], - 'is_synchronizing': True, })) else: user_ids.append((0, 0, { @@ -164,13 +163,12 @@ class HotelNode(models.Model): 'email': user['email'], 'active': user['active'], 'remote_user_id': user['id'], - 'is_synchronizing': True, })) vals.update({'user_ids': user_ids}) - wdb.set_trace() - - self.write(vals) + self.with_context({ + 'is_synchronizing': True, + }).write(vals) except (odoorpc.error.RPCError, odoorpc.error.InternalError, urllib.error.URLError) as err: diff --git a/hotel_node_master/models/hotel_node_user.py b/hotel_node_master/models/hotel_node_user.py index d78a76a0e..bd513c7d5 100644 --- a/hotel_node_master/models/hotel_node_user.py +++ b/hotel_node_master/models/hotel_node_user.py @@ -85,7 +85,7 @@ class HotelNodeUser(models.Model): raise ValidationError(msg) try: - if 'is_synchronizing' in vals: + if 'is_synchronizing' not in self._context: partner = self.env["res.partner"].search([('email', '=', vals['login'])]) if partner.id: vals['partner_id'] = partner.id @@ -148,9 +148,9 @@ class HotelNodeUser(models.Model): _("Odoo version in node: %s") % node.odoo_version _logger.error(msg) raise ValidationError(msg) - + try: - if 'is_synchronizing' not in vals: + if 'is_synchronizing' not in self._context: noderpc = odoorpc.ODOO(node.odoo_host, node.odoo_protocol, node.odoo_port) noderpc.login(node.odoo_db, node.odoo_user, node.odoo_password)