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

[14.0][ADD] connector woocommerce - connector wordpress - with WPML #431

Open
wants to merge 180 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
180 commits
Select commit Hold shift + click to select a range
ab2b5f1
[ADD] connector_extension_wordpress: new module
eantones Jun 20, 2023
ea0d5d5
[ADD] connector_extension_woocommerce: new module
eantones Jun 20, 2023
a10c8c3
[ADD] connector_woocommerce: New Module
KNVx May 10, 2023
e9c3cb2
[ADD] connector_wordpress: New Module
KNVx May 17, 2023
f32e2bf
[IMP] Connector_wordpress: removed binding from parameters in _has_to…
KNVx Sep 28, 2023
1087751
[IMP] connector_wordpress: now binding inherit from connector_extensi…
KNVx Oct 9, 2023
272012e
[IMP] connector_wordpress: _get_lock_name refactored in wordpress to …
KNVx Oct 16, 2023
434ec48
[ADD] website_sale_variant_info: New Module
KNVx Sep 14, 2023
b071129
[ADD] Connector_woocommerce_ast: New module
KNVx Sep 15, 2023
c241d12
[IMP] Connector_woocommerce_ast: listener to update carrier_id and ca…
KNVx Sep 26, 2023
91e6764
[IMP] Connector_woocommerce_ast: New states Delivered on Sale_order. …
KNVx Sep 27, 2023
57d3de1
[IMP] connector_woocommerce_ast: partial-shipped renamed to partial_s…
KNVx Sep 28, 2023
7908e3a
[IMP] Connector_woocommerce_ast: api removed from imports in stock_pi…
KNVx Oct 4, 2023
4a35df2
[ADD] connector_woocommerce_apg_nif: New module
KNVx Sep 20, 2023
3141231
[IMP] Connector_woocommerce: Created variant filter view
KNVx Sep 22, 2023
1e73fc6
[IMP] Connector_woocommerce: variant_is_published on product_product …
KNVx Sep 22, 2023
721b474
[IMP] Connector_woocommerce: required default_code in product export_…
KNVx Sep 22, 2023
1e21e23
[IMP] Connector_woocommerce: template_is_published replaced for butto…
KNVx Sep 22, 2023
28b1242
[IMP] Connector_woocommerce: Included has_attributes field in product…
KNVx Sep 26, 2023
52dce34
[IMP] Connector_woocommerce: Separation between simple/variant produc…
KNVx Sep 26, 2023
bb63724
[IMP] Connector_woocommerce: hook on listener to add more fields to u…
KNVx Sep 26, 2023
07f34d2
[IMP] Connector_woocommerce: Improved string of woocommerce_fields in…
KNVx Sep 26, 2023
44df6cf
[IMP] Connector_woocommerce: language on backend is a M2o. export map…
KNVx Sep 26, 2023
9af9e8d
[IMP] Connector_woocommerce: included active_test in binding fields t…
KNVx Sep 26, 2023
00966ae
[IMP] connector_woocommerce: included compute in variant_is_published…
KNVx Sep 27, 2023
c4a6d69
[IMP] Connector_woocommerce: product_type in prod_tmpl export mapper …
KNVx Sep 27, 2023
b64e726
[IMP] Connector_woocommerce: woocommerce_order_state refactored.
KNVx Sep 27, 2023
62db620
[IMP] Connector_woocommerce: included ensure_one() and removed api.mo…
KNVx Sep 28, 2023
66ea662
[IMP] connector_woocommerce: alternative_product_ids and accessory_pr…
KNVx Oct 4, 2023
6c5b0f1
[IMP] Connector_woocommerce: Improved ValidationError message when pr…
KNVx Oct 5, 2023
6adaf76
[IMP] Connector_woocommerce: improved ValidationError message for int…
KNVx Oct 5, 2023
88dada2
[IMP] connector_woocommerce: Inventory availability included to expor…
KNVx Oct 9, 2023
7b73dc3
[FIX] connector_woocommerce: Compute woocommerce stock picking state …
KNVx Oct 9, 2023
0bee4cd
[IMP] connector_woocommerce: renamed _get_filters_values function. No…
KNVx Oct 9, 2023
68567da
[IMP] connector_woocommerce: WooCommerce changes category names when …
KNVx Oct 9, 2023
bef487d
[IMP] connector_woocommerce: Just validated backends are used on resync
KNVx Oct 9, 2023
bb2b4d9
[IMP] connector_woocommerce: woocommerce_bind_ids is included on depe…
KNVx Oct 9, 2023
9d9d1cf
[IMP] connector_woocommerce: Stock status is instock when manage stoc…
KNVx Oct 10, 2023
8b03e5e
[IMP] connector_woocommerce: Export dependencies in prod_template and…
KNVx Oct 16, 2023
3d5a539
[IMP] connector_woocommerce: component exporter inherit from generic.…
KNVx Oct 16, 2023
06ffc24
[IMP] connector_woocommerce: new field woocommerce_enabled to export …
KNVx Oct 16, 2023
27c19de
[ADD] website_sale_product_document: New Module
KNVx Oct 23, 2023
5c25fcc
[IMP] connector_woocommerce: Common product class to be inhereted in …
KNVx Oct 23, 2023
4864f6c
[IMP] connector_wordpress: Renamed product_mixin and product,Read and…
KNVx Oct 23, 2023
b4a4976
[IMP] connector_extension_wordpress: refactored exec_wp_call, get_tot…
KNVx Oct 24, 2023
6bbaca1
[IMP] connector_extension_woocommerce: refactored exec_wcapi_call and…
KNVx Oct 24, 2023
c4ce7c5
[ADD] connector_woocommerce_alias_url_stream: New Module
KNVx Oct 26, 2023
1d7c13e
[ADD] Connector_extension_wordpress: Clean code
KNVx Oct 26, 2023
d4da016
[ADD] Connector_woocommerce: minor refactor changes
KNVx Oct 26, 2023
8b04d80
[IMP] website_sale_product_document: minor refactor
KNVx Oct 26, 2023
73d7e13
[IMP] connector_wordpress: Unlink binding of existing attachments
KNVx Oct 27, 2023
35051c1
[IMP] connector_woocommerce: improved prepare document description
KNVx Oct 27, 2023
84db0f3
[IMP] connector_woocommerce: commented listener
KNVx Oct 27, 2023
34d6c44
[IMP] connector_woocommerce_ast: commented listener
KNVx Oct 27, 2023
1999690
[IMP] connector_woocommerce: sale_orders with binding can't be import…
KNVx Oct 30, 2023
03f35b5
[IMP] connector_woocommerce: short description on mapper return None …
KNVx Oct 30, 2023
3022d64
Revert "[IMP] connector_woocommerce_ast: commented listener"
KNVx Oct 31, 2023
1ded0e1
[IMP] connector_woocommerce: listener re-activated
KNVx Oct 31, 2023
a651341
[IMP] connector_woocommerce: updated binders exporters and importers …
KNVx Oct 31, 2023
9758859
[IMP] connector_wordpress: updated binders and exporters component de…
KNVx Oct 31, 2023
9aa6ef5
[IMP] connector_wocommerce: deprecated tree string removed
KNVx Nov 2, 2023
04b6a48
[IMP] connector_extension_woocommerce: pre-commit readme updates
KNVx Nov 2, 2023
39ae82f
[IMP] connector_extension_wordpress: pre-commit readme updates
KNVx Nov 2, 2023
7266013
[IMP] connector_wordpress: Included verify_ssl
eantones Jun 20, 2023
7e4b21a
[IMP] connector_woocommerce: Included verify_ssl
KNVx Dec 18, 2023
b34f865
[IMP] connector_extension_wordpress: Included verify on requests
KNVx Dec 18, 2023
c3886c5
[FIX] connector_extension_woocommerce: raise ValidationError without …
KNVx Dec 19, 2023
bd448be
[FIX] connector_wordpress: Alternative bind don't use backend
KNVx Dec 19, 2023
1a2a6ec
[FIX] connector_woocommerce: Accessory products with parents without …
KNVx Dec 20, 2023
6d4204c
[FIX] connector_woocommerce_alias_url_strem: names are exported incor…
KNVx Jun 14, 2024
7f0221e
[FIX] connector_woocommerce: Products export all variants or tmpl fro…
KNVx Jun 14, 2024
4cb3f36
[IMP] connector_woocommerce: include res partner binding page
KNVx Jun 15, 2024
9ee9a4d
[IMP] connector_wordpress: Included wordpress attachment binding page
KNVx Jun 17, 2024
d80646d
[IMP] connector_wocommerce: included hook for mapping meta_data
KNVx Jun 17, 2024
be8966c
[IMP] connector_woocommerce_ast: meta data is generated on adapter
KNVx Jun 17, 2024
f3a5fc7
[IMP] connector_wordpress: included export mapper odoo tools mimetypes
KNVx Jun 18, 2024
714f6c1
[IMP] requirements.txt
KNVx Jun 18, 2024
8cbb69f
[ADD] connector_woocommerce_wpml: New module
KNVx Jul 9, 2024
a92a4e7
[IMP] connector_woocommerce: changes to make module more extensible
KNVx Jul 12, 2024
896fd49
[IMP] connector_wordpress: included parameter on _additional_external…
KNVx Jul 17, 2024
cb44e13
[IMP] connector_woocommerce: included and improved read on products
KNVx Jul 19, 2024
5d58cf9
[IMP] connector_extension_woocommerce: function to manage errors
KNVx Jul 17, 2024
ac86793
[IMP] connector_extension_woocommerce: included error codes to manage…
KNVx Jul 19, 2024
6c7c0ea
[IMP] connector_extension_woocommerce: included hook on search_read t…
KNVx Jul 19, 2024
14fe1a4
[IMP] connector_woocommerce_wpml: improved code before massive export
KNVx Jul 19, 2024
73bc1b5
[IMP] connector_woocommerce
KNVx Jul 22, 2024
a908410
[IMP] connector_woocommerce_wpml: slug product export_mapper and impr…
KNVx Jul 29, 2024
f249ec6
[IMP] connector_woocommerce: custom slug on product_template
KNVx Jul 29, 2024
91fbfed
[IMP] connector_woocommerce: included website_name on product templat…
KNVx Jul 30, 2024
87932c5
[IMP] connector_woocommerce_wpml: modified mapper to convert rgb to hex
KNVx Jul 30, 2024
747fb49
[IMP] connector_woocommerce: included html widget on product_product …
KNVx Jul 30, 2024
f51d69e
[IMP] connector_extension_woocommerce - defined _exec_delete
KNVx Jul 31, 2024
f12ba6d
[IMP] connector_woocommerce: included deleter on public category to d…
KNVx Jul 31, 2024
d4e5e3d
[REF] connector_woocommerce: Replaced http for https in licence url
KNVx Jul 31, 2024
66ab77c
[REF] connector_extension_woocommerce - Replaced http for https in li…
KNVx Jul 31, 2024
2745211
[IMP] connector_woocommerce_wpml: aditional_external_binding_fields w…
KNVx Jul 31, 2024
0a592d0
[IMP] connector_woocommerce: removed notify from product_public_categ…
KNVx Jul 31, 2024
e0d4f46
[IMP] connector_extension_woocommerce: improved manage_errors code
KNVx Aug 5, 2024
ae730fb
[IMP] connector_extension_wordpress: included manage_errors code
KNVx Aug 5, 2024
fa39925
[IMP] connector_woocommerce: included public_short_description to export
KNVx Aug 5, 2024
de5bbfc
[FIX] connector_wordpress: additional_external_binding_fields has ext…
KNVx Aug 5, 2024
3c75756
[IMP] connector_woocommerce_wpml: included public short description
KNVx Aug 5, 2024
c8c9869
[IMP] connector_woocommerce: included option to use or not main image…
KNVx Aug 5, 2024
d8eef97
[IMP] connector_woocommerce: improved code to use product_image_attac…
KNVx Aug 6, 2024
308a2aa
[FIX] connector_woocommerce: when we delete images on odoo, images st…
KNVx Aug 7, 2024
1a89fce
[IMP] connector_woocommerce_ast: included manage errors to detect con…
KNVx Aug 8, 2024
c032734
[ADD] connector_wordpress_wpml: new module
KNVx Aug 8, 2024
28bd4f3
[IMP] connector_wordpress: included seo data, write on adapter and ot…
KNVx Aug 8, 2024
40639c2
[IMP] connector_woocommerce_wpml: removed unwrap_binding, modified ma…
KNVx Aug 8, 2024
818938a
[IMP] connector_woocommerce: refactor views, deleted code, modified r…
KNVx Aug 8, 2024
7a5a1a5
[IMP] connector_extension_wordpress: improved post to include params …
KNVx Aug 8, 2024
70378c2
[IMP] connector_woocommerce: included pricelist on backend to upload …
KNVx Aug 8, 2024
d91146e
[IMP] connector_woocommerce: return sale_price None when is not set. …
KNVx Aug 8, 2024
f4f3006
[FIX] connector_woocommerce_wpml: char fields has ondelete
KNVx Aug 8, 2024
02770cd
[FIX] connector_wordpress_wpml: code is used instead of iso_code
KNVx Aug 9, 2024
10fa6c7
[FIX] connector_wordpress: title and alternate_text can't be translated
KNVx Aug 9, 2024
c49885e
[FIX] connector_woocommerce_wpml: iso code is used instead code
KNVx Aug 9, 2024
846ba36
[IMP] connector_woocommerce: included translations in spanish and cat…
KNVx Aug 9, 2024
734d1a4
[IMP] connector_woocommerce: included information message to product …
KNVx Aug 9, 2024
325caec
[IMP] connector_woocommerce: use_main_product_image has now params to…
KNVx Aug 9, 2024
ac64fab
[IMP] connector_woocommerce: move common fields to upper modules
KNVx Aug 9, 2024
f5cd06d
[ADD] website_sale_extra_fields: new module
KNVx Aug 9, 2024
76049ba
[IMP] website_sale_product_document: included documents on variant page
KNVx Aug 9, 2024
a986f17
[ADD] website_sale_stock_variant: new module
KNVx Aug 9, 2024
d38efb6
[ADD] website_sale_variant: new module
KNVx Aug 9, 2024
93d69d8
[FIX] connector_woocommerce: wrong translations
KNVx Aug 9, 2024
4dce410
[FIX] connector_woocommerce: conflict using "_" as a dummy variable a…
eantones Aug 13, 2024
a79a986
[FIX] website_sale_extra_fields: security csv not included in manifest
eantones Aug 13, 2024
cb3ce7b
[IMP] connector_woocommerce: included woocommerce warning message and…
KNVx Sep 2, 2024
29dfe29
[IMP] website_sale_extra_fields: group user can create the transient …
KNVx Sep 2, 2024
4fcb49b
[IMP] website_sale_extra_fields: modified fields for variant image at…
KNVx Sep 3, 2024
1511c6c
[IMP] connector_woocommerce: modified fields for variant image attach…
KNVx Sep 3, 2024
b7ba878
[FIX] connector_wordpress: alternate text is not being exported
KNVx Sep 3, 2024
958901a
[IMP] website_sale_extra_fields: Included description in product_publ…
KNVx Sep 3, 2024
09b48c5
[IMP] connector_woocommerce: included description in product public c…
KNVx Sep 3, 2024
8a64e97
[IMP] connector_woocommerce_wpml: included description in product pub…
KNVx Sep 3, 2024
6ed8205
[FIX] connector_woocommerce_wpml: lang is modified when lang is alrea…
KNVx Sep 3, 2024
12c46fb
[FIX] connector_woocommerce: modified rebinding by sku on product_tem…
KNVx Sep 4, 2024
8a7b8cb
[IMP] connector_woocommerce_wpml: removed comments
KNVx Sep 4, 2024
9768494
[FIX] connector_woocommerce_wpml: res modification on search read is …
KNVx Sep 4, 2024
b2bd0d4
[FIX] connector_woocommerce_wpml: Pre filter lang to resync (See TODO)
KNVx Sep 4, 2024
cf8dbe6
[IMP] website_sale_extra_fields: Included slug name and view modified…
KNVx Sep 5, 2024
024ef38
[IMP] connector_woocommerce_wpml: included slug name on export mapper…
KNVx Sep 5, 2024
c574596
[IMP] connector_woocommerce: included slug name on export mapper for …
KNVx Sep 5, 2024
0c73f31
[IMP] connector_woocommerce: modified public category view to include…
KNVx Sep 5, 2024
6199208
[IMP] connector_woocommerce_wpml: commented code in resync export. it…
KNVx Sep 5, 2024
00538e8
[IMP] connector_woocommerce_wpml: commented code in _prepare_relation…
KNVx Sep 5, 2024
1347ef2
[IMP] connector_woocommerce: removed resync export from product_produ…
KNVx Sep 5, 2024
0a5340e
[IMP] connector_woocommerce: resync export modified by changes on con…
KNVx Sep 5, 2024
98c72c8
[IMP] connector_woocommerce: created button to export attachments of …
KNVx Sep 5, 2024
4e145a0
[FIX] connector_woocommerce: included attachments from templates and …
KNVx Sep 5, 2024
b548cf9
[IMP] connector_woocommerce: product public category export None on d…
KNVx Sep 5, 2024
5a2602a
[FIX] connector_woocommerce: incorrect format on code
KNVx Sep 5, 2024
1c67780
[IMP] connector_woocommerce_wpml: improved description mapping for pr…
KNVx Sep 6, 2024
c07330a
[IMP] connector_woocommerce_wpml: included TODOS for next tasks
KNVx Sep 6, 2024
decc9d2
[IMP] website_sale_extra_fields: slug_name modified to be computed wi…
KNVx Sep 12, 2024
a9bc522
[IMP] connector_woocommerce_wpml: message duplicated term slug name c…
KNVx Sep 12, 2024
5282796
[FIX] connector_woocommerce: import partners duplicate partners
KNVx Sep 12, 2024
42d1abb
[IMP] connector_woocommerce_apg_nif: included hooks to separate NIF f…
KNVx Sep 12, 2024
552c1ac
[IMP] website_sale_extra_fields: new ir.checksum. modified view names…
KNVx Sep 12, 2024
28b4b5a
[IMP] connector_wordpress: modified ir_attachment, now we use ir_chec…
KNVx Sep 12, 2024
9c49d18
[IMP] connector_woocommerce: refactor ir_attachment, now we use ir_ch…
KNVx Sep 12, 2024
f7b68e7
[IMP] connector_woocommerce_wpml: removed ir_attachmemnt code. TODO: …
KNVx Sep 12, 2024
ab3e1a4
[IMP] connector_woocommerce: included TODOS, removed useless code
KNVx Sep 16, 2024
4af3b3d
[IMP] connector_woocommerce_ast: included TODO
KNVx Sep 16, 2024
d4ca260
[IMP] website_sale_extra_fields: included TODO and improved code
KNVx Sep 16, 2024
5d1d166
[IMP] connector_wordpress_wpml: TODO: adapt wordpress wpml like wooco…
KNVx Sep 16, 2024
a25b464
[IMP] connector_woocommerce_wpml: new connector, component mode. Revi…
KNVx Sep 16, 2024
7eaa618
[IMP] website_sale_extra_fields: add public additional information field
FrankC013 Oct 10, 2024
2745dc5
[ADD] connector_woocommerce_wpml_acf
FrankC013 Oct 11, 2024
9f75e38
[ADD] connector_woocommerce_acf
FrankC013 Oct 11, 2024
3e7e0b3
[REF] connector_wordpress: change backend credentials field name
FrankC013 Oct 11, 2024
c4be597
[FIX] connector_woocommerce_wpml: languages required
FrankC013 Oct 11, 2024
ca03997
[FIX] connector_woocommerce: expected string or bytes-like object whe…
FrankC013 Oct 11, 2024
747bba5
[REF] connector_extension_wordpress: rename wordpres backend credentials
FrankC013 Oct 11, 2024
288f6d2
[FIX] connector_woocommerce: manage multiple domain values
FrankC013 Oct 11, 2024
bddc1b1
[IMP] connector_woocommerce_wpml: add res_partner, sale_order, sale_o…
FrankC013 Oct 16, 2024
08aa9e8
[IMP] connector_woocommerce_apg_nif: duplicated partners
FrankC013 Oct 16, 2024
a1c39c5
[REF] connector_woocommerce: dont create / write records in adapter
FrankC013 Oct 16, 2024
1c0582d
[REF] connector_extension: not allow negative chunk size in backend
FrankC013 Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 7 additions & 1 deletion connector_extension/components/binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,13 @@ def _additional_internal_binding_fields(self, external_data):
return {}

