diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 2c2cd8f80..80b6275e5 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -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 diff --git a/partner_multi_image/README.rst b/partner_multi_image/README.rst new file mode 100644 index 000000000..2b0b5020a --- /dev/null +++ b/partner_multi_image/README.rst @@ -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 `_. + +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 +`_. 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 `_. + +Original implementation +----------------------- +This module is inspired in previous module *product_images* from OpenLabs +and Akretion. + + +Contributors +------------ + +* Sharoon Thomas +* Pedro M. Baeza +* Rafael Blasco +* Jairo Llopis +* Sodexis +* Sergio Teruel + +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. diff --git a/partner_multi_image/__init__.py b/partner_multi_image/__init__.py new file mode 100644 index 000000000..20bb2ff61 --- /dev/null +++ b/partner_multi_image/__init__.py @@ -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 diff --git a/partner_multi_image/__openerp__.py b/partner_multi_image/__openerp__.py new file mode 100644 index 000000000..256011512 --- /dev/null +++ b/partner_multi_image/__openerp__.py @@ -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, +} diff --git a/partner_multi_image/hooks.py b/partner_multi_image/hooks.py new file mode 100644 index 000000000..e4f304c1a --- /dev/null +++ b/partner_multi_image/hooks.py @@ -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") diff --git a/partner_multi_image/models/__init__.py b/partner_multi_image/models/__init__.py new file mode 100644 index 000000000..e6b1f3c7b --- /dev/null +++ b/partner_multi_image/models/__init__.py @@ -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 + diff --git a/partner_multi_image/models/res_partner.py b/partner_multi_image/models/res_partner.py new file mode 100644 index 000000000..0947ece1b --- /dev/null +++ b/partner_multi_image/models/res_partner.py @@ -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, + ) diff --git a/partner_multi_image/static/description/icon.png b/partner_multi_image/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_multi_image/static/description/icon.png differ diff --git a/partner_multi_image/tests/__init__.py b/partner_multi_image/tests/__init__.py new file mode 100644 index 000000000..ffb7d8e1d --- /dev/null +++ b/partner_multi_image/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Jairo Llopis +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from . import test_res_partner diff --git a/partner_multi_image/tests/test_res_partner.py b/partner_multi_image/tests/test_res_partner.py new file mode 100644 index 000000000..e132e3f90 --- /dev/null +++ b/partner_multi_image/tests/test_res_partner.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Jairo Llopis +# 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) diff --git a/partner_multi_image/views/res_partner_view.xml b/partner_multi_image/views/res_partner_view.xml new file mode 100644 index 000000000..2743ddf65 --- /dev/null +++ b/partner_multi_image/views/res_partner_view.xml @@ -0,0 +1,27 @@ + + + + + + Add multi images + res.partner + + + + + + + + + + +