如何增加或减少记录集? odoo9 [英] How to increment or decrement a recordset? odoo9

查看:74
本文介绍了如何增加或减少记录集? odoo9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的记录集是items = product.pricelist.item(4,3,2)

qty_in_product_uom由用户传递(4= min_quantity 500, 3= 250, 2= 100)

for rule in items:
    if rule.min_quantity and qty_in_product_uom < rule.min_quantity:
        print inside rule.id

现在我想要一个这样的函数,如果条件为真,它将选择下一个ID

now i want such a function that selects the next id if the condition is true

例如如果用户通过qty_in_product_uom说110,则我的上述if条件将给出id=2,在这种情况下,我要id=3

eg. if user passes qty_in_product_uom say 110 then my above if condition will give id=2 in this case i want id=3

如果id=3,则答案将为id=4

,如果id=4选择id=4

由于记录集是一成不变的,因此如何实现这一目标.

As recordsets are immutable how to achieve this.

推荐答案

recordset(BaseModel类)是一个可迭代的Python对象.这意味着您可以使用与使用列表几乎相同的方式来使用该对象.例如:

The recordset(BaseModel class) is an iterable Python object. That means you can use the object in almost the same way you use a list. For example:

item = product.pricelist.item(4,3,2)[0]

print item # This will print product.pricelist.item(4,)

如果要使用其ID从记录集中获取记录,可以使用:

If you want to get a record from the recordset using its id you can use:

item = product.pricelist.item(4,3,2).index(3)

print item # This will print product.pricelist.item(3,)

这篇关于如何增加或减少记录集? odoo9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