Browse Source

models.ru to pep8

pull/1/head^2
Ilnur Gallyamov 10 years ago
parent
commit
b9948e3c30
  1. 1
      README.rst
  2. 3
      __openerp__.py
  3. 16
      models.py

1
README.rst

@ -0,0 +1 @@
Trim email field in partner form.

3
__openerp__.py

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
{
'name': "Trim email's field",
'summary': """""",
'description': """""",
'summary': "",
'author': "Ivan Yelizariev",
'website': "https://yelizariev.github.io",

16
models.py

@ -8,14 +8,16 @@ class res_partner_strip_email(models.Model):
@api.one
def write(self, vals):
if 'email' in vals and type(vals['email']) is not bool:
vals['email'] = vals['email'].strip()
res = super(res_partner_strip_email, self).write(vals)
return res
vals = self._check_email_field(vals)
return super(res_partner_strip_email, self).write(vals)
@api.model
def create(self, vals):
if vals['email']:
vals = self._check_email_field(vals)
return super(res_partner_strip_email, self).create(vals)
def _check_email_field(self, vals):
if not isinstance(vals['email'], bool) and 'email' in vals or \
isinstance(vals['email'], bool) and vals['email']:
vals['email'] = vals['email'].strip()
res = super(res_partner_strip_email, self).create(vals)
return res
return vals
Loading…
Cancel
Save