Skip to content
Merged
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
35 changes: 35 additions & 0 deletions fs_product_brand_multi_image/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
**This file is going to be generated by oca-gen-addon-readme.**

*Manual changes will be overwritten.*

Please provide content in the ``readme`` directory:

* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)

Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.

A good, one sentence summary in the manifest is also highly recommended.


Automatic changelog generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_.

Just put towncrier compatible changelog fragments into `readme/newsfragments`
and the changelog file will be automatically generated and updated when a new fragment is added.

Please refer to `towncrier` documentation to know more.

NOTE: the changelog will be automatically generated when using `/ocabot merge $option`.
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_.
1 change: 1 addition & 0 deletions fs_product_brand_multi_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions fs_product_brand_multi_image/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Fs Product Brand Multi Image",
"summary": """
Link images to product brands""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/storage",
"depends": ["fs_base_multi_image", "product_brand", "sales_team", "image_tag"],
"data": [
"security/fs_product_brand_image.xml",
"views/fs_product_brand_image.xml",
"views/product_brand.xml",
],
"demo": [],
"maintainers": ["lmignon"],
"development_status": "Alpha",
}
3 changes: 3 additions & 0 deletions fs_product_brand_multi_image/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import fs_product_brand_image
from . import product_brand
from . import image_tag
21 changes: 21 additions & 0 deletions fs_product_brand_multi_image/models/fs_product_brand_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class FsProductBrandImage(models.Model):
_name = "fs.product.brand.image"
_inherit = "fs.image.relation.mixin"
_description = "Product Brand Image"

brand_id = fields.Many2one(
"product.brand",
required=True,
ondelete="cascade",
)
tag_id = fields.Many2one(
"image.tag",
string="tag",
domain=[("apply_on", "=", "brand")],
)
23 changes: 23 additions & 0 deletions fs_product_brand_multi_image/models/image_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2021 Akretion (https://www.akretion.com).
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from odoo import api, fields, models


class ImageTag(models.Model):
_inherit = "image.tag"

@api.model
def _get_default_apply_on(self):
active_model = self.env.context.get("active_model")
if active_model == "product.brand.image.relation":
return "brand"
else:
return super()._get_default_apply_on()

apply_on = fields.Selection(
selection_add=[("brand", "Brand")],
ondelete={"brand": "cascade"},
)
20 changes: 20 additions & 0 deletions fs_product_brand_multi_image/models/product_brand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2020 ACSONE SA/NV
# Copyright 2021 Camptocamp (http://www.camptocamp.com).
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models

from odoo.addons.fs_image.fields import FSImage


class ProductBrand(models.Model):
_inherit = "product.brand"

image_ids = fields.One2many(
string="Images",
comodel_name="fs.product.brand.image",
inverse_name="brand_id",
)
image = FSImage(related="image_ids.image", readonly=True, store=False)
image_medium = FSImage(related="image_ids.image_medium", readonly=True, store=False)
7 changes: 7 additions & 0 deletions fs_product_brand_multi_image/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* Sébastien Beau <sebastien.beau@akretion.com>
* Quentin Groulard <quentin.groulard@acsone.eu>
* `Camptocamp <https://www.camptocamp.com>`_

* Iván Todorovich <ivan.todorovich@gmail.com>

* Laurent Mignon <laurent.mignon@acsone.eu>
3 changes: 3 additions & 0 deletions fs_product_brand_multi_image/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Attach images stored into an external filesystem to product brands

This addon is a drop-in replacement for the **storage_image_product_brand** addon.
2 changes: 2 additions & 0 deletions fs_product_brand_multi_image/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Go to Sales > Configuration > Products > Product Brands.
A new field Images is available to upload or use existing images.
23 changes: 23 additions & 0 deletions fs_product_brand_multi_image/security/fs_product_brand_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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 model="ir.model.access" id="fs_product_brand_image_access_read">
<field name="name">fs.product.brand.image access read</field>
<field name="model_id" ref="model_fs_product_brand_image" />
<field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="0" />
<field name="perm_write" eval="0" />
<field name="perm_unlink" eval="0" />
</record>
<record model="ir.model.access" id="fs_product_brand_image_access_edit">
<field name="name">fs.product.brand.image access edit</field>
<field name="model_id" ref="model_fs_product_brand_image" />
<field name="group_id" ref="sales_team.group_sale_manager" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="1" />
<field name="perm_write" eval="1" />
<field name="perm_unlink" eval="1" />
</record>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions fs_product_brand_multi_image/views/fs_product_brand_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2020 ACSONE SA/NV
Copyright 2021 Camptocamp (http://www.camptocamp.com).
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record model="ir.ui.view" id="fs_product_brand_image_form_view">
<field name="name">product.brand.fs.image.form</field>
<field name="model">fs.product.brand.image</field>
<field
name="inherit_id"
ref="fs_base_multi_image.fs_image_relation_mixin_form_view"
/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<group name="extra" position="inside">
<field name="tag_id" context="{'default_apply_on': 'brand'}" />
</group>
</field>
</record>
</odoo>
50 changes: 50 additions & 0 deletions fs_product_brand_multi_image/views/product_brand.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2020 ACSONE SA/NV
Copyright 2021 Camptocamp (http://www.camptocamp.com).
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record model="ir.ui.view" id="product_brand_form_view">
<field name="model">product.brand</field>
<field name="inherit_id" ref="product_brand.view_product_brand_form" />
<field name="arch" type="xml">
<field name="logo" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="logo" position="after">
<field
name="image"
class="oe_avatar"
options="{'preview_image': 'image_medium', 'zoom': true}"
/>
</field>
<notebook position="inside">
<page name="images" string="Images">
<field name="image_ids">
<tree>
<field name="sequence" widget="handle" />
<field name="name" />
</tree>
</field>
<!-- field
name="image_ids"
mode="kanban"
widget="storage_image_handle"
/ -->
</page>
</notebook>
</field>
</record>
<record model="ir.ui.view" id="product_brand_kanban_view">
<field name="model">product.brand</field>
<field name="inherit_id" ref="product_brand.view_product_brand_kanban" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('o_kanban_image')]/img" position="attributes">
<attribute
name="t-att-src"
>kanban_image('product.brand', 'image_medium', record.id.raw_value)</attribute>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/fs_product_brand_multi_image/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,
)