diff --git a/__openerp__.py b/__openerp__.py index bcdadae..deace92 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -1,34 +1,20 @@ # -*- coding: utf-8 -*- { - 'name': "res_partner_strip_email", - - 'summary': """ - Short (1 phrase/line) summary of the module's purpose, used as - subtitle on modules listing or apps.openerp.com""", - - 'description': """ - Long description of module's purpose - """, - - 'author': "Your Company", - 'website': "http://www.yourcompany.com", + 'name': "Strip email in partner form", + 'summary': """Trim email's field""", + 'description': """Email will be trim when create/save""", + 'author': "It-Projects LLC", + 'website': "https://www.it-projects.info/", # 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': 'Uncategorized', - 'version': '0.1', + 'category': 'Base', + 'version': '1.0.0', # any module necessary for this one to work correctly 'depends': ['base'], # always loaded - 'data': [ - # 'security/ir.model.access.csv', - 'templates.xml', - ], - # only loaded in demonstration mode - 'demo': [ - 'demo.xml', - ], -} \ No newline at end of file + 'data': [ ], +} diff --git a/models.py b/models.py index 11cdbec..c899223 100644 --- a/models.py +++ b/models.py @@ -2,7 +2,19 @@ from openerp import models, fields, api -# class res_partner_strip_email(models.Model): -# _name = 'res_partner_strip_email.res_partner_strip_email' +class res_partner_strip_email(models.Model): + _inherit = 'res.partner' + + @api.one + def write(self, vals): + if 'email' in vals: + vals['email']=vals['email'].strip() + res = super(res_partner_strip_email, self).write(vals) + return res -# name = fields.Char() \ No newline at end of file + @api.model + def create(self, vals): + if vals['email']: + vals['email']=vals['email'].strip() + res = super(res_partner_strip_email, self).create(vals) + return res diff --git a/templates.xml b/templates.xml index 71a9d51..b916650 100644 --- a/templates.xml +++ b/templates.xml @@ -19,4 +19,4 @@ - \ No newline at end of file +