Browse Source

[FIX] partner_email_unique: duplicating partner sets empty email

pull/736/head
robin.keunen 6 years ago
parent
commit
6a2243ed78
  1. 4
      partner_email_unique/models/res_partner.py
  2. 3
      partner_email_unique/tests/test_res_partner_email.py

4
partner_email_unique/models/res_partner.py

@ -3,7 +3,7 @@
# Robin Keunen <robin@coopiteasy.be> # Robin Keunen <robin@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import models, api, _
from openerp import models, api, _, fields
from openerp.exceptions import ValidationError from openerp.exceptions import ValidationError
from openerp.tools import config from openerp.tools import config
@ -11,6 +11,8 @@ from openerp.tools import config
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = "res.partner" _inherit = "res.partner"
email = fields.Char(copy=False)
@api.multi @api.multi
@api.constrains('email') @api.constrains('email')
def _check_email(self): def _check_email(self):

3
partner_email_unique/tests/test_res_partner_email.py

@ -37,3 +37,6 @@ class TestResPartnerEmailUnique(common.SavepointCase):
# Empty email addresses don't raise # Empty email addresses don't raise
self.partner1.email = False self.partner1.email = False
self.partner2.email = False self.partner2.email = False
def test_copy_does_not_raise_duplicate_email_error(self):
self.partner1.copy()
Loading…
Cancel
Save