Skip to content
Open
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9151557
[ADD] connector_extension: New Module
KNVx Mar 23, 2023
bd60b1c
[FIX] connector_extension: pre-commit, company name
eantones Apr 30, 2023
82afcce
[IMP] connector_extension: added generic get version on check connection
eantones May 1, 2023
e0d1b21
[FIX] connector_extension: id fields method returns the fields itself…
eantones May 15, 2023
498936b
[IMP] connector_extension: improvements
KNVx May 11, 2023
59dd9e2
[IMP] connector_extension: split into specific connectors
eantones Jun 20, 2023
d1de5ec
[ADD] connector_extension_sql: new module
eantones Jun 20, 2023
2aeca94
[ADD] connector_extension_mysql: new module
eantones Jun 20, 2023
7c54404
[ADD] connector_extension_mssql: new module
eantones Jun 20, 2023
6d464f0
[IMP] connector_extension: pre-commit stuff
eantones Jun 22, 2023
3a39b85
[FIX] connector_extension: sync_date parameter not found
eantones Jun 27, 2023
8894dc5
[FIX] connector_extension: unwrap_binding return a binding instead of…
KNVx Jun 26, 2023
c9e013d
[FIX] connector_extension: binding is nor returned on run when it's c…
KNVx Jul 6, 2023
7c898cb
[FIX] connector_extension: batch delayed disabled, enable again
eantones Jul 9, 2023
5a096fc
[FIX] connector_extension: names of components are wrong. delayed.chu…
KNVx Jul 10, 2023
28c884a
[IMP] connector_extension: added sync offset because sometimes in som…
eantones Jul 12, 2023
501292e
[IMP] connector_extension: removed useless code (__init__ _delay_impo…
KNVx Jul 19, 2023
846a7db
[IMP] connector_extension: Refactor get_external_dict_ids to remove f…
KNVx Jul 19, 2023
706b130
[FIX] connector_extension: filter by hash is mapping 'veloconnect_hash'
KNVx Jul 20, 2023
8f955b2
[IMP] connector_extension: Included page_size on backend
KNVx Jul 31, 2023
4817295
[IMP] connector_extension: included parameter unwrap in dict2id to re…
KNVx Jul 26, 2023
a06678f
[IMP] connector_extension: tools are included in common dir
KNVx Jul 20, 2023
19e8304
[IMP] connector_extension: Included trim_domain on tools. This functi…
KNVx Jul 24, 2023
4936151
[IMP] connector_extension: hooks created on importer on _create and _…
KNVx Aug 1, 2023
d268926
[IMP] connector_extension: pre-commit stuff
eantones Oct 2, 2023
cacc2f9
[IMP] connector_extension: Generic Batch Exporters created on exporter
KNVx Jul 19, 2023
e06f072
[IMP] connector_extension: adapter, backend, binding and mapper creat…
KNVx Aug 1, 2023
9ddea8c
[IMP] connector_extension: Created generic batch, chunk and record on…
KNVx Aug 1, 2023
39c03f7
[IMP] Connector_extension: Included hook on _lock to be inhereted
KNVx Aug 9, 2023
281f563
[IMP] Connector_extension: commit is done before binding creation
KNVx Aug 9, 2023
581c198
[IMP] connector_extension: License is updated to LPGL-3.0.
KNVx Oct 11, 2023
08ed1cd
[IMP] connector_extension: removed adapters woocommerce and wordpress…
KNVx Oct 16, 2023
b625028
[IMP] connector_extension: wrap_binding function on binder has been r…
KNVx Oct 16, 2023
c6f8eb4
[IMP] connector_extension: _usage in batch exporter and batch importe…
KNVx Oct 16, 2023
eb4e0ec
[IMP] connector_extension: run of exporter refactor. New decorator at…
KNVx Oct 16, 2023
ab5c842
[IMP] connector_extension: _description created on connector extensio…
KNVx Oct 19, 2023
22bc73c
[REF] connector_extension: Update copier template
eantones Oct 31, 2023
f0d59d8
[REF] connector_extension: pre-commit check
eantones Oct 31, 2023
7f113ea
[IMP] connector_extension: renamed binder exporter importer and mappe…
KNVx Oct 31, 2023
e994162
[IMP] connector_extension: refactored _get_external_record_alt and to…
KNVx Oct 24, 2023
f652568
[ADD] connector_extension: Commit in Importer to avoid listener/expor…
KNVx Oct 26, 2023
ab0c342
Revert "[IMP] connector_extension: run of exporter refactor. New deco…
KNVx Oct 30, 2023
097ab47
[IMP] connector_extension: refactored run and export dependencies
KNVx Oct 31, 2023
bc657ad
[FIX] connector_extension: id2dict returns an incorrect string when e…
KNVx Dec 19, 2023
527bd6c
[IMP]connector_extension: _convert_format is modified to don't restri…
KNVx Jan 4, 2024
4ba0f72
[IMP] connector_extension: binder is defined with self.binder_for
KNVx Jan 4, 2024
2b86b59
[IMP] connector_extension: use_data is a new parameter to use the ext…
KNVx Jan 4, 2024
7d022e6
[IMP] connector_extension: Import batch call run with the new paramet…
KNVx Jan 4, 2024
7722fe5
[IMP] connector_extension: binding included as a parameter in _after_…
KNVx Jan 23, 2024
190f5bb
[FIX] connector_extension: lock is done in all relations but it's no …
KNVx May 21, 2024
b6d3d2c
[FIX] connector_extension: wrap record throws an error because don't …
KNVx May 21, 2024
2d8831b
[IMP] connector_extension: hook to modify domain on wrap_record
KNVx Jul 12, 2024
fc9165b
[FIX] connector_extension: Incorrect error message without parameters…
KNVx Jul 17, 2024
7ea3659
[IMP] connector_extension: included function on tools to convert rgb …
KNVx Jul 30, 2024
015f78b
[IMP] connector_extension: removed _find_binding and improved wrap_re…
KNVx Jul 17, 2024
551188a
[IMP] connector_extension: included deleter and listener to delete ex…
KNVx Jul 31, 2024
2498d70
[IMP] connector_extension: improved resync to force to export all the…
KNVx Aug 8, 2024
7101e75
[IMP] connector_extension
deeniiz Jul 29, 2025
a5c7c4a
Revert "[IMP] connector_extension"
eantones Aug 11, 2025
30acfdf
[IMP] connector_extension
deeniiz Jul 29, 2025
935b35d
[IMP] connector_extension: update dotfiles
eantones Mar 18, 2026
50aa198
[IMP] connector_extension: add user_id field and work_on override
eantones Mar 26, 2026
adeca0d
[IMP] connector_extension: add server_tz and refactor TZ conversion
eantones Apr 1, 2026
56a2beb
[REF] connector_extension: added binder hook for binding export value…
eantones Nov 18, 2025
83cb756
[IMP+FIX+REF] connector_extension
eantones Dec 2, 2025
a6e0471
[IMP] connector_extension: added log call in backend
eantones Dec 24, 2025
a13da62
[IMP] connector_extension: pre-commit auto fixes
deeniiz Mar 31, 2026
088b2a3
[MIG] connector_extension: Migration to 18.0
deeniiz Mar 31, 2026
39cb1d1
Merge branch '18.0' into 18.0-fwp-connector_extension
deeniiz Apr 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 49 additions & 10 deletions connector_extension/models/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright 2025 NuoBiT Solutions SL - Deniz Gallo <dgallo@nuobit.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
import logging
from contextlib import contextmanager

import pytz

Expand Down Expand Up @@ -45,6 +46,13 @@ def _select_state(self):
default=lambda self: self.env.company,
string="Company",
)
user_id = fields.Many2one(
comodel_name="res.users",
string="User",
help="User used as the default responsible for records created by "
"this backend. If set, all operations (imports, exports, jobs) "
"will run under this user context.",
)

