Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][14.0][ADD] connector_pms/connector_pms_wubook #1

Open
wants to merge 167 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
73df734
Update oca_dependencies.txt (queue and connector)
eantones Jan 20, 2021
b8751fa
[ADD] connector_pms: new module
eantones Oct 23, 2020
da9b544
[ADD] connector_pms_wubook: new module
eantones Jun 29, 2021
47b3c60
[FIX] connector_pms_wubook: required origin code on reservation
DarioLodeiros Jun 29, 2021
6b067fa
[IMP] connector_pms_wubook: enable queue batch import on folios and a…
eantones Jun 30, 2021
c8d4d0f
[IMP] connector_pms_wubook: parity pricelist unknown ID at first conf…
eantones Jun 30, 2021
d65dd62
[FIX] connector_pms_wubook: wrong backend attribute on room type
eantones Jun 30, 2021
3d2072f
[FIX] connector_pms_wubook: pricelist and availability plans not crea…
eantones Jun 30, 2021
db01f2b
[IMP] connector_pms_wubook: improve listeners
eantones Jun 30, 2021
ee8dafb
[REf] connector_pms_wubook: using dot notation
eantones Jun 30, 2021
ee13c22
[IMP] connector_pms: added support for datetime on format conversion
eantones Jul 12, 2021
a09d37a
[IMP] connector_pms_wubook: added more verbosity on Wubook request lo…
eantones Jul 12, 2021
ff4aae9
[IMP] connector_pms_wubook: added support for Wubbok restriction plan
eantones Jul 12, 2021
1df7545
[FIX] connector_pms_wubook: computed fields cannot be required
eantones Jul 12, 2021
b5b812a
[REF] connector_pms: simplify the call to binder_for
eantones Jul 12, 2021
bdc4a9c
[FIX] connector_pms: wrong queue function invocation and wrong record
eantones Jul 12, 2021
92aee89
[IMP] connector_pms_wubook: allow to filter by Availability Plan to i…
eantones Jul 12, 2021
b97fc63
[FIX] connector_pms: confusing exception message
eantones Jul 12, 2021
1694643
[REF] connector_pms: enable exports
eantones Jul 12, 2021
926051b
[REF] connector_pms_wubook: enable exports
eantones Jul 12, 2021
855fc70
[REF] connector_pms_wubook: restore the use of dot notation to access…
eantones Jul 12, 2021
944ac90
[IMP] connector_pms: move get_all_items to even higher on the class h…
eantones Jul 12, 2021
6a8e103
[IMP] connector_pms_wubook: make backend editable only on creation on…
eantones Jul 12, 2021
af450e9
[REF] connector_pms_wubook: remove old method to link parity pricelist
eantones Jul 12, 2021
eac3224
[FIX] connector_pms_wubook: use export_record instead of resync
eantones Jul 13, 2021
96cec49
[UPD] connector_pms_wubook: disable temporarily availability, plan, p…
eantones Jul 13, 2021
72be756
[REF] connector_pms_wubook: direct instead of mapping on availability…
eantones Jul 13, 2021
e4f84ad
[FIX] connector_pms: avoid triggering the export on forcing wrap record
eantones Jul 13, 2021
a1f3ab6
[IMP] connector_pms: added last sync date for export to allow differe…
eantones Jul 13, 2021
bc45bab
[IMP] connector_pms_wubook: added last sync date for export to allow …
eantones Jul 13, 2021
e8fe741
[IMP] connector_pms: added synced attribute on binding to know if the…
eantones Jul 13, 2021
37df182
[IMP] connector_pms_wubook: added synced attribute on binding views
eantones Jul 13, 2021
379d259
[IMP] connector_pms_wubook: added binder to Availability Plan Rule
eantones Jul 13, 2021
60e7273
[IMP] connector_pms: added child binder mapper and child_bind hook to…
eantones Jul 13, 2021
b9e03d2
[IMP] connector_pms_wubook: added child mapper binder
eantones Jul 13, 2021
bc0bd37
[IMP] connector_pms: added property availability base views
eantones Jul 13, 2021
39422ec
[IMP] connector_pms_wubook: added property availability
eantones Jul 13, 2021
8b7c068
[REF] connector_pms: child binding hook methods reorg
eantones Jul 14, 2021
148e867
[IMP] connector_pms: added a hook to make easier to change the synced…
eantones Jul 14, 2021
978cdf9
[IMP] connector_pms_wubook: no export not changed rules in Availabili…
eantones Jul 14, 2021
2d44dc3
[REF] connector_pms: remove old code
eantones Jul 14, 2021
954b8b8
[FIX] connector_pms: wrong error message on wrap_record
eantones Jul 14, 2021
cbcc5d5
[FIX] connector_pms_wubook: wrong sync detection when rules without b…
eantones Jul 14, 2021
34e7aed
[FIX] connector_pms_wubook: error on save Availability Plan with rule…
eantones Jul 14, 2021
25a9f2b
[IMP] connector_pms_wubook: separate different error messages
eantones Jul 14, 2021
01756f6
[FIX] connector_pms: missing import
eantones Jul 14, 2021
85d9126
[REF] connector_pms: unify class inherit attribute criteria
eantones Jul 14, 2021
a8e2190
[REF] connector_pms_wubook: unify attribute separation criteria
eantones Jul 14, 2021
494b394
[IMP] connector_pms: added child binder mapper
eantones Jul 14, 2021
44eaea5
[IMP] connector_pms_wubook: added child binder mapper
eantones Jul 14, 2021
00f6613
[FIX] connector_pms_wubook: error importing Availability Plan when th…
eantones Jul 14, 2021
815da6c
[FIX] connector_pms_wubook: duplicate import of Availability Plan whe…
eantones Jul 14, 2021
471103a
[IMP] connector_pms: added pricelist generic binding view
eantones Jul 14, 2021
3efaf82
[IMP] connector_pms_wubook: export only if pricelist changes
eantones Jul 14, 2021
7904aeb
[REF] connector_pms_wubook: remove old code
eantones Jul 14, 2021
6961308
[IMP] connector_pms_wubook: added cron and scheduler methods
eantones Jul 14, 2021
9ab68fa
[FIX] connector_pms_wubook: error exporting records older than 2 days…
eantones Jul 15, 2021
02bc721
[IMP] connector_pms_wubook: added more cases to control Wubook error …
eantones Jul 15, 2021
ada53a7
[FIX] connector_pms_wubook: no Pricelist or Availability Plan exporte…
eantones Jul 15, 2021
6a7c6e3
[FIX] connector_pms_wubook: virtual Pricelist error skiping items bec…
eantones Jul 15, 2021
800f997
[FIX] connector_pms_wubook: wrong rule conflict count between rules o…
eantones Jul 20, 2021
042a7a8
[IMP] connector_pms_wubook: cron every less than a minute for availab…
eantones Jul 25, 2021
d9b5a2c
[FIX] connector_wubook: exports not launched by cron
eantones Sep 22, 2021
53db4ca
[IMP] connector_pms: added message to skipping records
eantones Sep 22, 2021
c6a2410
[REF] connector_pms_wubook: use new room_type_id of product
eantones Sep 22, 2021
64e791a
[FIX] connector_pms_wubook: export error when both price and discount…
eantones Sep 22, 2021
8494a48
[FIX] connector_pms_wubook: make sure only daily pricelists are exported
eantones Sep 22, 2021
298eebb
[IMP] connector_pms_wubook: exclude room classes to export
eantones Sep 22, 2021
d1fe7cb
[FIX] connector_pms_wubook: get room classes from the adapter without…
eantones Sep 22, 2021
df73e53
[IMP] connector_pms_wubook: added availability on import restrictions
eantones Sep 23, 2021
8e1dec5
[FIX] connector_pms_wubook: records wrongly skipped on export
eantones Sep 23, 2021
ef580c2
[IMP] connector_pms: not detecting empty result on dictionaries with …
eantones Sep 23, 2021
fbc7a7a
[IMP] connector_pms: unify nothing to export message
eantones Sep 23, 2021
ae2393a
[FIX] connector_pms_wubook: pricelists and availability plans exporte…
eantones Sep 23, 2021
267972c
[FIX] connector_pms_wubook: remove daily check on export
eantones Sep 25, 2021
a14bf14
[FIX] connector_pms_wubook: error on compute write date in virtual pr…
eantones Sep 25, 2021
a7d8a69
[IMP] connector_pms_wubook: only export room types, pricelists and av…
eantones Sep 25, 2021
73cfb20
[IMP]connector_pms_wubook: cron data noupdate 1
DarioLodeiros Sep 28, 2021
30f4909
[FIX] connector_pms_wubook: permission denied to availability plan ru…
eantones Sep 29, 2021
aa78911
[FIX] connector_pms_wubook: no channel ID on error message
eantones Oct 24, 2021
6f778ff
[FIX] connector_pms_wubook: board service not imported on booking res…
eantones Oct 24, 2021
8862f69
[FIX] connector_pms_wubook: ancillary data not imported on fetching r…
eantones Oct 24, 2021
808d501
[REF] connector_pms_wubook: comment test output
eantones Oct 28, 2021
a101d0e
[IMP] connector_pms: allow to disable export
DarioLodeiros Sep 26, 2021
04ee1d9
[FIX] connector_pms_wubook: segregate board service price from the ro…
eantones Oct 28, 2021
9b75fda
[FIX] connector_pms_wubook: occupancy not imported
eantones Nov 8, 2021
17b61d1
[FIX] connector_pms_wubook: error getting room type when importing folio
eantones Nov 10, 2021
04d8131
[FIX] connector_pms_wubook: wrong board service price on Wubook reser…
eantones Dec 7, 2021
ce4a777
[REF+FIX] connector_pms: wrong view name
eantones Dec 7, 2021
d462aa5
[FIX] connector_pms_wubook: wrong OTA reservation field
eantones Dec 7, 2021
eb0667e
[IMP] connector_pms: register and limit backend calls
eantones Dec 15, 2021
05865ee
[IMP] connector_pms_wubook: register and limit backend calls
eantones Dec 15, 2021
1698d0a
[FIX] connector_pms_wubook: availability singleton error
eantones Dec 16, 2021
2cacf3a
[IMP] connector_pms: allow to have models without binding
eantones Dec 16, 2021
18b7826
[IMP] connector_pms_wubook: do not export dependencies
eantones Dec 16, 2021
6af9d14
[IMP] connector_pms: use seconds in interval instead of minutes
eantones Dec 16, 2021
7d6d585
[IMP] connector_pms_wubook: use seconds in interval instead of minutes
eantones Dec 16, 2021
11b9be8
[REF] connector_pms: rename method field names
eantones Dec 16, 2021
affc88a
[REF] connector_pms_wubook: rename method field names
eantones Dec 16, 2021
e0a5fc8
[IMP]pms_connector: generic board interpretation import
DarioLodeiros Jan 8, 2022
d7a8354
[ADD]connector_pms_wubook: payment from OTAs&Wubook
DarioLodeiros Oct 12, 2021
d301df7
[WIP]connector_pms_wubook: avoid continuous resync by rename plan and…
DarioLodeiros Jan 12, 2022
ccf568a
[IMP]conector_pms_wubook: default occupancie base in room capacity
DarioLodeiros Apr 12, 2022
8e473fc
[IMP]connector_pms: link between external_code and ota reservation code
DarioLodeiros Apr 15, 2022
d9e3612
[IMP]connector_pms_wubook: OTA payments date = checkout
DarioLodeiros Apr 15, 2022
e83adcb
[IMP]connector_pms_wubook: update ota payments consistence
DarioLodeiros Apr 15, 2022
8e7da2d
[IMP]connector_pms_wubook: Tax included adapter
DarioLodeiros Apr 16, 2022
09f36ae
[IMP]connector_pms_wubook: avoid jobs in export disabled channels
DarioLodeiros May 10, 2022
209dba2
[FIX]14.0-connector_pms: force update avail on wubook cancel folio
DarioLodeiros Jun 2, 2022
c5f4274
[FIX]14.0-connector_pms: update wubook folios by origin code
DarioLodeiros Jun 2, 2022
f133302
[WIP]connector_pms: avoid sync pricelist item without date start cons…
DarioLodeiros Jun 8, 2022
63fd5f7
[IMP]connector_pms: Improvement payment journal not configured
DarioLodeiros Jun 27, 2022
aa9b949
[IMP]connector_pms: add management import payment with invoice_to_age…
DarioLodeiros Jun 27, 2022
2eb8b60
[FIX]connector_pms: payments update on folio modifications wubook
DarioLodeiros Jul 5, 2022
ab9b8c4
[IMP] Multiorigin Folioç
DarioLodeiros Sep 18, 2022
49ecab3
[IMP]connector_pms: force set sale channel origin id
DarioLodeiros Sep 28, 2022
eee10a0
[FIX]:14.0-connector_pms: fix parent_id backend model channel backend…
DarioLodeiros Oct 11, 2022
2a508a1
[ADD]connector_pms: OTA payments with today date
DarioLodeiros Nov 19, 2022
6cf74e4
[ADD]connector_pms: pricelist pms enabled configuration
DarioLodeiros Nov 20, 2022
669dc0e
[IMP]connecto_pms_wubook: unique board_service_room_type by property
DarioLodeiros Dec 7, 2022
eaa3307
[FIX]connector_pms_wubook: filter board by pms property
DarioLodeiros Dec 7, 2022
a4ffcc8
[IMP]connector_pms_wubook: avoid cron in not daily pricelists
DarioLodeiros Dec 8, 2022
2bd01ef
[WIP]connector_pms_wubook: refact export cron
DarioLodeiros Jan 12, 2022
77f1605
[WIP]connector_pms_wubook: review mapper
DarioLodeiros Jan 12, 2022
d5145cd
[IMP]connector_pms_wubook: improvmente scheduler export performance
DarioLodeiros Dec 18, 2022
c6e5330
[IMP]connector_pms_wubook: add priority job 1 to import folios
DarioLodeiros Dec 14, 2022
5c95134
[TMP]connector_pms_wubook: Temporal solution to create exponential jo…
DarioLodeiros Dec 14, 2022
b4f37af
[FIX]connector_pms_wubook: pricelist items actual_wrte_date set
DarioLodeiros Dec 19, 2022
fcb84a9
[IMP]connector_pms: Force Wubook Avail update on Import folios
DarioLodeiros Dec 20, 2022
3e7e392
[FIX]connector_pms_wubook: condition import ota payments
DarioLodeiros Dec 21, 2022
022daab
[IMP]connector_pms: add pms_property to queue jobs
DarioLodeiros Dec 24, 2022
8b3da15
[TMP]connector_pms_wubook: avoid compute total rooms
DarioLodeiros Dec 25, 2022
260022d
[IMP]connector_pms: sync boards services control
DarioLodeiros Jan 29, 2023
026598a
[IMP]connector_pms: improvement import folio updates
DarioLodeiros Jan 30, 2023
03e1788
[IMP]connector_pms_wubook: avoid create repeat jobs in avail updates
DarioLodeiros Feb 4, 2023
df5d81b
[IMP]connector_pms_wubook: change date format 24:00
DarioLodeiros Feb 4, 2023
6b503a9
[IMP]connector_pms_wubook: change default max price to 2000
DarioLodeiros Feb 4, 2023
9fbec18
[IMP]connector_pms_wubook: board service skip if binding dont exist
DarioLodeiros Feb 4, 2023
f1e6277
[IMP]connector_pms_wubook: adaptation to import airbnb reservations
DarioLodeiros Feb 5, 2023
ae494af
[FIX]connector_pms_wubook: board service property matching
DarioLodeiros Feb 9, 2023
16c96b5
[IMP]connector_pms: force write blocked reservations in importer foli…
DarioLodeiros Mar 21, 2023
4a85125
[IMP]pms_connector: mapper room type get capacity
DarioLodeiros Mar 21, 2023
8848c9e
[ADD]connector_pms_wubook: Add default boardservice feature
DarioLodeiros Apr 19, 2023
bf5a1c5
[IMP]connecto_pms_wubook: force write avail rules in the same channel
DarioLodeiros Jun 11, 2023
1212035
[IMP]pms_connector_wubook: add search folio&reservation by external_id
DarioLodeiros Jul 11, 2023
d318048
[IMP]pms_connector_wubook: Fix search avail job in queued
DarioLodeiros Sep 12, 2023
e603ab5
[IMP]pms_connector_wubook: Booking.com Payment BankTransfer
DarioLodeiros Oct 9, 2023
4635e22
[FIX]pms_coonector_wubook: return payment_dateway_fee
DarioLodeiros Oct 11, 2023
615174b
[FIX]pms_connector_wubook: pms_property_id parameter in get_room_type…
DarioLodeiros Oct 12, 2023
bdf61d6
[IMP]connecto_pms_wubook: set default pricelist if rate_id = -1
DarioLodeiros Oct 16, 2023
c3716bd
[IMP]connector_pms_wubook: cancel draft invoices linked to wubook can…
DarioLodeiros Oct 16, 2023
bf845f7
[FIX]pms_connector_wubook: fix name_search in folio and reservation m…
DarioLodeiros Oct 18, 2023
c60744b
[FIX]connector_pms_wubook: domain _name_search folio&reservation
DarioLodeiros Oct 23, 2023
c68322c
[IMP]connector_pms_wubook: unlink draft invoices linked to wubook can…
DarioLodeiros Oct 24, 2023
789142f
[IMP]connector_pms_wubook: disabled temporally tax_included param in …
DarioLodeiros Feb 24, 2024
c7375c6
[IMP]connector_pms_wubook: export disabled channel improvements
DarioLodeiros Mar 14, 2024
cd6a7f5
[IMP]connector_pms_wubook: mapped children wuboo, improvement occupan…
DarioLodeiros Mar 14, 2024
bed6c4e
[IMP]connector_pms_wubook: folio message_post with sudo
DarioLodeiros Mar 16, 2024
fcb73c5
[FIX]connector_pms_wubook: call get_room_type_capacity with ...pms_pr…
DarioLodeiros Apr 16, 2024
8096ea1
[REF] connector_pms_wubook: pre-commit error
FrankC013 May 8, 2024
ced15f9
[REF] connector_pms: pre-commit error
FrankC013 May 8, 2024
54acc85
[ADD]connector_pms_wubook: take account commission type in OTAs reser…
DarioLodeiros Jun 24, 2024
fc9b6c7
[FIX]connector_pms_wubook: fix children key in mapped reservation lines
DarioLodeiros Jul 25, 2024
ee39137
[IMP]connector_pms_wubook: add editable bottom in room type binding tree
DarioLodeiros Oct 22, 2024
a3bcb6b
[FIX]connector_pms_wubook: temporal fix component issues with listene…
DarioLodeiros Oct 22, 2024
8e2bac8
[FIX]connector_pms_wubook: reservation_line mapper_import record.get(…
DarioLodeiros Oct 23, 2024
306aa2b
[IMP]connector_pms: Blocked False in Website Engine reservations
DarioLodeiros Nov 12, 2024
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
91 changes: 91 additions & 0 deletions connector_pms/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
=============
PMS Connector
=============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6c6f3e6839947ed86924adc3667235de9205ec86e0ee48df315f979d5a392cbd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github
:target: https://github.com/OCA/pms/tree/14.0/connector_pms
:alt: OCA/pms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pms-14-0/pms-14-0-connector_pms
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pms&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Base module for implement channel connectors

Features:

* Avaliability Management
* Odoo Connector

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Usage
=====

No configuration required. This is a 'tool' module, need be used with other modules.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pms/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pms/issues/new?body=module:%20connector_pms%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Eric Antones <eantones@nuobit.com>

Contributors
~~~~~~~~~~~~

* Eric Antones <eantones@nuobit.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/pms <https://github.com/OCA/pms/tree/14.0/connector_pms>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
6 changes: 6 additions & 0 deletions connector_pms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import components_custom
from . import components
from . import models
37 changes: 37 additions & 0 deletions connector_pms/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "PMS Connector",
"summary": "Channel PMS connector Base",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"development_status": "Alpha",
"category": "Connector",
"website": "https://github.com/OCA/pms",
"author": "Eric Antones <eantones@nuobit.com>,Odoo Community Association (OCA)",
"depends": [
"connector",
"pms",
],
"data": [
"data/queue_data.xml",
"security/ir.model.access.csv",
"views/channel_menus.xml",
"views/channel_backend_views.xml",
"views/channel_backend_type_views.xml",
"views/channel_backend_log_views.xml",
"views/channel_backend_method_views.xml",
"views/pms_property_views.xml",
"views/pms_room_type_views.xml",
"views/pms_room_type_class_views.xml",
"views/pms_board_service_views.xml",
"views/pms_folio_views.xml",
"views/pms_reservation_views.xml",
"views/product_pricelist_views.xml",
"views/product_pricelist_item_views.xml",
"views/pms_availability_plan_views.xml",
"views/pms_availability_plan_rule_views.xml",
"views/queue_job_views.xml",
],
}
11 changes: 11 additions & 0 deletions connector_pms/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import core
from . import adapter
from . import binder
from . import deleter
from . import exporter
from . import importer
from . import mapper_export
from . import mapper_import
111 changes: 111 additions & 0 deletions connector_pms/components/adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import datetime

from odoo import _
from odoo.exceptions import ValidationError

from odoo.addons.component.core import AbstractComponent


class ChannelAdapter(AbstractComponent):
_name = "channel.adapter"
_inherit = "base.backend.adapter.crud"

def chunks(self, lst, n):
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i : i + n]

def _filter(self, values, domain=None):
# TODO support for domains with 'or' clauses
# TODO refactor and optimize
if not domain:
return values

operations = {
"=": lambda x, y: x != y,
"!=": lambda x, y: x == y,
">": lambda x, y: x <= y,
"<": lambda x, y: x >= y,
">=": lambda x, y: x < y,
"<=": lambda x, y: x > y,
}

values_filtered = []
for record in values:
for elem in domain:
k, op, v = elem
if k not in record:
raise ValidationError(_("Key %s does not exist") % k)
if operations[op](record[k], v):
break
elif op == "in":
if not isinstance(v, (tuple, list)):
raise ValidationError(
_("The value %s should be a list or tuple") % v
)
if record[k] not in v:
break
elif op == "not in":
if not isinstance(v, (tuple, list)):
raise ValidationError(
_("The value %s should be a list or tuple") % v
)
if record[k] in v:
break
else:
break
raise NotImplementedError("Operator '%s' not supported" % op)
else:
values_filtered.append(record)

