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

[16.0][MIG] connector_prestashop_catalog_manager: Migration to 16.0 #181

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1d8cf97
[ADD] connector_prestashop_catalog_manager:
pedrobaeza Sep 5, 2016
e82cacc
[IMP][8.0] connector_prestashop_catalog_manager: Export categories fr…
sergio-teruel Sep 11, 2016
2b27519
[FIX][8.0] connector_prestashop_catalog_manager: Fixed error when exp…
sergio-teruel Sep 12, 2016
4ee7ed8
[FIX][8.0] connector_prestashop_catalog_manager: Export field create_…
sergio-teruel Sep 14, 2016
3e1b865
[IMP][8.0] connector_prestashop: Update ps combinations after export …
sergio-teruel Sep 18, 2016
778888f
[FIX][8.0] connector_prestashop_catalog_manager: Fix error to write i…
sergio-teruel Sep 28, 2016
deecc7a
[fix] catalog manager
simahawk Oct 19, 2016
b40951a
[fix] translations
simahawk Oct 19, 2016
f10dfc8
PEP8 + MT cleanup
simahawk Oct 19, 2016
0ccb481
Do not export imported product templates
guewen Nov 29, 2016
912911e
[9.0][MIG] connector_prestashop_catalog_manager: Migration and new st…
sergio-teruel Nov 29, 2016
39c8e2b
[9.0][FIX] connector_prestashop_catalog_manager: Fix export impact price
sergio-teruel Nov 30, 2016
965b5d2
[9.0][FIX] connector_prestashop_catalog_manager: Fix export default c…
sergio-teruel Nov 30, 2016
33a8eeb
[9.0][FIX] custom_connector_prestashop_catalog_feature: Remove defaul…
sergio-teruel Nov 30, 2016
d6c788e
[9.0][FIX] connector_prestashop_catalog_manager: Fix tax group in pro…
sergio-teruel Dec 1, 2016
1f218d5
[9.0][FIX] connector_prestashop_catalog_manager: Fix error when expor…
sergio-teruel Dec 1, 2016
cba839c
Move 'get_environment' to 'prestashop.backend' model
guewen Dec 5, 2016
0cfedfb
fixup! [9.0][MIG] connector_prestashop_catalog_manager: Migration and…
guewen Dec 5, 2016
f676470
Remove the shop_url
guewen Dec 5, 2016
b715f78
pep8
guewen Dec 7, 2016
3ad0ac3
Fix pylint errors/warnings
guewen Dec 7, 2016
534ec02
[mig][9.0] connector_prestashop_manufacturer
simahawk Feb 1, 2017
d26ab29
update contribs
simahawk Feb 10, 2017
02566d4
[add] base adapter: add _export_node_name_res attr to handle results
simahawk Feb 10, 2017
7bfd2ac
fix author
simahawk Feb 10, 2017
7f03b65
[add] manufacturer export
simahawk Feb 14, 2017
8fb51ff
Rise the digit number for exported prices rounding
guewen Mar 3, 2017
c7ee68b
[MIG] Make modules uninstallable
pedrobaeza Apr 2, 2017
e31bf9c
[MIG] Rename manifest files
pedrobaeza Apr 2, 2017
eb2ad55
[FIX+IMP] connector_prestashop: Several things:
simahawk May 8, 2017
2fc592b
[9.0][IMP] connector_prestashop_catalog_manager: Change image from da…
sergio-teruel Jun 25, 2017
7d5556a
[FIX] connector_prestashop: Fix atomicity design (#81)
nbessi Sep 13, 2017
f6229eb
[IMP] connector_prestashop_catalog_manager: pre-commit stuff
AurelijaNorvaisaite Jun 26, 2024
b706082
[MIG] connector_prestashop_catalog_manager Migration to 16.0
AurelijaNorvaisaite Jun 26, 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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^connector_prestashop_catalog_manager/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
Expand Down
72 changes: 72 additions & 0 deletions connector_prestashop_catalog_manager/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=============================================
Catalog Manager for Odoo PrestaShop Connector
=============================================

This module is an extension for *connector_prestashop*. With it, you will be
able to manage your catalog directly from Odoo:

* Create/modify attributtes and values in Odoo and push then in PrestaShop.
* Create/modify products and push them in PrestaShop.
* Create/modify products variants and push them in PrestaShop (combinations).
* Create/modify category and push them in PrestaShop.
* Create/modify image and push then in PrestaShop.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/108/8.0


Known issues / Roadmap
======================

* Tests.

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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/connector-prestashop/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Images
------

* `PrestaShop logo <http://seeklogo.com/prestashop-logo-178788.html>`_.
* `Odoo logo <https://www.odoo.com/es_ES/page/brand-assets>`_.
* `Cable <https://openclipart.org/detail/174134/cable-with-connector>`_.

Contributors
------------

* Sébastien Beau <[email protected]>
* Benoît Guillot <[email protected]>
* Mikel Arregi <[email protected]>
* Sergio Teruel <[email protected]>
* Pedro M. Baeza <[email protected]>
* Simone Orsi <[email protected]>

Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
4 changes: 4 additions & 0 deletions connector_prestashop_catalog_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import wizards
35 changes: 35 additions & 0 deletions connector_prestashop_catalog_manager/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2011-2013 Camptocamp
# Copyright 2011-2013 Akretion
# Copyright 2015 AvanzOSC
# Copyright 2015-2016 Tecnativa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Prestashop-Odoo Catalog Manager",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"depends": [
"connector_prestashop",
"product_categ_image",
"product_multi_image",
],
"author": "Akretion,"
"AvanzOSC,"
"Tecnativa,"
"Camptocamp SA,"
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector-prestashop",
"category": "Connector",
"data": [
"views/product_attribute_view.xml",
"views/product_view.xml",
"wizards/export_category_view.xml",
"wizards/export_multiple_products_view.xml",
"wizards/sync_products_view.xml",
"wizards/active_deactive_products_view.xml",
"views/product_image_view.xml",
"views/product_category_view.xml",
"security/ir.model.access.csv",
],
"installable": True,
}
7 changes: 7 additions & 0 deletions connector_prestashop_catalog_manager/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# © 2016 Sergio Teruel <[email protected]>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import product_category
from . import product_product
from . import product_template
from . import product_image
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import common
from . import exporter
from . import deleter
141 changes: 141 additions & 0 deletions connector_prestashop_catalog_manager/models/product_category/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import fields, models
from odoo.tools import config

