diff --git a/res_partner_strip_email/README.rst b/res_partner_strip_email/README.rst new file mode 100644 index 0000000..c90a29b --- /dev/null +++ b/res_partner_strip_email/README.rst @@ -0,0 +1 @@ +Trim email field in partner form. diff --git a/res_partner_strip_email/__init__.py b/res_partner_strip_email/__init__.py new file mode 100644 index 0000000..89d26e2 --- /dev/null +++ b/res_partner_strip_email/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import models diff --git a/res_partner_strip_email/__openerp__.py b/res_partner_strip_email/__openerp__.py new file mode 100644 index 0000000..652d2cb --- /dev/null +++ b/res_partner_strip_email/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Trim partner's email", + 'summary': "", + 'author': "IT-Projects LLC, Ivan Yelizariev", + 'license': 'LGPL-3', + 'website': "https://yelizariev.github.io", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml + # for the full list + 'category': 'Tools', + 'version': '1.0.0', + + # any module necessary for this one to work correctly + 'depends': ['base'], + + # always loaded + 'data': [], + 'installable': False, +} diff --git a/res_partner_strip_email/models.py b/res_partner_strip_email/models.py new file mode 100644 index 0000000..bb6f741 --- /dev/null +++ b/res_partner_strip_email/models.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +from openerp import models, fields, api + + +class res_partner_strip_email(models.Model): + _inherit = 'res.partner' + + @api.one + def write(self, vals): + vals = self._check_email_field(vals) + return super(res_partner_strip_email, self).write(vals) + + @api.model + def create(self, vals): + vals = self._check_email_field(vals) + return super(res_partner_strip_email, self).create(vals) + + def _check_email_field(self, vals): + if vals.get('email'): + vals['email'] = vals['email'].strip() + return vals diff --git a/res_partner_strip_email/static/description/icon.png b/res_partner_strip_email/static/description/icon.png new file mode 100644 index 0000000..b43a0a1 Binary files /dev/null and b/res_partner_strip_email/static/description/icon.png differ