return values_filtered

def _extract_domain_clauses(self, domain, fields):
if not isinstance(fields, (tuple, list)):
fields = [fields]
extracted, rest = [], []
for clause in domain:
tgt = extracted if clause[0] in fields else rest
tgt.append(clause)
return extracted, rest

def _convert_format(self, elem, mapper, path=""):
if isinstance(elem, dict):
for k, v in elem.items():
current_path = "{}/{}".format(path, k)
if v == "":
elem[k] = None
continue
if isinstance(v, (tuple, list, dict)):
if isinstance(v, dict):
if current_path in mapper:
v2 = {}
for k1, v1 in v.items():
new_value = mapper[current_path](k1)
v2[new_value] = v1
v = elem[k] = v2
self._convert_format(v, mapper, current_path)
elif isinstance(
v, (str, int, float, bool, datetime.date, datetime.datetime)
):
if current_path in mapper:
elem[k] = mapper[current_path](v)
else:
raise NotImplementedError("Type %s not implemented" % type(v))
elif isinstance(elem, (tuple, list)):
for ch in elem:
self._convert_format(ch, mapper, path)
elif isinstance(
elem, (str, int, float, bool, datetime.date, datetime.datetime)
):
pass
else:
raise NotImplementedError("Type %s not implemented" % type(elem))


