Browse Source

Trim email's field v 1.0.0

pull/1/head^2
Ilnur Gallyamov 10 years ago
parent
commit
4bf024bc83
  1. 3
      __init__.py
  2. BIN
      __init__.pyc
  3. 8
      __openerp__.py
  4. 20
      controllers.py
  5. 25
      demo.xml
  6. 29
      models.py
  7. BIN
      models.pyc
  8. 2
      security/ir.model.access.csv
  9. 22
      templates.xml

3
__init__.py

@ -1,3 +1,2 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import controllers
import models
import models

BIN
__init__.pyc

8
__openerp__.py

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
{ {
'name': "Strip email in partner form",
'summary': """Trim email's field""",
'description': """Email will be trim when create/save""",
'name': "Trim email's field",
'summary': """""",
'description': """""",
'author': "It-Projects LLC", 'author': "It-Projects LLC",
'website': "https://www.it-projects.info/", 'website': "https://www.it-projects.info/",
@ -16,5 +16,5 @@
'depends': ['base'], 'depends': ['base'],
# always loaded # always loaded
'data': [ ],
'data': [],
} }

20
controllers.py

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from openerp import http
# class ResPartnerStripEmail(http.Controller):
# @http.route('/res_partner_strip_email/res_partner_strip_email/', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/res_partner_strip_email/res_partner_strip_email/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('res_partner_strip_email.listing', {
# 'root': '/res_partner_strip_email/res_partner_strip_email',
# 'objects': http.request.env['res_partner_strip_email.res_partner_strip_email'].search([]),
# })
# @http.route('/res_partner_strip_email/res_partner_strip_email/objects/<model("res_partner_strip_email.res_partner_strip_email"):obj>/', auth='public')
# def object(self, obj, **kw):
# return http.request.render('res_partner_strip_email.object', {
# 'object': obj
# })

25
demo.xml

@ -1,25 +0,0 @@
<openerp>
<data>
<!-- -->
<!-- <record id="object0" model="res_partner_strip_email.res_partner_strip_email"> -->
<!-- <field name="name">Object 0</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object1" model="res_partner_strip_email.res_partner_strip_email"> -->
<!-- <field name="name">Object 1</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object2" model="res_partner_strip_email.res_partner_strip_email"> -->
<!-- <field name="name">Object 2</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object3" model="res_partner_strip_email.res_partner_strip_email"> -->
<!-- <field name="name">Object 3</field> -->
<!-- </record> -->
<!-- -->
<!-- <record id="object4" model="res_partner_strip_email.res_partner_strip_email"> -->
<!-- <field name="name">Object 4</field> -->
<!-- </record> -->
<!-- -->
</data>
</openerp>

29
models.py

@ -2,19 +2,20 @@
from openerp import models, fields, api from openerp import models, fields, api
class res_partner_strip_email(models.Model): 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
_inherit = 'res.partner'
@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
@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
@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

BIN
models.pyc

2
security/ir.model.access.csv

@ -1,2 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_res_partner_strip_email_res_partner_strip_email,res_partner_strip_email.res_partner_strip_email,model_res_partner_strip_email_res_partner_strip_email,,1,0,0,0

22
templates.xml

@ -1,22 +0,0 @@
<openerp>
<data>
<!-- <template id="listing"> -->
<!-- <ul> -->
<!-- <li t-foreach="objects" t-as="object"> -->
<!-- <a t-attf-href="#{ root }/objects/#{ object.id }"> -->
<!-- <t t-esc="object.display_name"/> -->
<!-- </a> -->
<!-- </li> -->
<!-- </ul> -->
<!-- </template> -->
<!-- <template id="object"> -->
<!-- <h1><t t-esc="object.display_name"/></h1> -->
<!-- <dl> -->
<!-- <t t-foreach="object._fields" t-as="field"> -->
<!-- <dt><t t-esc="field"/></dt> -->
<!-- <dd><t t-esc="object[field]"/></dd> -->
<!-- </t> -->
<!-- </dl> -->
<!-- </template> -->
</data>
</openerp>
Loading…
Cancel
Save