Browse Source

[MIG] partner_second_lastname: Migration to 13.0

14.0
emagdalena 4 years ago
committed by Luis Torres
parent
commit
d2a3a5a01d
  1. 10
      partner_second_lastname/README.rst
  2. 6
      partner_second_lastname/__manifest__.py
  3. 1
      partner_second_lastname/i18n/es.po
  4. 1
      partner_second_lastname/i18n/fr.po
  5. 1
      partner_second_lastname/i18n/nl_NL.po
  6. 7
      partner_second_lastname/i18n/partner_second_lastname.pot
  7. 3
      partner_second_lastname/models/res_config_settings.py
  8. 6
      partner_second_lastname/models/res_partner.py
  9. 6
      partner_second_lastname/static/description/index.html
  10. 1
      partner_second_lastname/tests/__init__.py
  11. 2
      partner_second_lastname/tests/test_config.py
  12. 2
      partner_second_lastname/tests/test_name.py
  13. 215
      partner_second_lastname/tests/test_onchange.py

10
partner_second_lastname/README.rst

@ -14,13 +14,13 @@ Partner second last name
: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/12.0/partner_second_lastname
:target: https://github.com/OCA/partner-contact/tree/13.0/partner_second_lastname
: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-12-0/partner-contact-12-0-partner_second_lastname
:target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_second_lastname
: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/12.0
:target: https://runbot.odoo-community.org/runbot/134/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -80,7 +80,7 @@ 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_second_lastname%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_second_lastname%0Aversion:%2013.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.
@ -113,6 +113,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/partner-contact <https://github.com/OCA/partner-contact/tree/12.0/partner_second_lastname>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/13.0/partner_second_lastname>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

6
partner_second_lastname/__manifest__.py

@ -6,12 +6,12 @@
{
"name": "Partner second last name",
"summary": "Have split first and second lastnames",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"license": "AGPL-3",
"website": "https://github.com/OCA/partner-contact",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"category": "Partner Management",
"depends": ["partner_firstname",],
"data": ["views/res_partner.xml", "views/res_user.xml",],
"depends": ["partner_firstname"],
"data": ["views/res_partner.xml", "views/res_user.xml"],
"installable": True,
}

1
partner_second_lastname/i18n/es.po

@ -21,7 +21,6 @@ msgstr ""
#. module: partner_second_lastname
#: model:ir.model,name:partner_second_lastname.model_res_config_settings
#, fuzzy
#| msgid "res.config.settings"
msgid "Config Settings"
msgstr "res.config.settings"

1
partner_second_lastname/i18n/fr.po

@ -22,7 +22,6 @@ msgstr ""
#. module: partner_second_lastname
#: model:ir.model,name:partner_second_lastname.model_res_config_settings
#, fuzzy
#| msgid "res.config.settings"
msgid "Config Settings"
msgstr "res.config.settings"

1
partner_second_lastname/i18n/nl_NL.po

@ -22,7 +22,6 @@ msgstr ""
#. module: partner_second_lastname
#: model:ir.model,name:partner_second_lastname.model_res_config_settings
#, fuzzy
#| msgid "res.config.settings"
msgid "Config Settings"
msgstr "res.config.settings"

7
partner_second_lastname/i18n/partner_second_lastname.pot

@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_second_lastname
# * partner_second_lastname
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -28,4 +28,3 @@ msgstr ""
#: model:ir.model.fields,field_description:partner_second_lastname.field_res_users__lastname2
msgid "Second last name"
msgstr ""

3
partner_second_lastname/models/res_config_settings.py

@ -1,7 +1,7 @@
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
from odoo import models
class ResConfigSettings(models.TransientModel):
@ -16,7 +16,6 @@ class ResConfigSettings(models.TransientModel):
}
return [(k, new_labels[k]) if k in new_labels else (k, v) for k, v in options]
@api.multi
def _partners_for_recalculating(self):
return self.env["res.partner"].search(
[

6
partner_second_lastname/models/res_partner.py

@ -50,7 +50,6 @@ class ResPartner(models.Model):
partner.lastname, partner.firstname, partner.lastname2,
)
@api.multi
def _inverse_name(self):
"""Try to revert the effect of :meth:`._compute_name`."""
self.ensure_one()
@ -106,8 +105,3 @@ class ResPartner(models.Model):
for partner in self:
if not partner.lastname2:
raise
@api.onchange("firstname", "lastname", "lastname2")
def _onchange_subnames(self):
"""Trigger onchange with :attr:`~.lastname2` too."""
super(ResPartner, self)._onchange_subnames()

6
partner_second_lastname/static/description/index.html

@ -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/partner-contact/tree/12.0/partner_second_lastname"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-partner_second_lastname"><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/134/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/partner-contact/tree/13.0/partner_second_lastname"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_second_lastname"><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/134/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module was written to extend the functionality of <tt class="docutils literal">partner_firstname</tt> to
support having a second lastname for contact partners.</p>
<p>In some countries, it’s important to have a second last name for contacts.</p>
@ -424,7 +424,7 @@ you easily in some corner cases.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/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/partner-contact/issues/new?body=module:%20partner_second_lastname%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/partner-contact/issues/new?body=module:%20partner_second_lastname%0Aversion:%2013.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">
@ -451,7 +451,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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/partner-contact/tree/12.0/partner_second_lastname">OCA/partner-contact</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/13.0/partner_second_lastname">OCA/partner-contact</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>

1
partner_second_lastname/tests/__init__.py

@ -1,6 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_name
from . import test_onchange
from . import test_config
from odoo.addons.partner_firstname.tests import test_empty

2
partner_second_lastname/tests/test_config.py

@ -10,7 +10,7 @@ class TestConfig(common.SavepointCase):
super(TestConfig, cls).setUpClass()
cls.wizard = cls.env["res.config.settings"].create({})
cls.partner = cls.env["res.partner"].create(
{"firstname": "First", "lastname": "Last", "lastname2": "Second",}
{"firstname": "First", "lastname": "Last", "lastname2": "Second"}
)
def test_last_first(self):

2
partner_second_lastname/tests/test_name.py

@ -17,7 +17,7 @@ class CompanyCase(TransactionCase):
def tearDown(self):
try:
new = self.env["res.partner"].create(
{"is_company": True, "name": self.name,}
{"is_company": True, "name": self.name}
)
# Name should be cleaned of unneeded whitespace

215
partner_second_lastname/tests/test_onchange.py

@ -1,215 +0,0 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U.
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
"""These tests try to mimic the behavior of the UI form.
The form operates in onchange mode, with its limitations.
"""
from odoo.tests.common import TransactionCase
class OnChangeCase(TransactionCase):
is_company = False
def setUp(self):
super(OnChangeCase, self).setUp()
self.env["ir.config_parameter"].set_param(
"partner_names_order", "last_first_comma"
)
def new_partner(self):
"""Create an empty partner. Ensure it is (or not) a company."""
new = self.env["res.partner"].new()
new.is_company = self.is_company
return new
class PartnerCompanyCase(OnChangeCase):
is_company = True
def tearDown(self):
"""Companies never have ``firstname`` nor ``lastname2``."""
super(PartnerCompanyCase, self).tearDown()
self.assertEqual(self.partner.firstname, False)
self.assertEqual(self.partner.lastname2, False)
def set_name(self, value):
self.partner.name = value
# It triggers onchange
self.partner._onchange_name()
# Ensure it's properly set
self.assertEqual(self.partner.name, value)
def test_create_from_form(self):
"""A user creates a company from the form."""
name = "Sôme company"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_name(name)
self.assertEqual(self.partner.lastname, name)
def test_empty_name_and_subnames(self):
"""If the user empties ``name``, subnames must be ``False``.
Otherwise, the ``required`` attr will not work as expected.
"""
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_name("Fóo")
self.set_name("")
self.assertEqual(self.partner.lastname, False)
class PartnerContactCase(OnChangeCase):
def set_field(self, field, value):
# Changes the field
setattr(self.partner, field, value)
if field in ("firstname", "lastname", "lastname2"):
# Trigger onchanges
self.partner._onchange_subnames()
self.partner._onchange_name()
# Check it's set OK
self.assertEqual(getattr(self.partner, field), value)
def test_create_from_form_empty(self):
"""A user creates a contact from the form.
All subfields must be false, or the ``required`` attr will not work as
expected.
"""
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# Odoo tries to compute the name
self.partner._compute_name()
# This is then triggered
self.partner._onchange_name()
# Subnames must start as False to make the UI work fine
self.assertEqual(self.partner.firstname, False)
self.assertEqual(self.partner.lastname, False)
self.assertEqual(self.partner.lastname2, False)
# ``name`` cannot be False, or upstream Odoo will fail
self.assertEqual(self.partner.name, "")
def test_create_from_form_only_firstname(self):
"""A user creates a contact with only the firstname from the form."""
firstname = "Fïrst"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_field("firstname", firstname)
self.assertEqual(self.partner.lastname, False)
self.assertEqual(self.partner.lastname2, False)
self.assertEqual(self.partner.name, firstname)
def test_create_from_form_only_lastname(self):
"""A user creates a contact with only the lastname from the form."""
lastname = "Läst"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_field("lastname", lastname)
self.assertEqual(self.partner.firstname, False)
self.assertEqual(self.partner.lastname2, False)
self.assertEqual(self.partner.name, lastname)
def test_create_from_form_only_lastname2(self):
"""A user creates a contact with only the lastname2 from the form."""
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_field("lastname2", lastname2)
self.assertEqual(self.partner.firstname, False)
self.assertEqual(self.partner.lastname, False)
self.assertEqual(self.partner.name, lastname2)
def test_create_from_without_firstname(self):
"""A user creates a contact without firstname from the form."""
lastname = "Läst"
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_field("lastname", lastname)
self.set_field("lastname2", lastname2)
self.assertEqual(self.partner.firstname, False)
self.assertEqual(self.partner.name, "{} {}".format(lastname, lastname2))
def test_create_from_without_lastname(self):
"""A user creates a contact without lastname from the form."""
firstname = "Fïrst"
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_field("firstname", firstname)
self.set_field("lastname2", lastname2)
self.assertEqual(self.partner.lastname, False)
self.assertEqual(self.partner.name, "{}, {}".format(lastname2, firstname))
def test_create_from_without_lastname2(self):
"""A user creates a contact without lastname2 from the form."""
firstname = "Fïrst"
lastname = "Läst"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_field("firstname", firstname)
self.set_field("lastname", lastname)
self.assertEqual(self.partner.lastname2, False)
self.assertEqual(self.partner.name, "{}, {}".format(lastname, firstname))
def test_create_from_form_all(self):
"""A user creates a contact with all names from the form."""
firstname = "Fïrst"
lastname = "Läst"
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
# User changes fields
self.set_field("firstname", firstname)
self.set_field("lastname", lastname)
self.set_field("lastname2", lastname2)
self.assertEqual(
self.partner.name, "{} {}, {}".format(lastname, lastname2, firstname)
)
Loading…
Cancel
Save