class ChannelAdapterError(Exception):
def __init__(self, message, data=None):
super().__init__(message)
self.data = data or {}
8 changes: 8 additions & 0 deletions connector_pms/components/binder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.addons.component.core import AbstractComponent


class ChannelBinder(AbstractComponent):
_name = "channel.binder"
_inherit = "base.binder.custom"
11 changes: 11 additions & 0 deletions connector_pms/components/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import AbstractComponent


class BaseChannelConnector(AbstractComponent):
_name = "base.channel.connector"
_inherit = "base.connector"

_description = "Base Channel Connector Component"
9 changes: 9 additions & 0 deletions connector_pms/components/deleter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import AbstractComponent


class ChannelDeleter(AbstractComponent):
_name = "channel.deleter"
_inherit = ["base.deleter"]
69 changes: 69 additions & 0 deletions connector_pms/components/exporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2021 Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo.addons.component.core import AbstractComponent

_logger = logging.getLogger(__name__)


class ChannelExporter(AbstractComponent):
"""Base exporter for Channel"""

_name = "channel.exporter"
_inherit = "generic.exporter.custom"

_usage = "direct.record.exporter"


class ChannelBatchExporter(AbstractComponent):
"""The role of a BatchExporter is to search for a list of
items to import, then it can either import them directly or delay
the import of each item separately.
"""

_name = "channel.batch.exporter"
_inherit = "base.exporter"

def run(self, domain=None):
"""Run the batch synchronization"""
if not domain:
domain = []
relation_model = self.binder_for().unwrap_model()
for relation in self.env[relation_model].search(domain):
self._export_record(relation)

def _export_record(self, external_id):
"""Export a record directly or delay the export of the record.

Method to implement in sub-classes.
"""
raise NotImplementedError


class ChannelDirectBatchExporter(AbstractComponent):
"""Import the records directly, without delaying the jobs."""

_name = "channel.direct.batch.exporter"
_inherit = "channel.batch.exporter"

_usage = "direct.batch.exporter"

def _export_record(self, relation):
"""export the record directly"""
self.model.export_record(self.backend_record, relation)


class ChannelDelayedBatchExporter(AbstractComponent):
"""Delay import of the records"""

_name = "channel.delayed.batch.exporter"
_inherit = "channel.batch.exporter"

_usage = "delayed.batch.exporter"

def _export_record(self, relation, job_options=None):
"""Delay the export of the records"""
delayable = self.model.with_delay(**job_options or {})
delayable.export_record(self.backend_record, relation)
Loading
Loading