from odoo.addons.component.core import Component
from odoo.addons.component_event import skip_if
from odoo.addons.connector_prestashop.components.backend_adapter import (
PrestaShopWebServiceImage,
)


class ProductCategory(models.Model):
_inherit = "product.category"

prestashop_image_bind_ids = fields.One2many(
comodel_name="prestashop.categ.image",
inverse_name="odoo_id",
copy=False,
string="PrestaShop Image Bindings",
)


class PrestashopCategImage(models.Model):
_name = "prestashop.categ.image"
_inherit = "prestashop.binding.odoo"
_inherits = {"product.category": "odoo_id"}
_description = "Prestashop Category Image"

odoo_id = fields.Many2one(
comodel_name="product.category",
string="Product",
required=True,
ondelete="cascade",
)


class PrestashopCategImageModelBinder(Component):
_name = "prestashop.categ.image.binder"
_inherit = "prestashop.binder"
_apply_on = "prestashop.categ.image"


class CategImageAdapter(Component):
_name = "prestashop.categ.image.adapter"
_inherit = "prestashop.crud.adapter"
_apply_on = "prestashop.categ.image"
_prestashop_image_model = "categories"

def connect(self):
debug = False
if config["log_level"] == "debug":
debug = True
return PrestaShopWebServiceImage(
self.prestashop.api_url, self.prestashop.webservice_key, debug=debug
)

def read(self, category_id, image_id, options=None):
# pylint: disable=method-required-super
api = self.connect()
return api.get_image(
self._prestashop_image_model, category_id, image_id, options=options
)

def create(self, attributes=None):
# pylint: disable=method-required-super
api = self.connect()
image_binary = attributes["image"]
img_filename = attributes["name"]
image_url = "images/{}/{}".format(
self._prestashop_image_model,
str(attributes["categ_id"]),
)
return api.add(image_url, files=[("image", img_filename, image_binary)])

def write(self, id_, attributes=None):
# pylint: disable=method-required-super
api = self.connect()
image_binary = attributes["image"]
img_filename = attributes["name"]
delete_url = "images/%s" % (self._prestashop_image_model)
api.delete(delete_url, str(attributes["categ_id"]))
image_url = "images/{}/{}".format(
self._prestashop_image_model,
str(attributes["categ_id"]),
)
return api.add(image_url, files=[("image", img_filename, image_binary)])


class PrestashopProductCategoryListener(Component):
_name = "prestashop.product.category.event.listener"
_inherit = "prestashop.connector.listener"
_apply_on = "prestashop.product.category"

@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
def on_record_create(self, record, fields=None):
"""Called when a record is created"""
record.with_delay().export_record(fields=fields)

