Browse Source

[MIG] partner_academic_title: Migration to 11.0

pull/719/head
Luis M. Ontalba 6 years ago
parent
commit
8d0defe24b
  1. 68
      partner_academic_title/README.rst
  2. 13
      partner_academic_title/__manifest__.py
  3. 94
      partner_academic_title/data/partner_academic_title_data.xml
  4. 19
      partner_academic_title/models/partner_academic_title.py
  5. 29
      partner_academic_title/models/res_partner.py
  6. 4
      partner_academic_title/readme/CONTRIBUTORS.rst
  7. 3
      partner_academic_title/readme/DESCRIPTION.rst
  8. 1
      partner_academic_title/tests/__init__.py
  9. 29
      partner_academic_title/tests/test_partner_academic_title.py
  10. 74
      partner_academic_title/views/partner_academic_title_view.xml
  11. 31
      partner_academic_title/views/res_partner_view.xml

68
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 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 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 to add multiple titles on partners. there is a sequence on titles to display
them in an order on the partner. them in an order on the partner.
**Table of contents**
.. contents::
:local:
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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_academic_title%0Aversion:%2011.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.
Credits Credits
======= =======
Authors
~~~~~~~
* ACSONE SA/NV
Contributors Contributors
------------
~~~~~~~~~~~~
* Stéphane Bidoul <stephane.bidoul@acsone.eu> * Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Adrien Peiffer <adrien.peiffer@acsone.eu> * Adrien Peiffer <adrien.peiffer@acsone.eu>
* Meyomesse Gilles <meyomesse.gilles@gmail.com> * Meyomesse Gilles <meyomesse.gilles@gmail.com>
* Luis M. Ontalba <luismaront@gmail.com>
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 :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 <https://github.com/OCA/partner-contact/tree/11.0/partner_academic_title>`_ project on GitHub.
To contribute to this module, please visit http://odoo-community.org.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

13
partner_academic_title/__manifest__.py

@ -1,18 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2015-2017 ACSONE SA/NV (<https://acsone.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
'name': "Partner Academic Title", 'name': "Partner Academic Title",
'summary': """ 'summary': """
Add possibility to define some academic title""", Add possibility to define some academic title""",
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)', 'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
'website': "http://acsone.eu",
'website': "https://github.com/OCA/partner-contact",
'category': 'Other', 'category': 'Other',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': [ 'depends': [
'hr',
'partner_contact_configuration',
'contacts',
], ],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
@ -20,4 +18,5 @@
'views/partner_academic_title_view.xml', 'views/partner_academic_title_view.xml',
'views/res_partner_view.xml', 'views/res_partner_view.xml',
], ],
'installable': True,
} }

94
partner_academic_title/data/partner_academic_title_data.xml

@ -1,51 +1,49 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015-2017 ACSONE SA/NV <!-- Copyright 2015-2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<data noupdate="1">
<record id="academic_title_bs" model="partner.academic.title">
<field name="name">B.S.</field>
<field name="sequence">1</field>
</record>
<record id="academic_title_ms" model="partner.academic.title">
<field name="name">M.S.</field>
<field name="sequence">2</field>
</record>
<record id="academic_title_mph" model="partner.academic.title">
<field name="name">M.P.H.</field>
<field name="sequence">3</field>
</record>
<record id="academic_title_mba" model="partner.academic.title">
<field name="name">M.B.A.</field>
<field name="sequence">4</field>
</record>
<record id="academic_title_md" model="partner.academic.title">
<field name="name">M.D.</field>
<field name="sequence">5</field>
</record>
<record id="academic_title_phd" model="partner.academic.title">
<field name="name">Ph.D.</field>
<field name="sequence">6</field>
</record>
<record id="academic_title_edd" model="partner.academic.title">
<field name="name">Ed.D</field>
<field name="sequence">7</field>
</record>
<record id="academic_title_psyd" model="partner.academic.title">
<field name="name">Psy.D.</field>
<field name="sequence">8</field>
</record>
<record id="academic_title_thd" model="partner.academic.title">
<field name="name">Th.D.</field>
<field name="sequence">9</field>
</record>
<record id="academic_title_pharmd" model="partner.academic.title">
<field name="name">Pharm.D.</field>
<field name="sequence">10</field>
</record>
<record id="academic_title_jd" model="partner.academic.title">
<field name="name">J.D.</field>
<field name="sequence">11</field>
</record>
</data>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record id="academic_title_bs" model="partner.academic.title">
<field name="name">B.S.</field>
<field name="sequence">1</field>
</record>
<record id="academic_title_ms" model="partner.academic.title">
<field name="name">M.S.</field>
<field name="sequence">2</field>
</record>
<record id="academic_title_mph" model="partner.academic.title">
<field name="name">M.P.H.</field>
<field name="sequence">3</field>
</record>
<record id="academic_title_mba" model="partner.academic.title">
<field name="name">M.B.A.</field>
<field name="sequence">4</field>
</record>
<record id="academic_title_md" model="partner.academic.title">
<field name="name">M.D.</field>
<field name="sequence">5</field>
</record>
<record id="academic_title_phd" model="partner.academic.title">
<field name="name">Ph.D.</field>
<field name="sequence">6</field>
</record>
<record id="academic_title_edd" model="partner.academic.title">
<field name="name">Ed.D</field>
<field name="sequence">7</field>
</record>
<record id="academic_title_psyd" model="partner.academic.title">
<field name="name">Psy.D.</field>
<field name="sequence">8</field>
</record>
<record id="academic_title_thd" model="partner.academic.title">
<field name="name">Th.D.</field>
<field name="sequence">9</field>
</record>
<record id="academic_title_pharmd" model="partner.academic.title">
<field name="name">Pharm.D.</field>
<field name="sequence">10</field>
</record>
<record id="academic_title_jd" model="partner.academic.title">
<field name="name">J.D.</field>
<field name="sequence">11</field>
</record>
</odoo> </odoo>

19
partner_academic_title/models/partner_academic_title.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2015-2017 ACSONE SA/NV (<https://acsone.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields from odoo import models, fields
@ -8,10 +7,12 @@ from odoo import models, fields
class PartnerAcademicTitle(models.Model): class PartnerAcademicTitle(models.Model):
_name = 'partner.academic.title' _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) active = fields.Boolean(default=True)

29
partner_academic_title/models/res_partner.py

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2015-2017 ACSONE SA/NV (<https://acsone.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api from odoo import models, fields, api
@ -11,19 +10,17 @@ class ResPartner(models.Model):
def _get_separator(self): def _get_separator(self):
return ', ' return ', '
@api.multi
@api.depends('academic_title_ids', 'academic_title_ids.sequence') @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( academic_title_ids = fields.Many2many(
string='Academic Titles', string='Academic Titles',
@ -34,6 +31,6 @@ class ResPartner(models.Model):
) )
academic_title_display = fields.Char( academic_title_display = fields.Char(
string='Academic Titles', string='Academic Titles',
compute='_get_academic_title_display',
compute='_compute_academic_title_display',
store=True store=True
) )

4
partner_academic_title/readme/CONTRIBUTORS.rst

@ -0,0 +1,4 @@
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Adrien Peiffer <adrien.peiffer@acsone.eu>
* Meyomesse Gilles <meyomesse.gilles@gmail.com>
* Luis M. Ontalba <luismaront@gmail.com>

3
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.

1
partner_academic_title/tests/__init__.py

@ -0,0 +1 @@
from . import test_partner_academic_title

29
partner_academic_title/tests/test_partner_academic_title.py

@ -0,0 +1,29 @@
# Copyright 2019 Luis M. Ontalba <luismaront@gmail.com>
# 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")

74
partner_academic_title/views/partner_academic_title_view.xml

@ -1,43 +1,39 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015-2017 ACSONE SA/NV <!-- Copyright 2015-2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<data>
<record id="view_academic_title_form" model="ir.ui.view">
<field name="name">partner.academic.title.form</field>
<field name="model">partner.academic.title</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
<field name="sequence" />
<field name="active" />
</group>
</sheet>
</form>
</field>
</record>
<record id="view_academic_title_tree" model="ir.ui.view">
<field name="name">partner.academic.title.tree</field>
<field name="model">partner.academic.title</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="sequence"/>
<field name="name" />
</tree>
</field>
</record>
<record id="open_academic_title" model="ir.actions.act_window">
<field name="name">Academic Titles</field>
<field name="res_model">partner.academic.title</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!-- this menu his managed in partner_contact_configuration (visible if your are in group_system)
group_system is activate in developper mode
-->
<menuitem id="menu_academic_title" name="Academic Titles" parent="partner_contact_configuration.menu_config_contacts" groups="base.group_no_one" action="open_academic_title" sequence="4"/>
</data>
<record id="view_academic_title_form" model="ir.ui.view">
<field name="name">partner.academic.title.form</field>
<field name="model">partner.academic.title</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
<field name="sequence" />
<field name="active" />
</group>
</sheet>
</form>
</field>
</record>
<record id="view_academic_title_tree" model="ir.ui.view">
<field name="name">partner.academic.title.tree</field>
<field name="model">partner.academic.title</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="sequence"/>
<field name="name" />
</tree>
</field>
</record>
<record id="open_academic_title" model="ir.actions.act_window">
<field name="name">Academic Titles</field>
<field name="res_model">partner.academic.title</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_academic_title" name="Academic Titles"
parent="contacts.res_partner_menu_config"
action="open_academic_title" sequence="3"/>
</odoo> </odoo>

31
partner_academic_title/views/res_partner_view.xml

@ -1,18 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015-2017 ACSONE SA/NV <!-- Copyright 2015-2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.form (partner_academic_title)</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='title']" position="after">
<field name="academic_title_ids" class="oe_edit_only" widget="many2many_tags" placeholder="Academic Titles" attrs="{'invisible': [('is_company', '=', True)]}"/>
<field name="academic_title_display" class="oe_read_only" attrs="{'invisible': [('is_company', '=', True)]}" />
</xpath>
</field>
</record>
</data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.form (partner_academic_title)</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='title']" position="after">
<label for="academic_title_ids" class="oe_edit_only"/>
<field name="academic_title_ids" widget="many2many_tags"
placeholder="Academic Titles" nolabel="1" class="oe_edit_only"
attrs="{'invisible': [('is_company', '=', True)]}" />
<label for="academic_title_display" class="oe_read_only"/>
<field name="academic_title_display" nolabel="1" class="oe_read_only"
attrs="{'invisible': [('is_company', '=', True)]}" />
</xpath>
</field>
</record>
</odoo> </odoo>
Loading…
Cancel
Save