[IMP] orm.name*: better docstrings
bzr revid: odo@openerp.com-20110912171210-pmeqvy71l4iu8ulz
This commit is contained in:
parent
b225276cd0
commit
0624e4ab5c
|
@ -2107,19 +2107,15 @@ class orm_template(object):
|
|||
raise NotImplementedError(_('The search method is not implemented on this object !'))
|
||||
|
||||
def name_get(self, cr, user, ids, context=None):
|
||||
"""
|
||||
|
||||
:param cr: database cursor
|
||||
:param user: current user id
|
||||
:type user: integer
|
||||
:param ids: list of ids
|
||||
:param context: context arguments, like lang, time zone
|
||||
:type context: dictionary
|
||||
:return: tuples with the text representation of requested objects for to-many relationships
|
||||
"""Returns the preferred display value (text representation) for the records with the
|
||||
given ``ids``. By default this will be the value of the ``name`` column, unless
|
||||
the model implements a custom behavior.
|
||||
Can sometimes be seen as the inverse function of :meth:`~.name_search`, but it is not
|
||||
guaranteed to be.
|
||||
|
||||
:rtype: list(tuple)
|
||||
:return: list of pairs ``(id,text_repr)`` for all records with the given ``ids``.
|
||||
"""
|
||||
if not context:
|
||||
context = {}
|
||||
if not ids:
|
||||
return []
|
||||
if isinstance(ids, (int, long)):
|
||||
|
@ -2128,38 +2124,39 @@ class orm_template(object):
|
|||
[self._rec_name], context, load='_classic_write')]
|
||||
|
||||
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
|
||||
"""
|
||||
Search for records and their display names according to a search domain.
|
||||
"""Search for records that have a display name matching the given ``name`` pattern if compared
|
||||
with the given ``operator``, while also matching the optional search domain (``args``).
|
||||
This is used for example to provide suggestions based on a partial value for a relational
|
||||
field.
|
||||
Sometimes be seen as the inverse function of :meth:`~.name_get`, but it is not
|
||||
guaranteed to be.
|
||||
|
||||
:param cr: database cursor
|
||||
:param user: current user id
|
||||
:param name: object name to search
|
||||
:param args: list of tuples specifying search criteria [('field_name', 'operator', 'value'), ...]
|
||||
:param operator: operator for search criterion
|
||||
:param context: context arguments, like lang, time zone
|
||||
:type context: dictionary
|
||||
:param limit: optional max number of records to return
|
||||
:return: list of object names matching the search criteria, used to provide completion for to-many relationships
|
||||
|
||||
This method is equivalent of :py:meth:`~osv.osv.osv.search` on **name** + :py:meth:`~osv.osv.osv.name_get` on the result.
|
||||
See :py:meth:`~osv.osv.osv.search` for an explanation of the possible values for the search domain specified in **args**.
|
||||
This method is equivalent to calling :meth:`~.search` with a search domain based on ``name``
|
||||
and then :meth:`~.name_get` on the result of the search.
|
||||
|
||||
:param list args: optional search domain (see :meth:`~.search` for syntax),
|
||||
specifying further restrictions
|
||||
:param str operator: domain operator for matching the ``name`` pattern, such as ``'like'``
|
||||
or ``'='``.
|
||||
:param int limit: optional max number of records to return
|
||||
:rtype: list
|
||||
:return: list of pairs ``(id,text_repr)`` for all matching records.
|
||||
"""
|
||||
return self._name_search(cr, user, name, args, operator, context, limit)
|
||||
|
||||
def name_create(self, cr, uid, name, context=None):
|
||||
"""
|
||||
Creates a new record by calling :py:meth:`~osv.osv.osv.create` with only one
|
||||
value provided: the name of the new record (``_rec_name`` field).
|
||||
The new record will also be initialized with any default values applicable
|
||||
to this model, or provided through the context. The usual behavior of
|
||||
:py:meth:`~osv.osv.osv.create` applies.
|
||||
Similarly, this method may raise an exception if the model has multiple
|
||||
required fields and some do not have default values.
|
||||
"""Creates a new record by calling :meth:`~.create` with only one
|
||||
value provided: the name of the new record (``_rec_name`` field).
|
||||
The new record will also be initialized with any default values applicable
|
||||
to this model, or provided through the context. The usual behavior of
|
||||
:meth:`~.create` applies.
|
||||
Similarly, this method may raise an exception if the model has multiple
|
||||
required fields and some do not have default values.
|
||||
|
||||
:param name: name of the record to create
|
||||
:param name: name of the record to create
|
||||
|
||||
:return: the :py:meth:`~osv.osv.osv.name_get` value for the newly-created record.
|
||||
:rtype: tuple
|
||||
:return: the :meth:`~.name_get` pair value for the newly-created record.
|
||||
"""
|
||||
rec_id = self.create(cr, uid, {self._rec_name: name}, context);
|
||||
return self.name_get(cr, uid, [rec_id], context)[0]
|
||||
|
|
Loading…
Reference in New Issue