@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
@skip_if(lambda self, record, **kwargs: self.need_to_export(record, **kwargs))
def on_record_write(self, record, fields=None):
"""Called when a record is written"""
record.with_delay().export_record(fields=fields)


class ProductCategoryListener(Component):
_name = "product.category.event.listener"
_inherit = "prestashop.connector.listener"
_apply_on = "product.category"

@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
def on_record_write(self, record, fields=None):
"""Called when a record is written"""
for binding in record.prestashop_bind_ids:
if not self.need_to_export(binding, fields):
binding.with_delay().export_record(fields=fields)
if "image" in fields:
if record.prestashop_image_bind_ids:
for image in record.prestashop_image_bind_ids:
image.with_delay().export_record(fields=fields)
else:
for presta_categ in record.prestashop_bind_ids:
image = self.env["prestashop.categ.image"].create(
{"backend_id": presta_categ.backend_id.id, "odoo_id": record.id}
)
image.with_delay().export_record(fields=fields)

@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
def on_record_unlink(self, record, fields=None):
"""Called when a record is deleted"""
for binding in record.prestashop_bind_ids:
work = self.work.work_on(collection=binding.backend_id)
binder = work.component(
usage="binder", model_name="prestashop.product.category"
)
prestashop_id = binder.to_external(binding)
if prestashop_id:
self.env[
"prestashop.product.category"
].with_delay().export_delete_record(binding.backend_id, prestashop_id)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2018 PlanetaTIC - Marc Poch <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import Component


class ProductCategoryDeleter(Component):
_name = "prestashop.product.category.deleter"
_inherit = "prestashop.deleter"
_apply_on = [
"prestashop.product.category",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import Component
from odoo.addons.connector.components.mapper import changed_by, mapping

from ..product_template.exporter import get_slug


class ProductCategoryExporter(Component):
_name = "prestashop.product.category.exporter"
_inherit = "prestashop.exporter"
_apply_on = "prestashop.product.category"

def _export_dependencies(self):
"""Export the dependencies for the category"""
category_binder = self.binder_for("prestashop.product.category")
categories_obj = self.env["prestashop.product.category"]
for category in self.binding:
self.export_parent_category(
category.odoo_id.parent_id, category_binder, categories_obj
)

def export_parent_category(self, category, binder, ps_categ_obj):
if not category:
return
ext_id = binder.to_external(category.id, wrap=True)
if ext_id:
return ext_id
res = {
"backend_id": self.backend_record.id,
"odoo_id": category.id,
"link_rewrite": get_slug(category.name),
}
category_ext = ps_categ_obj.with_context(connector_no_export=True).create(res)
parent_cat_id = category_ext.export_record()
return parent_cat_id


class ProductCategoryExportMapper(Component):
_name = "prestashop.product.category.export.mapper"
_inherit = "translation.prestashop.export.mapper"
_apply_on = "prestashop.product.category"

direct = [
("default_shop_id", "id_shop_default"),
("active", "active"),
("position", "position"),
]
# handled by base mapping `translatable_fields`
_translatable_fields = [
("name", "name"),
("link_rewrite", "link_rewrite"),
("description", "description"),
("meta_description", "meta_description"),
("meta_keywords", "meta_keywords"),
("meta_title", "meta_title"),
]

@changed_by("parent_id")
@mapping
def parent_id(self, record):
if not record["parent_id"]:
return {"id_parent": 2}
category_binder = self.binder_for("prestashop.product.category")
ext_categ_id = category_binder.to_external(record.parent_id.id, wrap=True)
return {"id_parent": ext_categ_id}


class CategImageExporter(Component):
_name = "prestashop.product.category.image.exporter"
_inherit = "prestashop.exporter"
_apply_on = "prestashop.categ.image"

def _create(self, data):
"""Create the Prestashop record"""
if self.backend_adapter.create(data):
return 1

def _update(self, data):
return 1


class CategImageExportMapper(Component):
_name = "prestashop.product.category.image.mapper"
_inherit = "prestashop.export.mapper"
_apply_on = "prestashop.categ.image"

@changed_by("image")
@mapping
def image(self, record):
name = record.name.lower() + ".jpg"
return {"image": record["image"], "name": name}

@changed_by("odoo_id")
@mapping
def odoo_id(self, record):
binder = self.binder_for("prestashop.product.category")
ext_categ_id = binder.to_external(record.odoo_id.id, wrap=True)
return {"categ_id": ext_categ_id}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import common
from . import exporter
from . import deleter
Loading
Loading