Browse Source

One possible implementation of raise when partner create/write is manual vs no raise with partner create/write is via code

pull/18/head
Alexis de Lattre 10 years ago
parent
commit
25f00cf7e9
  1. 5
      base_phone/base_phone.py
  2. 4
      base_phone/res_partner_view.xml

5
base_phone/base_phone.py

@ -61,9 +61,10 @@ class phone_common(orm.AbstractModel):
return result return result
def _generic_reformat_phonenumbers(self, cr, uid, vals, phonefields=None, def _generic_reformat_phonenumbers(self, cr, uid, vals, phonefields=None,
raise_if_parse_fails=False,
context=None): context=None):
"""Reformat phone numbers in E.164 format i.e. +33141981242""" """Reformat phone numbers in E.164 format i.e. +33141981242"""
if context is None:
context = {}
if phonefields is None: if phonefields is None:
phonefields = [ phonefields = [
'phone', 'partner_phone', 'work_phone', 'fax', 'phone', 'partner_phone', 'work_phone', 'fax',
@ -105,7 +106,7 @@ class phone_common(orm.AbstractModel):
_logger.error( _logger.error(
"Cannot reformat the phone number '%s' to " "Cannot reformat the phone number '%s' to "
"international format" % vals.get(field)) "international format" % vals.get(field))
if raise_if_parse_fails:
if context.get('raise_if_phone_parse_fails'):
raise orm.except_orm( raise orm.except_orm(
_('Error:'), _('Error:'),
_("Cannot reformat the phone number '%s' to " _("Cannot reformat the phone number '%s' to "

4
base_phone/res_partner_view.xml

@ -56,5 +56,9 @@
</field> </field>
</record> </record>
<record id="base.action_partner_form" model="ir.actions.act_window">
<field name="context">{'search_default_customer':1, 'raise_if_phone_parse_fails': True}</field>
</record>
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save