lang_ids = fields.Many2many(
comodel_name="res.lang",
Expand All @@ -70,7 +78,21 @@ def _select_state(self):
string="Timezone",
required=True,
default=lambda self: self._context.get("tz") or self.env.user.tz or "UTC",
help="This field is used to define in which timezone the backend will work.",
help="The timezone of the business data in the external system. "
"All imported datetime values are assumed to be in this timezone "
"and will be converted to UTC for storage in Odoo. "
"On export, Odoo UTC values are converted back to this timezone.",
)
server_tz = fields.Selection(
_tz_get,
string="Server Timezone",
required=True,
default=lambda self: self._context.get("tz") or self.env.user.tz or "UTC",
help="The timezone of the external system's server. "
"Used for technical timestamps managed by the server itself "
"(e.g. modification dates, audit trails) which may differ from "
"the business data timezone when the server is hosted in a "
"different region.",
)

chunk_size = fields.Integer(
Expand Down Expand Up @@ -113,18 +135,35 @@ def button_reset_to_draft(self):
self.ensure_one()
self.write({"state": "draft", "version": False})

@staticmethod
def _convert_tz(dt_naive, from_tz, to_tz):
dt = pytz.timezone(from_tz).localize(dt_naive)
dt = dt.astimezone(pytz.timezone(to_tz))
return dt.replace(tzinfo=None)

def tz_to_utc(self, datetime_local_naive):
datetime_local = pytz.timezone(self.tz).localize(datetime_local_naive)
datetime_utc = datetime_local.astimezone(pytz.utc)
datetime_utc_naive = datetime_utc.replace(tzinfo=None)
return datetime_utc_naive
return self._convert_tz(datetime_local_naive, self.tz, "UTC")

def utc_to_local(self, datetime_utc_naive):
return self._convert_tz(datetime_utc_naive, "UTC", self.tz)

# Deprecated: use utc_to_local instead
def tz_to_local(self, datetime_utc_naive):
local_tz = pytz.timezone(self.tz)
datetime_utc = pytz.utc.localize(datetime_utc_naive)
datetime_local = datetime_utc.astimezone(local_tz)
datetime_local_naive = datetime_local.replace(tzinfo=None)
return datetime_local_naive
return self.utc_to_local(datetime_utc_naive)

def server_tz_to_utc(self, datetime_server_naive):
return self._convert_tz(datetime_server_naive, self.server_tz, "UTC")

def utc_to_server_tz(self, datetime_utc_naive):
return self._convert_tz(datetime_utc_naive, "UTC", self.server_tz)

@contextmanager
def work_on(self, model_name, **kwargs):
backend = self
if self.user_id:
backend = self.with_user(self.user_id)
with super(ConnectorBackend, backend).work_on(model_name, **kwargs) as work:
yield work

# Scheduler methods
@api.model
Expand Down
Loading