[IMP] base_state: added default methods, as in base_stage.

bzr revid: tde@openerp.com-20120530082943-raemlear6m8uha0s
This commit is contained in:
Thibault Delavallée
2012-05-30 10:29:43 +02:00
parent 226a50f369
commit c0cc4cc7ac
2 changed files with 41 additions and 3 deletions
+7 -3
View File
@@ -41,7 +41,7 @@ class base_stage(object):
"""
if context is None:
context = {}
if not context.get('portal', False):
if not context or not context.get('portal'):
return False
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if hasattr(user, 'partner_address_id') and user.partner_address_id:
@@ -52,7 +52,9 @@ class base_stage(object):
""" Gives default email address for current user
:param context: if portal in context is false return false anyway
"""
if context and context.get('portal'):
if context is None:
context = {}
if not context or not context.get('portal'):
return False
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.user_email
@@ -61,7 +63,9 @@ class base_stage(object):
""" Gives current user id
:param context: if portal in context is false return false anyway
"""
if context and context.get('portal'):
if context is None:
context = {}
if not context or not context.get('portal'):
return False
return uid
+34
View File
@@ -32,6 +32,40 @@ class base_state(object):
- ``state`` (selection field)
"""
def _get_default_partner(self, cr, uid, context=None):
""" Gives id of partner for current user
:param context: if portal in context is false return false anyway
"""
if context is None:
context = {}
if not context or not context.get('portal'):
return False
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if hasattr(user, 'partner_address_id') and user.partner_address_id:
return user.partner_address_id
return user.company_id.partner_id.id
def _get_default_email(self, cr, uid, context=None):
""" Gives default email address for current user
:param context: if portal in context is false return false anyway
"""
if context is None:
context = {}
if not context or not context.get('portal'):
return False
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.user_email
def _get_default_user(self, cr, uid, context=None):
""" Gives current user id
:param context: if portal in context is false return false anyway
"""
if context is None:
context = {}
if not context or not context.get('portal'):
return False
return uid
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
""" This function returns value of partner email based on Partner Address
:param add: Id of Partner's address