[tryton-debian-vcs] tryton-modules-party branch upstream updated. upstream/4.2.2-1-g049f417

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Tue Mar 14 12:08:54 UTC 2017


The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-party.git;a=commitdiff;h=upstream/4.2.2-1-g049f417

commit 049f417cf99f9e58b6f8aa9519e447b9fa3eef73
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Mar 14 10:41:03 2017 +0100

    Adding upstream version 4.2.3.
    
    Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>

diff --git a/CHANGELOG b/CHANGELOG
index f4d9fbe..1214b6b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 4.2.3 - 2017-03-10
+* Bug fixes (see mercurial logs for details)
+
 Version 4.2.2 - 2017-01-22
 * Bug fixes (see mercurial logs for details)
 
diff --git a/PKG-INFO b/PKG-INFO
index 6230b10..85859fa 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: trytond_party
-Version: 4.2.2
+Version: 4.2.3
 Summary: Tryton module with parties and addresses
 Home-page: http://www.tryton.org/
 Author: Tryton
diff --git a/contact_mechanism.py b/contact_mechanism.py
index 41f14e1..9ace6a6 100644
--- a/contact_mechanism.py
+++ b/contact_mechanism.py
@@ -30,6 +30,12 @@ _TYPES = [
     ('other', 'Other'),
 ]
 
+_PHONE_TYPES = {
+    'phone',
+    'mobile',
+    'fax',
+    }
+
 
 class ContactMechanism(sequence_ordered(), ModelSQL, ModelView):
     "Contact Mechanism"
@@ -136,7 +142,7 @@ class ContactMechanism(sequence_ordered(), ModelSQL, ModelView):
 
     @classmethod
     def format_value(cls, value=None, type_=None):
-        if phonenumbers and type_ == 'phone':
+        if phonenumbers and type_ in _PHONE_TYPES:
             try:
                 phonenumber = phonenumbers.parse(value)
             except NumberParseException:
@@ -148,7 +154,7 @@ class ContactMechanism(sequence_ordered(), ModelSQL, ModelView):
 
     @classmethod
     def format_value_compact(cls, value=None, type_=None):
-        if phonenumbers and type_ == 'phone':
+        if phonenumbers and type_ in _PHONE_TYPES:
             try:
                 phonenumber = phonenumbers.parse(value)
             except NumberParseException:
@@ -247,7 +253,7 @@ class ContactMechanism(sequence_ordered(), ModelSQL, ModelView):
             mechanism.check_valid_phonenumber()
 
     def check_valid_phonenumber(self):
-        if not phonenumbers:
+        if not phonenumbers or self.type not in _PHONE_TYPES:
             return
         try:
             phonenumbers.parse(self.value)
diff --git a/tests/test_party.py b/tests/test_party.py
index 0e1111b..5db1866 100644
--- a/tests/test_party.py
+++ b/tests/test_party.py
@@ -12,6 +12,7 @@ from trytond.tests.test_tryton import ModuleTestCase, with_transaction
 from trytond.tests.test_tryton import doctest_teardown
 from trytond.tests.test_tryton import doctest_checker
 from trytond.pool import Pool
+from trytond.exceptions import UserError
 from trytond.transaction import Transaction
 
 
@@ -132,17 +133,20 @@ class PartyTestCase(ModuleTestCase):
         pool = Pool()
         Party = pool.get('party.party')
         ContactMechanism = pool.get('party.contact_mechanism')
-
-        party1, = Party.create([{
-                    'name': 'Party 1',
-                    }])
-        mechanism, = ContactMechanism.create([{
-                    'party': party1.id,
-                    'type': 'phone',
-                    'value': '+442083661177',
-                    }])
+        transaction = Transaction()
+
+        def create(mtype, mvalue):
+            party1, = Party.create([{
+                        'name': 'Party 1',
+                        }])
+            return ContactMechanism.create([{
+                        'party': party1.id,
+                        'type': mtype,
+                        'value': mvalue,
+                        }])[0]
 
         # Test format on create
+        mechanism = create('phone', '+442083661177')
         self.assertEqual(mechanism.value, '+44 20 8366 1177')
         self.assertEqual(mechanism.value_compact, '+442083661177')
 
@@ -158,6 +162,20 @@ class PartyTestCase(ModuleTestCase):
         self.assertEqual(mechanism.value, '+44 20 8366 1179')
         self.assertEqual(mechanism.value_compact, '+442083661179')
 
+        # Test rejection of a phone type mechanism to non-phone value
+        with self.assertRaises(UserError):
+            mechanism.value = 'notaphone at example.com'
+            mechanism.save()
+        transaction.rollback()
+
+        # Test rejection of invalid phone number creation
+        with self.assertRaises(UserError):
+            mechanism = create('phone', 'alsonotaphone at example.com')
+        transaction.rollback()
+
+        # Test acceptance of a non-phone value when type is non-phone
+        mechanism = create('email', 'name at example.com')
+
 
 def suite():
     suite = trytond.tests.test_tryton.suite()
diff --git a/tryton.cfg b/tryton.cfg
index 0703327..f47df75 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
 [tryton]
-version=4.2.2
+version=4.2.3
 depends:
     country
     ir
diff --git a/trytond_party.egg-info/PKG-INFO b/trytond_party.egg-info/PKG-INFO
index 6e07f6e..7db3b0d 100644
--- a/trytond_party.egg-info/PKG-INFO
+++ b/trytond_party.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: trytond-party
-Version: 4.2.2
+Version: 4.2.3
 Summary: Tryton module with parties and addresses
 Home-page: http://www.tryton.org/
 Author: Tryton
-- 
tryton-modules-party



More information about the tryton-debian-vcs mailing list