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

ADD catalog-maanger #20

Open
wants to merge 1 commit into
base: 14.0-tax-priority
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
74 changes: 74 additions & 0 deletions connector_prestashop_catalog_manager/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.. 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]>
* Guillaume Masson <[email protected]>
* Marc Poch <[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
37 changes: 37 additions & 0 deletions connector_prestashop_catalog_manager/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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": "14.0.1.0.0",
"license": "AGPL-3",
"depends": [
"connector_prestashop",
"product_categ_image",
"product_multi_image",
"product_brand",
],
"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",
"wizards/export_brand_view.xml",
"views/product_image_view.xml",
"views/product_category_view.xml",
"security/ir.model.access.csv",
],
"installable": True,
}
10 changes: 10 additions & 0 deletions connector_prestashop_catalog_manager/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# © 2016 Sergio Teruel <[email protected]>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import binding
from . import product_brand
from . import product_category
from . import product_product
from . import product_template
from . import product_image
from . import ir_translation
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2021 PlanetaTIC - Marc Poch <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import common
16 changes: 16 additions & 0 deletions connector_prestashop_catalog_manager/models/binding/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 PlanetaTIC - Marc Poch <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class PrestashopBinding(models.AbstractModel):
_inherit = "prestashop.binding"

@api.model
def create(self, vals):
ctx = self.env.context.copy()
ctx["catalog_manager_ignore_translation"] = True
res = super(PrestashopBinding, self.with_context(ctx)).create(vals)

return res
46 changes: 46 additions & 0 deletions connector_prestashop_catalog_manager/models/ir_translation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2019 PlanetaTIC - Marc Poch <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class IrTranslation(models.Model):
_inherit = "ir.translation"

def write_on_source_model(self):
"""Force a write on source model to make catalog_manager
export the translation
"""
for translation in self:
if translation.type == "model":
# get model and ir_field
model, fieldname = translation.name.split(",")
model_obj = translation.env[model]
instance = model_obj.browse(translation.res_id)
instance_vals = instance.read([fieldname])[0]
untranslated_content = instance_vals[fieldname]
instance.with_context(catalog_manager_force_translation=True).write(
{fieldname: untranslated_content}
)
return True

def write(self, vals):
res = False
for translation in self:
if translation.env.context.get("catalog_manager_force_translation", False):
continue
res = super().write(vals)

self.write_on_source_model()
return res

@api.model
def create(self, vals):
res = super().create(vals)

if not self.env.context.get("catalog_manager_ignore_translation", False):
# It is called from a binding creation so,
# Once the binding will be created, it will export everything.
# this way we avoid job duplicities exporting the same instance
res.write_on_source_model()
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2020 PlanetaTIC - Marc Poch <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import common
from . import exporter
from . import deleter
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2020 PlanetaTIC - Marc Poch <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import Component
from odoo.addons.component_event import skip_if


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

@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 ProductBrandListener(Component):
_name = "product.brand.event.listener"
_inherit = "prestashop.connector.listener"
_apply_on = "product.brand"

@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)

@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.brand"
)
prestashop_id = binder.to_external(binding)
if prestashop_id:
self.env["prestashop.product.brand"].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 2020 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 ProductBrandDeleter(Component):
_name = "prestashop.product.brand.deleter"
_inherit = "prestashop.deleter"
_apply_on = [
"prestashop.product.brand",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 PlanetaTIC - Marc Poch <[email protected]>
# 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 mapping


class ProductBrandExporter(Component):
_name = "prestashop.product.brand.exporter"
_inherit = "prestashop.exporter"
_apply_on = "prestashop.product.brand"


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

direct = [
("name", "name"),
]

@mapping
def active(self, record):
return {"active": 1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import common
from . import exporter
from . import deleter
Loading