Browse Source

migration to 11.0

pull/495/head
Jordi Ballester 7 years ago
parent
commit
a48e13c663
  1. 2
      partner_second_lastname/README.rst
  2. 4
      partner_second_lastname/__manifest__.py
  3. 2
      partner_second_lastname/models/__init__.py
  4. 6
      partner_second_lastname/models/res_config_settings.py
  5. 8
      partner_second_lastname/models/res_partner.py
  6. 8
      partner_second_lastname/tests/test_config.py
  7. 22
      partner_second_lastname/tests/test_name.py
  8. 40
      partner_second_lastname/tests/test_onchange.py

2
partner_second_lastname/README.rst

@ -53,7 +53,7 @@ you easily in some corner cases.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/10.0
:target: https://runbot.odoo-community.org/runbot/134/11.0
Known issues / Roadmap

4
partner_second_lastname/__manifest__.py

@ -2,12 +2,12 @@
# Copyright 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# Copyright 2017 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Partner second last name",
"summary": "Have split first and second lastnames",
"version": "10.0.1.0.0",
"version": "11.0.1.0.0",
"license": "AGPL-3",
"website": "https://www.tecnativa.com",
"author": "Tecnativa, "

2
partner_second_lastname/models/__init__.py

@ -2,5 +2,5 @@
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import base_config_settings
from . import res_config_settings
from . import res_partner

6
partner_second_lastname/models/base_config_settings.py → partner_second_lastname/models/res_config_settings.py

@ -5,12 +5,12 @@
from odoo import models, api
class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
def _partner_names_order_selection(self):
options = super(
BaseConfigSettings, self)._partner_names_order_selection()
ResConfigSettings, self)._partner_names_order_selection()
new_labels = {
'last_first': 'Lastname SecondLastname Firstname',
'last_first_comma': 'Lastname SecondLastname, Firstname',

8
partner_second_lastname/models/res_partner.py

@ -39,7 +39,7 @@ class ResPartner(models.Model):
names[-1] = names[-1] + ","
if firstname:
names.append(firstname)
return u" ".join(names)
return " ".join(names)
@api.depends("firstname", "lastname", "lastname2")
def _compute_name(self):
@ -55,11 +55,11 @@ class ResPartner(models.Model):
parts = self._get_inverse_name(self.name, self.is_company)
# Avoid to hit :meth:`~._check_name` with all 3 fields being ``False``
before, after = {}, {}
for key, value in parts.iteritems():
for key, value in parts.items():
(before if value else after)[key] = value
if any([before[k] != self[k] for k in before.keys()]):
if any([before[k] != self[k] for k in list(before.keys())]):
self.update(before)
if any([after[k] != self[k] for k in after.keys()]):
if any([after[k] != self[k] for k in list(after.keys())]):
self.update(after)
@api.model

8
partner_second_lastname/tests/test_config.py

@ -9,7 +9,7 @@ class TestConfig(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestConfig, cls).setUpClass()
cls.wizard = cls.env['base.config.settings'].create({})
cls.wizard = cls.env['res.config.settings'].create({})
cls.partner = cls.env['res.partner'].create({
'firstname': "First",
'lastname': "Last",
@ -18,18 +18,18 @@ class TestConfig(common.SavepointCase):
def test_last_first(self):
self.wizard.partner_names_order = 'last_first'
self.wizard.set_partner_names_order()
self.wizard.set_values()
self.wizard.action_recalculate_partners_name()
self.assertEqual(self.partner.name, "Last Second First")
def test_last_first_comma(self):
self.wizard.partner_names_order = 'last_first_comma'
self.wizard.set_partner_names_order()
self.wizard.set_values()
self.wizard.action_recalculate_partners_name()
self.assertEqual(self.partner.name, "Last Second, First")
def test_first_last(self):
self.wizard.partner_names_order = 'first_last'
self.wizard.set_partner_names_order()
self.wizard.set_values()
self.wizard.action_recalculate_partners_name()
self.assertEqual(self.partner.name, "First Last Second")

22
partner_second_lastname/tests/test_name.py

@ -22,7 +22,7 @@ class CompanyCase(TransactionCase):
})
# Name should be cleaned of unneeded whitespace
clean_name = u" ".join(self.name.split(None))
clean_name = " ".join(self.name.split(None))
# Check it's saved OK
self.assertEqual(
@ -51,27 +51,27 @@ class CompanyCase(TransactionCase):
def test_long_name(self):
"""Create a company with a long name."""
self.name = u"Söme very lóng nâme"
self.name = "Söme very lóng nâme"
def test_short_name(self):
"""Create a company with a short name."""
self.name = u"Shoŕt"
self.name = "Shoŕt"
def test_whitespace_before(self):
"""Create a company with name prefixed with whitespace."""
self.name = u" Wĥitespace befòre"
self.name = " Wĥitespace befòre"
def test_whitespace_after(self):
"""Create a company with name suffixed with whitespace."""
self.name = u"Whitespâce aftér "
self.name = "Whitespâce aftér "
def test_whitespace_inside(self):
"""Create a company with whitespace inside the name."""
self.name = u"Whitespacé ïnside"
self.name = "Whitespacé ïnside"
def test_whitespace_everywhere(self):
"""Create a company with whitespace everywhere in the name."""
self.name = u" A lot öf whitespace "
self.name = " A lot öf whitespace "
class PersonCase(TransactionCase):
@ -84,10 +84,10 @@ class PersonCase(TransactionCase):
self.env['ir.config_parameter'].set_param(
'partner_names_order', 'last_first_comma')
self.firstname = u"Fírstname"
self.lastname = u"Làstname1"
self.lastname2 = u"Lâstname2"
self.template = u"%(last1)s %(last2)s, %(first)s"
self.firstname = "Fírstname"
self.lastname = "Làstname1"
self.lastname2 = "Lâstname2"
self.template = "%(last1)s %(last2)s, %(first)s"
def tearDown(self):
try:

40
partner_second_lastname/tests/test_onchange.py

@ -46,7 +46,7 @@ class PartnerCompanyCase(OnChangeCase):
def test_create_from_form(self):
"""A user creates a company from the form."""
name = u"Sôme company"
name = "Sôme company"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -66,8 +66,8 @@ class PartnerCompanyCase(OnChangeCase):
self.partner = self.new_partner()
# User changes fields
self.set_name(u"Fóo")
self.set_name(u"")
self.set_name("Fóo")
self.set_name("")
self.assertEqual(self.partner.lastname, False)
@ -107,11 +107,11 @@ class PartnerContactCase(OnChangeCase):
self.assertEqual(self.partner.lastname2, False)
# ``name`` cannot be False, or upstream Odoo will fail
self.assertEqual(self.partner.name, u"")
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 = u"Fïrst"
firstname = "Fïrst"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -125,7 +125,7 @@ class PartnerContactCase(OnChangeCase):
def test_create_from_form_only_lastname(self):
"""A user creates a contact with only the lastname from the form."""
lastname = u"Läst"
lastname = "Läst"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -139,7 +139,7 @@ class PartnerContactCase(OnChangeCase):
def test_create_from_form_only_lastname2(self):
"""A user creates a contact with only the lastname2 from the form."""
lastname2 = u"Läst2"
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -153,8 +153,8 @@ class PartnerContactCase(OnChangeCase):
def test_create_from_without_firstname(self):
"""A user creates a contact without firstname from the form."""
lastname = u"Läst"
lastname2 = u"Läst2"
lastname = "Läst"
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -166,12 +166,12 @@ class PartnerContactCase(OnChangeCase):
self.assertEqual(self.partner.firstname, False)
self.assertEqual(
self.partner.name,
u"%s %s" % (lastname, lastname2))
"%s %s" % (lastname, lastname2))
def test_create_from_without_lastname(self):
"""A user creates a contact without lastname from the form."""
firstname = u"Fïrst"
lastname2 = u"Läst2"
firstname = "Fïrst"
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -183,12 +183,12 @@ class PartnerContactCase(OnChangeCase):
self.assertEqual(self.partner.lastname, False)
self.assertEqual(
self.partner.name,
u"%s, %s" % (lastname2, firstname))
"%s, %s" % (lastname2, firstname))
def test_create_from_without_lastname2(self):
"""A user creates a contact without lastname2 from the form."""
firstname = u"Fïrst"
lastname = u"Läst"
firstname = "Fïrst"
lastname = "Läst"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -200,13 +200,13 @@ class PartnerContactCase(OnChangeCase):
self.assertEqual(self.partner.lastname2, False)
self.assertEqual(
self.partner.name,
u"%s, %s" % (lastname, firstname))
"%s, %s" % (lastname, firstname))
def test_create_from_form_all(self):
"""A user creates a contact with all names from the form."""
firstname = u"Fïrst"
lastname = u"Läst"
lastname2 = u"Läst2"
firstname = "Fïrst"
lastname = "Läst"
lastname2 = "Läst2"
with self.env.do_in_onchange():
# User presses ``new``
self.partner = self.new_partner()
@ -218,4 +218,4 @@ class PartnerContactCase(OnChangeCase):
self.assertEqual(
self.partner.name,
u"%s %s, %s" % (lastname, lastname2, firstname))
"%s %s, %s" % (lastname, lastname2, firstname))
Loading…
Cancel
Save