def _get_external_record_domain(self, relation, values):
return [(k, "=", v) for k, v in values.items()]
domain = []
for k, v in values.items():
if isinstance(v, (tuple, list)):
domain.append((k, "in", v))
else:
domain.append((k, "=", v))
return domain

def _get_external_record_alt(self, relation, id_values):
domain = self._get_external_record_domain(relation, id_values)
Expand Down
8 changes: 7 additions & 1 deletion connector_extension/models/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ def _select_state(self):

chunk_size = fields.Integer(
string="Chunk Size",
default=-1,
help="This field is used to define the chunk size to import from the backend.",
)

@api.constrains("chunk_size")
def _check_chunk_size(self):
for rec in self:
if rec.chunk_size < 0:
raise ValueError("Chunk Size must be a positive number")

page_size = fields.Integer(
string="Page Size",
default=-1,
Expand Down
64 changes: 64 additions & 0 deletions connector_extension_woocommerce/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
===============================
Connector Extension Woocommerce
===============================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-NuoBiT%2Fodoo--addons-lightgray.png?logo=github
:target: https://github.com/NuoBiT/odoo-addons/tree/14.0/connector_extension_woocommerce
:alt: NuoBiT/odoo-addons

|badge1| |badge2| |badge3|

This module extends the connector extension module to add support for Woocommerce

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/NuoBiT/odoo-addons/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/NuoBiT/odoo-addons/issues/new?body=module:%20connector_extension_woocommerce%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
~~~~~~~

* NuoBiT Solutions
* SL

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

* `NuoBiT <https://www.nuobit.com>`__:

* Kilian Niubo <[email protected]>
* Eric Antones <[email protected]>

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

This module is part of the `NuoBiT/odoo-addons <https://github.com/NuoBiT/odoo-addons/tree/14.0/connector_extension_woocommerce>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions connector_extension_woocommerce/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import components
15 changes: 15 additions & 0 deletions connector_extension_woocommerce/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright NuoBiT Solutions - Kilian Niubo <[email protected]>
# Copyright NuoBiT Solutions - Eric Antones <[email protected]>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

{
"name": "Connector Extension Woocommerce",
"summary": "This module extends the connector extension module "
"to add support for Woocommerce",
"version": "14.0.1.0.0",
"author": "NuoBiT Solutions, SL",
"license": "LGPL-3",
"category": "Connector",
"website": "https://github.com/nuobit/odoo-addons",
"depends": ["connector_extension"],
}
1 change: 1 addition & 0 deletions connector_extension_woocommerce/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import adapter
212 changes: 212 additions & 0 deletions connector_extension_woocommerce/components/adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Copyright NuoBiT Solutions - Eric Antones <[email protected]>
# Copyright NuoBiT Solutions - Kilian Niubo <[email protected]>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)

import json
import logging

from requests.exceptions import ConnectionError as RequestConnectionError

from odoo import _
from odoo.exceptions import ValidationError

from odoo.addons.component.core import AbstractComponent
from odoo.addons.connector.exception import RetryableJobError

from ...connector_extension.common.tools import trim_domain

_logger = logging.getLogger(__name__)


class ConnectorExtensionWooCommerceAdapterCRUD(AbstractComponent):
_name = "connector.extension.woocommerce.adapter.crud"
_inherit = "connector.extension.adapter.crud"

def _exec(self, op, resource, *args, **kwargs):
if kwargs.get("domain"):
kwargs["domain"] = trim_domain(kwargs["domain"])
func = getattr(self, "_exec_%s" % op)
return func(resource, *args, **kwargs)

def _manage_error_codes(
self, res_data, res, resource, raise_on_error=True, **kwargs
):
if not res.ok:
error_message = None
if res.status_code == 404:
if res_data.get("code") == "rest_no_route":
error_message = _(
"Error: '%s'. Probably the %s has been"
" removed from Woocommerce. "
"If it's the case, try to remove the binding of the %s."
% (res_data.get("message"), resource, self.model._name)
)
elif res_data.get("code") == "woocommerce_rest_term_invalid":
error_message = _(
"Error: '%s'. Probably the %s has been "
"removed from Woocommerce. "
"If it's the case, try to remove the binding of the %s."
% (res_data.get("message"), resource, self.model._name)
)
elif (
res_data.get("code")
== "woocommerce_rest_product_variation_invalid_parent"
):
error_message = _(
"Error: '%s'. Probably the product in %s "
"has been removed from Woocommerce. "
"If it's the case, try to remove the binding of the "
"woocommerce.product.template"
% (
res_data.get("message"),
resource,
)
)
elif res.status_code == 400:
if res_data.get("code") == "term_exists":
error_message = _(
"Error: '%s'. Probably repeated record already exists in Woocommerce.\n"
"Please, review the data in %s/%s and compare it with %s"
% (
res_data["message"],
resource,
res_data["res_data"]["resource_id"],
kwargs["data"],
)
)
elif (
res_data.get("code")
== "woocommerce_rest_product_variation_invalid_id"
):
error_message = _(
"Error: '%s'. Probably the %s has been removed from Woocommerce. "
"If it's the case, try to remove the binding of the %s."
% (res_data.get("message"), resource, self.model._name)
)
if not error_message:
error_message = _("Error: %s, Resource: %s" % (res_data, resource))
if raise_on_error:
raise ValidationError(error_message)
return error_message
return res_data

# TODO: remove this total items and use the res.headers instead
def _get_res_total_items(self, res):
headers = res.headers
total_items = headers.get("X-WP-Total") or 0
if total_items:
total_items = int(headers.get("X-WP-Total"))
return total_items

def _exec_wcapi_call(self, op, resource, *args, **kwargs):
func = getattr(self.wcapi, op)
try:
res = func(resource, *args, **kwargs)
res_data = res.json()
if "data" in res_data:
res_data["res_data"] = res_data.pop("data")
res_data = self._manage_error_codes(res_data, res, resource, **kwargs)
total_items = self._get_res_total_items(res)
result = {
"ok": res.ok,
"status_code": res.status_code,
"total_items": total_items,
"data": res_data,
}
except RequestConnectionError as e:
raise RetryableJobError(_("Error connecting to WooCommerce: %s") % e) from e
except json.decoder.JSONDecodeError as e:
raise ValidationError(
_(
"Error decoding json WooCommerce response: "
"%s\nArgs:%s\nKwargs:%s\n"
"URL:%s\nHeaders:%s\nMethod:%s\nBody:%s"
)
% (
e,
args,
kwargs,
res.url,
res.request.headers,
res.request.method,
res.text and res.text[:100] + " ...",
)
) from e
return result

def get_total_items(self, resource, domain=None):
filters_values = self._get_search_fields()
real_domain, common_domain = self._extract_domain_clauses(
domain, filters_values
)
params = self._domain_to_normalized_dict(real_domain)
params["per_page"] = 1
result = self._exec_wcapi_call("get", resource, params=params)
return result["total_items"]

def _get_search_fields(self):
return ["modified_after", "offset", "per_page", "page"]

def _exec_get(self, resource, *args, **kwargs):
if resource == "system_status":
return self._exec_wcapi_call("get", resource, *args, **kwargs)
# WooCommerce has the parameter next on the response headers
# to get the next page but we can't use it because if we use
# the offset, the next page will have the same items as the first page.
# It looks like a bug in WooCommerce API.
domain = []
if "domain" in kwargs:
domain = kwargs.pop("domain")
search_fields = self._get_search_fields()
real_domain, common_domain = self._extract_domain_clauses(domain, search_fields)
params = self._domain_to_normalized_dict(real_domain)
if "limit" in kwargs:
limit = kwargs.pop("limit")
else:
limit = self.get_total_items(resource, domain)
params["offset"] = (
kwargs.pop("offset") if "offset" in kwargs and "offset" not in params else 0
)
page_size = self.backend_record.page_size
params["per_page"] = page_size if page_size > 0 else 100
data = []
while len(data) < limit:
if page_size > limit - len(data):
params["per_page"] = limit - len(data)
res = self._exec_wcapi_call("get", resource, params=params, *args, **kwargs)
# WooCommerce returns a dict if the response is a single item
if not isinstance(res["data"], list):
res["data"] = [res["data"]]
data += res["data"]
params["offset"] += len(res["data"])
return self._filter(data, common_domain)

def _exec_post(self, resource, *args, **kwargs):
res = self._exec_wcapi_call(
"post",
resource,
*args,
**kwargs,
)
return res["data"]

def _exec_put(self, resource, *args, **kwargs):
return self._exec_wcapi_call("put", resource, *args, **kwargs)

def _exec_delete(self, resource, *args, **kwargs):
return self._exec_wcapi_call(
"delete",
resource,
*args,
**kwargs,
)

def _exec_options(self, resource, *args, **kwargs):
raise NotImplementedError()

def get_version(self):
system_status = self._exec("get", "system_status")
version = False
if system_status:
version = system_status["data"].get("environment").get("version")
return version
4 changes: 4 additions & 0 deletions connector_extension_woocommerce/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `NuoBiT <https://www.nuobit.com>`__:

* Kilian Niubo <[email protected]>
* Eric Antones <[email protected]>
1 change: 1 addition & 0 deletions connector_extension_woocommerce/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module extends the connector extension module to add support for Woocommerce
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading