How to can read all record,only can write self record.
int
or
list
(
int
) or
None
) – id(s)Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
How to can read all record,only can write self record.
Hi,
For reading the records you can use the orm methods in Odoo. Either you can use search, browse, read or readgroup for this.
Odoo ORM Methods:
See the Official Documentation: ORM API
Model.browse([ids]) → records
Returns a recordset for the ids provided as parameter in the current environment.
self.browse([7, 18, 12])
res.partner(7, 18, 12)
Model.search(args[, offset=0][, limit=None][, order=None][, count=False])
Searches for records based on the args
search domain.
int
) – number of results to ignore (default: none)int
) – maximum number of records to return (default: all)str
) – sort stringbool
) – if True, only counts and returns the number of matching records (default: False)limit
records matching the search criteriaModel.search_count(args) → int
Returns the number of records in the current model matching the provided domain.
Model.name_search(name='', args=None, operator='ilike', limit=100) → records
Search for records that have a display name matching the given
name
pattern when 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 name_get()
, but it is not guaranteed to be.
This method is equivalent to calling search()
with a search
domain based on display_name
and then name_get()
on the
result of the search.
(id, text_repr)
for all matching records.Model.read([fields])
Reads the requested fields for the records in self
, low-level/RPC
method. In Python code, prefer browse()
.
Model.read_group(domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True)
Get the list of records in list view grouped by the given groupby
fields.
list
) – A search domain. Use an empty
list to match all records.list
) – list of fields present in the list view specified on the object.
Each element is either ‘field’ (field name, using the default aggregation),
or ‘field:agg’ (aggregate field with aggregation function ‘agg’),
or ‘name:agg(field)’ (aggregate field with ‘agg’ and return it as ‘name’).
The possible aggregation functions are the ones provided by PostgreSQL
(https://www.postgresql.org/docs/current/static/functions-aggregate.html)
and ‘count_distinct’, with the expected meaning.list
) – list of groupby descriptions by which the records will be grouped.
A groupby description is either a field (then it will be grouped by that field)
or a string ‘field:groupby_function’. Right now, the only functions supported
are ‘day’, ‘week’, ‘month’, ‘quarter’ or ‘year’, and they only make sense for
date/datetime fields.int
) – optional number of records to skipint
) – optional max number of records to returnstr
) – optional order by
specification, for
overriding the natural sort ordering of the
groups, see also search()
(supported only for many2one fields currently)bool
) – if true, the results are only grouped by the first groupby and the
remaining groupbys are put in the __context key. If false, all the groupbys are
done in one call.list of dictionaries(one dictionary for each record) containing:
groupby
argumentgroupby
Thanks
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up