def get_format_email(self, cr, uid, email, context=None): """ ``Check and format`` email just like `email.coordinate` make it :rparam: formated email value """ if email: if check_email(email): email = format_email(email) return email
def create(self, cr, uid, vals, context=None): """ ====== create ====== format email by removing whitespace and changing upper to lower """ if 'email' in vals: vals['email'] = format_email(vals['email']) return super(email_coordinate, self).create(cr, uid, vals, context=context)
def _get_mailing_object(self, cr, uid, dl_id, email_from, mailing_model=False, email_field='email', context=None): email_from = format_email(email_from) return super(distribution_list, self)._get_mailing_object( cr, uid, dl_id, email_from, mailing_model='email.coordinate', email_field=email_field, context=context)
def index_partner_mobile(self, page=1, search=False, value=False, **kw): """ Index provides the list of partner Manage a pager too """ def create_pager(url, partner_count): pager = http.request.website.pager(url=url, total=partner_count, page=page, step=self._PPG, scope=4, url_args=kw) return pager cr, uid, domain = http.request.cr, http.request.uid, [] context = http.request.context url = "/partner_mobile" mobile_obj = http.request.registry['virtual.mobile.partner'] partner_obj = http.request.registry['res.partner'] if search and value: if search == 'email': value = format_email(value) domain = [(search, 'ilike', value)] kw['search'] = search kw['value'] = value mobile_ids = list( set(mobile_obj.search(cr, uid, domain, context=context))) pager = create_pager(url, len(mobile_ids)) domain = [('id', 'in', mobile_ids)] partner_ids = partner_obj.search(cr, uid, domain, offset=pager['offset'], limit=self._PPG, order='display_name', context=context) partners = partner_obj.browse(cr, uid, partner_ids, context=context) return http.request.render('mozaik_mobile.mobile_index', { "pager": pager, "partners": partners, })