Odoo Hilfe

2

3
4 Answers
8
Avatar

Dhinesh

--Dhinesh--
3905
| 6 5 11
Pondicherry, Indien
--Dhinesh--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks.

 

Dhinesh
03.09.14, 04:37

Hi, Operations on recordset are

record in recset1           # include
record not in recset1       # not include
recset1 + recset2           # extend
recset1 | recset2           # union
recset1 & recset2           # intersect
recset1 - recset2           # difference

1 Kommentar
Atte Isopuro
03.09.14, 04:55

Thank you for the prompt answer. I was also wondering if there are list-like operations available for single recordsets, like recordset[3:7] to get records 3 through 7 from the recordset?

5
Avatar

Akhil P Sivan

--Akhil P Sivan--

4164
| 6 4 9
Kochi, Indien
--Akhil P Sivan--

Odoo Developer

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
29.10.15, 23:36

Hi,

Other recordset operations:

1. sorted(): To sort a recordset

# sort records by name
recset.sorted(key=lambda r: r.name)


2. filtered(): To filter a recordset:

# only keep records whose company is the current user's
records.filtered(lambda r: r.company_id == user.company_id)

# only keep records whose partner is a company
records.filtered("partner_id.is_company")


3. mapped(): To map a recordset by applying the provided function to each record in the recordset and returns a recordset if the results are recordsets.

recordset.mapped(lambda record: record.amount + record.tax_amount)

# returns a list of name
recset.mapped('name')

# returns a recordset of partners
recset.mapped('invoice_id.partner_id')


0
Osval Reyes
29.10.15, 19:35

Is there anyway to apply a .search([]) call in a recordset?

1 Kommentar
Atte Isopuro
16.09.16, 06:03

I'm not aware of being able to do this directly. What you need to do is explicitly narrow your domain to that recordset using the recordset's 'ids' attribute. So say you have a recordset partners, and you want to find out which of those partners are suppliers. Then you would do:

self.env['res.partner'].search([ ( 'id', 'in', partners.ids ), ( 'supplier', '=', True ) ])

Fragen Sie
Writer
Keep Informed
1 Verfolger
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now