From 8d0defe24bceef9b2e0cf9789e178a26e43ef4d9 Mon Sep 17 00:00:00 2001 From: "Luis M. Ontalba" Date: Wed, 20 Mar 2019 13:36:43 +0100 Subject: [PATCH] [MIG] partner_academic_title: Migration to 11.0 --- partner_academic_title/README.rst | 68 +++++++++++--- partner_academic_title/__manifest__.py | 13 ++- .../data/partner_academic_title_data.xml | 94 +++++++++---------- .../models/partner_academic_title.py | 19 ++-- partner_academic_title/models/res_partner.py | 29 +++--- .../readme/CONTRIBUTORS.rst | 4 + partner_academic_title/readme/DESCRIPTION.rst | 3 + partner_academic_title/tests/__init__.py | 1 + .../tests/test_partner_academic_title.py | 29 ++++++ .../views/partner_academic_title_view.xml | 74 +++++++-------- .../views/res_partner_view.xml | 31 +++--- 11 files changed, 220 insertions(+), 145 deletions(-) create mode 100644 partner_academic_title/readme/CONTRIBUTORS.rst create mode 100644 partner_academic_title/readme/DESCRIPTION.rst create mode 100644 partner_academic_title/tests/__init__.py create mode 100644 partner_academic_title/tests/test_partner_academic_title.py diff --git a/partner_academic_title/README.rst b/partner_academic_title/README.rst index 5cdf52680..b1ebd28b2 100644 --- a/partner_academic_title/README.rst +++ b/partner_academic_title/README.rst @@ -1,34 +1,78 @@ -.. 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 - ====================== Partner Academic Title ====================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-OCA%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/11.0/partner_academic_title + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-11-0/partner-contact-11-0-partner_academic_title + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + This module was written to adds possibility to define some academic titles and to add multiple titles on partners. there is a sequence on titles to display them in an order on the partner. +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + Credits ======= +Authors +~~~~~~~ + +* ACSONE SA/NV + Contributors ------------- +~~~~~~~~~~~~ * Stéphane Bidoul * Adrien Peiffer * Meyomesse Gilles +* Luis M. Ontalba + +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. -.. image:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :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. -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/partner-contact `_ project on GitHub. -To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_academic_title/__manifest__.py b/partner_academic_title/__manifest__.py index fc742a08f..57a40630a 100644 --- a/partner_academic_title/__manifest__.py +++ b/partner_academic_title/__manifest__.py @@ -1,18 +1,16 @@ -# -*- coding: utf-8 -*- -# Copyright 2015-2017 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2015-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name': "Partner Academic Title", 'summary': """ Add possibility to define some academic title""", 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', - 'website': "http://acsone.eu", + 'website': "https://github.com/OCA/partner-contact", 'category': 'Other', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'license': 'AGPL-3', 'depends': [ - 'hr', - 'partner_contact_configuration', + 'contacts', ], 'data': [ 'security/ir.model.access.csv', @@ -20,4 +18,5 @@ 'views/partner_academic_title_view.xml', 'views/res_partner_view.xml', ], + 'installable': True, } diff --git a/partner_academic_title/data/partner_academic_title_data.xml b/partner_academic_title/data/partner_academic_title_data.xml index c84583192..52a6ffb1f 100644 --- a/partner_academic_title/data/partner_academic_title_data.xml +++ b/partner_academic_title/data/partner_academic_title_data.xml @@ -1,51 +1,49 @@ - - - - B.S. - 1 - - - M.S. - 2 - - - M.P.H. - 3 - - - M.B.A. - 4 - - - M.D. - 5 - - - Ph.D. - 6 - - - Ed.D - 7 - - - Psy.D. - 8 - - - Th.D. - 9 - - - Pharm.D. - 10 - - - J.D. - 11 - - + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> + + + B.S. + 1 + + + M.S. + 2 + + + M.P.H. + 3 + + + M.B.A. + 4 + + + M.D. + 5 + + + Ph.D. + 6 + + + Ed.D + 7 + + + Psy.D. + 8 + + + Th.D. + 9 + + + Pharm.D. + 10 + + + J.D. + 11 + diff --git a/partner_academic_title/models/partner_academic_title.py b/partner_academic_title/models/partner_academic_title.py index 3e4ba6a2a..302e9608f 100644 --- a/partner_academic_title/models/partner_academic_title.py +++ b/partner_academic_title/models/partner_academic_title.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -# Copyright 2015-2017 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2015-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import models, fields @@ -8,10 +7,12 @@ from odoo import models, fields class PartnerAcademicTitle(models.Model): _name = 'partner.academic.title' - name = fields.Char(required=True, - translate=True - ) - sequence = fields.Integer(required=True, - help="""defines the order to display titles""" - ) + name = fields.Char( + required=True, + translate=True + ) + sequence = fields.Integer( + required=True, + help="""defines the order to display titles""" + ) active = fields.Boolean(default=True) diff --git a/partner_academic_title/models/res_partner.py b/partner_academic_title/models/res_partner.py index 4e5646dc5..9f0087584 100644 --- a/partner_academic_title/models/res_partner.py +++ b/partner_academic_title/models/res_partner.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -# Copyright 2015-2017 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2015-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import models, fields, api @@ -11,19 +10,17 @@ class ResPartner(models.Model): def _get_separator(self): return ', ' + @api.multi @api.depends('academic_title_ids', 'academic_title_ids.sequence') - @api.one - def _get_academic_title_display(self): - display_title = "" - separator = self._get_separator() - title_ids = self.academic_title_ids.sorted(lambda r: r.sequence) - for title in title_ids: - if display_title: - display_title = "%s%s%s" % (display_title, separator, - title.name) - else: - display_title = "%s" % (title.name) - self.academic_title_display = display_title + def _compute_academic_title_display(self): + for this in self: + display_title = "" + separator = this._get_separator() + title_ids = this.academic_title_ids.sorted(lambda r: r.sequence) + if title_ids: + display_title = separator.join( + [title.name for title in title_ids]) + this.academic_title_display = display_title academic_title_ids = fields.Many2many( string='Academic Titles', @@ -34,6 +31,6 @@ class ResPartner(models.Model): ) academic_title_display = fields.Char( string='Academic Titles', - compute='_get_academic_title_display', + compute='_compute_academic_title_display', store=True ) diff --git a/partner_academic_title/readme/CONTRIBUTORS.rst b/partner_academic_title/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..6306df88f --- /dev/null +++ b/partner_academic_title/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Stéphane Bidoul +* Adrien Peiffer +* Meyomesse Gilles +* Luis M. Ontalba diff --git a/partner_academic_title/readme/DESCRIPTION.rst b/partner_academic_title/readme/DESCRIPTION.rst new file mode 100644 index 000000000..18f2a6941 --- /dev/null +++ b/partner_academic_title/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module was written to adds possibility to define some academic titles and +to add multiple titles on partners. there is a sequence on titles to display +them in an order on the partner. diff --git a/partner_academic_title/tests/__init__.py b/partner_academic_title/tests/__init__.py new file mode 100644 index 000000000..0228abfa8 --- /dev/null +++ b/partner_academic_title/tests/__init__.py @@ -0,0 +1 @@ +from . import test_partner_academic_title diff --git a/partner_academic_title/tests/test_partner_academic_title.py b/partner_academic_title/tests/test_partner_academic_title.py new file mode 100644 index 000000000..4db2901ff --- /dev/null +++ b/partner_academic_title/tests/test_partner_academic_title.py @@ -0,0 +1,29 @@ +# Copyright 2019 Luis M. Ontalba +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from odoo.tests import common + + +class TestPartnerAcademicTitle(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestPartnerAcademicTitle, cls).setUpClass() + cls.partner_ac_tit_A = cls.env['partner.academic.title'].create({ + 'name': 'A', + 'sequence': 2, + }) + cls.partner_ac_tit_B = cls.env['partner.academic.title'].create({ + 'name': 'B', + 'sequence': 1, + }) + cls.partner = cls.env['res.partner'].create({ + 'name': 'Test partner', + }) + + def test_compute_academic_title_display(self): + partner = self.partner + partner.academic_title_ids = [ + (4, self.partner_ac_tit_A.id, 0), + (4, self.partner_ac_tit_B.id, 0), + ] + self.assertEqual(partner.academic_title_display, "B, A") diff --git a/partner_academic_title/views/partner_academic_title_view.xml b/partner_academic_title/views/partner_academic_title_view.xml index 355f5350e..283734d01 100644 --- a/partner_academic_title/views/partner_academic_title_view.xml +++ b/partner_academic_title/views/partner_academic_title_view.xml @@ -1,43 +1,39 @@ + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - - - partner.academic.title.form - partner.academic.title - -
- - - - - - - -
-
-
- - - partner.academic.title.tree - partner.academic.title - - - - - - - - - Academic Titles - partner.academic.title - form - tree,form - - - -
+ + partner.academic.title.form + partner.academic.title + +
+ + + + + + + +
+
+
+ + partner.academic.title.tree + partner.academic.title + + + + + + + + + Academic Titles + partner.academic.title + form + tree,form + +
diff --git a/partner_academic_title/views/res_partner_view.xml b/partner_academic_title/views/res_partner_view.xml index b90c42fd0..3c444bbd7 100644 --- a/partner_academic_title/views/res_partner_view.xml +++ b/partner_academic_title/views/res_partner_view.xml @@ -1,18 +1,21 @@ + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> - - - res.partner.form (partner_academic_title) - res.partner - - - - - - - - - + + res.partner.form (partner_academic_title) + res.partner + + + + + +