[14.0][MIG] base_conditional_image: Migration to 14.0

pull/2372/head
sonhd 2021-12-20 21:39:04 +07:00 committed by Denis Leemann
parent ef1064e4ee
commit 10f7743cf5
7 changed files with 98 additions and 67 deletions

View File

@ -14,13 +14,13 @@ Conditional Images
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/12.0/base_conditional_image
:target: https://github.com/OCA/server-tools/tree/14.0/base_conditional_image
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_conditional_image
:target: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_conditional_image
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/12.0
:target: https://runbot.odoo-community.org/runbot/149/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -71,7 +71,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/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/OCA/server-tools/issues/new?body=module:%20base_conditional_image%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_conditional_image%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.
@ -86,7 +86,15 @@ Authors
Contributors
~~~~~~~~~~~~
* Patrick Tombez <patrick.tombez@camptocamp.com>
* `Camptocamp <https://camptocamp.com/>`_:
* Patrick Tombez <patrick.tombez@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Son Ho <sonhd@trobz.com>
Other credits
~~~~~~~~~~~~~
The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp
Maintainers
~~~~~~~~~~~
@ -101,6 +109,6 @@ 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.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/base_conditional_image>`_ project on GitHub.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/14.0/base_conditional_image>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -3,7 +3,8 @@
{
"name": "Conditional Images",
"version": "12.0.1.0.1",
"summary": "This module extends the functionality to support conditional images",
"version": "14.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Misc",

View File

@ -51,7 +51,10 @@ class Image(models.Model):
@api.model
def _process_images(self, vals, required=False):
if {"image", "image_medium", "image_small"} & set(vals.keys()):
tools.image_resize_images(vals)
vals["image_medium"] = tools.image_process(
vals.get("image"), size=(128, 128)
)
vals["image_small"] = tools.image_process(vals.get("image"), size=(64, 64))
elif required:
raise ValidationError(_("At least one image type must be specified"))
@ -60,7 +63,6 @@ class Image(models.Model):
self._process_images(vals, required=True)
return super().create(vals)
@api.multi
def write(self, vals):
self._process_images(vals)
return super().write(vals)

View File

@ -1 +1,4 @@
* Patrick Tombez <patrick.tombez@camptocamp.com>
* `Camptocamp <https://camptocamp.com/>`_:
* Patrick Tombez <patrick.tombez@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Son Ho <sonhd@trobz.com>

View File

@ -0,0 +1 @@
The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Conditional Images</title>
<style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/base_conditional_image"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_conditional_image"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/base_conditional_image"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_conditional_image"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of any model to support conditional images
(based on the record attributes) and to manage them either globally or by company.</p>
<p>The main goal behind this module is to avoid storing the same image multiple times.
@ -383,7 +383,8 @@ With this module properly set up, it will be stored only one time and you can ch
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="id7">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
</ul>
</li>
</ul>
@ -414,7 +415,7 @@ If your object does not have a <cite>company_id</cite> field, this check will be
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_conditional_image%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_conditional_image%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -428,17 +429,36 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li><dl class="first docutils">
<dt><a class="reference external" href="https://camptocamp.com/">Camptocamp</a>:</dt>
<dd><ul class="first last">
<li>Patrick Tombez &lt;<a class="reference external" href="mailto:patrick.tombez&#64;camptocamp.com">patrick.tombez&#64;camptocamp.com</a>&gt;</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://trobz.com">Trobz</a>:</dt>
<dd><ul class="first last">
<li>Son Ho &lt;<a class="reference external" href="mailto:sonhd&#64;trobz.com">sonhd&#64;trobz.com</a>&gt;</li>
</ul>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id7">Other credits</a></h2>
<p>The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/base_conditional_image">OCA/server-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/base_conditional_image">OCA/server-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -1,64 +1,60 @@
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<odoo>
<record id="view_image_tree" model="ir.ui.view">
<field name="name">image.tree</field>
<field name="model">image</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="model_name" />
<field name="company_id" />
<field name="selector" />
</tree>
</field>
<field name="name">image.tree</field>
<field name="model">image</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="model_name" />
<field name="company_id" />
<field name="selector" />
</tree>
</field>
</record>
<record id="view_image_form" model="ir.ui.view">
<field name="name">image.form</field>
<field name="model">image</field>
<field name="arch" type="xml">
<form>
<group>
<group>
<field name="name" />
<field name="model_name" />
<field name="company_id" />
</group>
<group>
<field
name="image"
widget='image'
class="oe_avatar"
options='{"preview_image": "image_medium"}'
/>
</group>
<group string="Selector">
<field
name="selector"
nolabel="True"
widget="ace"
options="{'mode': 'python'}"
/>
</group>
</group>
</form>
</field>
<field name="name">image.form</field>
<field name="model">image</field>
<field name="arch" type="xml">
<form>
<group>
<group>
<field name="name" />
<field name="model_name" />
<field name="company_id" />
</group>
<group>
<field
name="image"
widget='image'
class="oe_avatar"
options='{"preview_image": "image_medium"}'
/>
</group>
<group string="Selector">
<field
name="selector"
nolabel="True"
widget="ace"
options="{'mode': 'python'}"
/>
</group>
</group>
</form>
</field>
</record>
<record id="image_action" model="ir.actions.act_window">
<field name="name">Images</field>
<field name="res_model">image</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
id="image_menu"
string="Images"
parent="base.menu_ir_property"
action="image_action"
sequence="99"
/>
</data>
</openerp>
<record model="ir.ui.menu" id="image_menu">
<field name="name">Images</field>
<field name="parent_id" ref="base.menu_ir_property" />
<field name="action" ref="image_action" />
<field name="sequence" eval="99" />
</record>
</odoo>