Skip to content

Commit

Permalink
Merge PR #699 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by sebastienbeau
  • Loading branch information
shopinvader-git-bot committed Jun 19, 2020
2 parents e55d67d + 029a3a0 commit e6b3100
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
6 changes: 6 additions & 0 deletions setup/shopinvader_category_image_for_product/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
57 changes: 57 additions & 0 deletions shopinvader_category_image_for_product/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
======================================
Shopinvader category image for product
======================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-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-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github
:target: https://github.com/shopinvader/odoo-shopinvader/tree/10.0/shopinvader_cart_expiry
:alt: shopinvader/odoo-shopinvader

|badge1| |badge2| |badge3|

This ShopInvader submodule give the possibility to display the category image for products with no image.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/shopinvader/odoo-shopinvader/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 <https://github.com/shopinvader/odoo-shopinvader/issues/new?body=module:%shopinvader_category_image_for_product%0Aversion:%2010.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
~~~~~~~

* ACSONE SA/NV

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

* Cédric PIGEON <[email protected]>

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

This module is part of the `shopinvader/odoo-shopinvader <https://github.com/shopinvader/odoo-shopinvader/tree/10.0/shopinvader_category_image_for_product>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions shopinvader_category_image_for_product/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions shopinvader_category_image_for_product/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2020 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Shopinvader category image for product",
"summary": "Shopinvader Display category image for product",
"version": "12.0.1.0.0",
"category": "e-commerce",
"author": "ACSONE SA/NV",
"website": "https://github.com/shopinvader/odoo-shopinvader",
"license": "AGPL-3",
"installable": True,
"depends": [
"shopinvader",
"shopinvader_search_engine",
"shopinvader_image",
],
"data": ["data/ir_export.xml"],
"demo": [],
}
9 changes: 9 additions & 0 deletions shopinvader_category_image_for_product/data/ir_export.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="ir_exp_shopinvader_variant_image_category" model="ir.exports.line">
<field name="name">image_categories</field>
<field name="export_id" ref="shopinvader.ir_exp_shopinvader_variant"/>
</record>
</odoo>
1 change: 1 addition & 0 deletions shopinvader_category_image_for_product/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import shopinvader_variant
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2020 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
from odoo.fields import first


class ShopinvaderVariant(models.Model):
_name = "shopinvader.variant"
_inherit = ["shopinvader.variant"]

image_categories = fields.Serialized(compute="_compute_image_categories")

@api.model
def _get_category_by_backend(self, record):
return record.shopinvader_categ_ids.filtered(
lambda c, v=record: c.record_id == v.categ_id
and c.index_id.backend_id == v.index_id.backend_id
and c.images
)

@api.multi
@api.depends(
"shopinvader_categ_ids",
"shopinvader_categ_ids.index_id",
"shopinvader_categ_ids.index_id.backend_id",
"shopinvader_categ_ids.images",
)
def _compute_image_categories(self):
"""
Compute function for image_categories field.
This field should contains the value of images field into the first
category found (with same backend)
:return:
"""
for record in self:
category = self._get_category_by_backend(record)
record.image_categories = first(category).images or []
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Cédric PIGEON <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This addon allows to display the category image when a product has no images.

0 comments on commit e6b3100

Please sign in to comment.