Browse Source
[9.0][ADD][partner_multi_image] possibility to have multiple images for a partner (#287)
pull/218/merge
[9.0][ADD][partner_multi_image] possibility to have multiple images for a partner (#287)
pull/218/merge
Sergio Teruel Albert
8 years ago
committed by
Pedro M. Baeza
11 changed files with 244 additions and 0 deletions
-
3oca_dependencies.txt
-
87partner_multi_image/README.rst
-
10partner_multi_image/__init__.py
-
27partner_multi_image/__openerp__.py
-
18partner_multi_image/hooks.py
-
9partner_multi_image/models/__init__.py
-
31partner_multi_image/models/res_partner.py
-
BINpartner_multi_image/static/description/icon.png
-
5partner_multi_image/tests/__init__.py
-
27partner_multi_image/tests/test_res_partner.py
-
27partner_multi_image/views/res_partner_view.xml
@ -1,2 +1,5 @@ |
|||
# List the OCA project dependencies, one per line |
|||
# Add a repository url and branch if you need a forked version |
|||
account-payment |
|||
product-attribute |
|||
server-tools |
@ -0,0 +1,87 @@ |
|||
.. 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 |
|||
|
|||
=========================== |
|||
Multiple Images in Partners |
|||
=========================== |
|||
|
|||
This module implements the possibility to have multiple images for a partner. |
|||
|
|||
Installation |
|||
============ |
|||
|
|||
To install this module, you need to: |
|||
|
|||
* Install ``base_multi_image`` from |
|||
`OCA/server-tools <https://github.com/OCA/server-tools>`_. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, you need to: |
|||
|
|||
#. Go to *Sales > Sales > Customers* and choose a partner. |
|||
#. Go to the new *Images* tab. |
|||
#. Add a new image. |
|||
#. Refresh the page. |
|||
#. The first image in the collection is the main image for the partner. |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/135/9.0 |
|||
|
|||
Known issues / Roadmap |
|||
====================== |
|||
|
|||
* If you try to sort images before saving the partner, you will get an error |
|||
similar to ``DataError: invalid input syntax for integer: |
|||
"one2many_v_id_62"``. This bug has not been fixed yet, but a workaround is |
|||
to save and edit again to sort images. |
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues |
|||
<https://github.com/OCA/partner-contact/issues>`_. In case of trouble, please |
|||
check there if your issue has already been reported. If you spotted it first, |
|||
help us smash it by providing detailed and welcomed feedback. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Images |
|||
------ |
|||
|
|||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
|||
|
|||
Original implementation |
|||
----------------------- |
|||
This module is inspired in previous module *product_images* from OpenLabs |
|||
and Akretion. |
|||
|
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Sharoon Thomas |
|||
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> |
|||
* Rafael Blasco <rafabn@antiun.com> |
|||
* Jairo Llopis <yajo.sk8@gmail.com> |
|||
* Sodexis <dev@sodexis.com> |
|||
* Sergio Teruel <sergio.teruel@tecnativa.com> |
|||
|
|||
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. |
@ -0,0 +1,10 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009 Sharoon Thomas Open Labs Business Solutions |
|||
# Copyright 2014 Tecnativa - Pedro M. Baeza |
|||
# Copyright 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# Copyright 2016 Sodexis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import models |
|||
from .hooks import pre_init_hook |
|||
from .hooks import uninstall_hook |
@ -0,0 +1,27 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009 Sharoon Thomas Open Labs Business Solutions |
|||
# Copyright 2014 Tecnativa - Pedro M. Baeza |
|||
# Copyright 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# Copyright 2016 Sodexis |
|||
# Copyright 2017 Tecnativa - Sergio Teruel |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
{ |
|||
"name": "Multiple Images in Partners", |
|||
"version": "9.0.1.0.0", |
|||
"author": "Tecnativa, " |
|||
"Odoo Community Association (OCA)", |
|||
"license": "AGPL-3", |
|||
"website": "https://www.tecnativa.com", |
|||
"category": "Customer Relationship Management", |
|||
"pre_init_hook": "pre_init_hook", |
|||
"uninstall_hook": "uninstall_hook", |
|||
"depends": [ |
|||
"base", |
|||
"base_multi_image", |
|||
], |
|||
"data": [ |
|||
'views/res_partner_view.xml', |
|||
], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,18 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009 Sharoon Thomas Open Labs Business Solutions |
|||
# Copyright 2014 Tecnativa Pedro M. Baeza |
|||
# Copyright 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# Copyright 2016 Sodexis |
|||
# Copyright 2017 Tecnativa - Sergio Teruel |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openerp.addons.base_multi_image.hooks import pre_init_hook_for_submodules |
|||
from openerp.addons.base_multi_image.hooks import uninstall_hook_for_submodules |
|||
|
|||
|
|||
def pre_init_hook(cr): |
|||
pre_init_hook_for_submodules(cr, "res.partner", "image") |
|||
|
|||
|
|||
def uninstall_hook(cr, registry): # pragma: no cover |
|||
uninstall_hook_for_submodules(cr, registry, "res.partner") |
@ -0,0 +1,9 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009 Sharoon Thomas Open Labs Business Solutions |
|||
# Copyright 2014 Tecnativa - Pedro M. Baeza |
|||
# Copyright 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# Copyright 2016 Sodexis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import res_partner |
|||
|
@ -0,0 +1,31 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2009 Sharoon Thomas Open Labs Business Solutions |
|||
# Copyright 2014 Tecnativa - Pedro M. Baeza |
|||
# Copyright 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# Copyright 2016 Sodexis |
|||
# Copyright 2017 Tecnativa - Sergio Teruel |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
"""Reference core image fields to multi-image variants.""" |
|||
|
|||
|
|||
from openerp import fields, models |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
|
|||
_name = "res.partner" |
|||
_inherit = [_name, "base_multi_image.owner"] |
|||
|
|||
image = fields.Binary( |
|||
related='image_main', |
|||
store=False, |
|||
) |
|||
image_medium = fields.Binary( |
|||
related='image_main_medium', |
|||
store=False, |
|||
) |
|||
image_small = fields.Binary( |
|||
related='image_main_small', |
|||
store=False, |
|||
) |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from . import test_res_partner |
@ -0,0 +1,27 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com> |
|||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
|||
|
|||
from openerp.tests.common import TransactionCase |
|||
from openerp.modules import get_module_resource |
|||
|
|||
|
|||
class ResPartnerCase(TransactionCase): |
|||
def setUp(self): |
|||
super(ResPartnerCase, self).setUp() |
|||
self.partner = self.env["res.partner"].create({ |
|||
"name": "somebody", |
|||
}) |
|||
|
|||
def tearDown(self): |
|||
"""Remove stored images.""" |
|||
self.partner.image = False |
|||
return super(ResPartnerCase, self).tearDown() |
|||
|
|||
def test_set_image(self): |
|||
"""Image is OK.""" |
|||
path = get_module_resource( |
|||
"partner_multi_image", "static/description", "icon.png") |
|||
with open(path, "rb") as image: |
|||
self.partner.image = image.read().encode("base64") |
|||
self.assertIsNot(self.partner.image, False) |
@ -0,0 +1,27 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!-- |
|||
Copyright 2009 Sharoon Thomas Open Labs |
|||
Copyright 2014 Tecnativa - Pedro M. Baeza |
|||
Copyright 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
Copyright 2016 Sodexis |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
--> |
|||
<odoo> |
|||
|
|||
<record id="view_partner_form_img_inh" model="ir.ui.view"> |
|||
<field name="name">Add multi images</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="/form/sheet/notebook" position="inside"> |
|||
<page string="Images" name="multi_image"> |
|||
<field name="image_ids" nolabel="1" context="{ |
|||
'default_owner_model': 'res.partner', |
|||
'default_owner_id': id, |
|||
}" mode="kanban"/> |
|||
</page> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue