Community mailing list archives

community@mail.odoo.com

Re: Search record using its field

by
Togar Hutabarat
- 06/10/2016 03:31:40

Hi Vak0160,

I think the best way to do this is to add one additional function field (computational field), type boolean, which is will be assigned as True if qty < qty2, otherwise: False. And then you can use this field as parameter in your search domain :)

Happy coding!

On Jun 10, 2016 11:02, "vak0160" <vak0160.work@gmail.com> wrote:

Hello Kitti,

I have seen the source code of the `filtered` method, its only a shortcut of what I did before using loop and if. What if I have thousands of records and I want to search for a couple record based on that query, won't it be so slow to search?

On 06/10/2016 10:47 AM, Kitti Upariphutthiphong wrote:
Hi,

Given you have records. In coding you can use

records.filtered(lambda r: r.qty < r.qty2)


On Fri, Jun 10, 2016 at 9:26 AM, vak0160 <vak0160.work@gmail.com> wrote:

Hello Community,

I Have a model with qty and qty2 fields, and I want to search for a record with qty < qty2 condition.
How I can do that without having to iterate all the record and search for the record sequentially using if?

-- 
Regards,
Andre

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


-- 
Regards,
Andre

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe