【问题标题】:How to not store an integer field in openerp如何不在 openerp 中存储整数字段
【发布时间】:2014-03-04 08:53:20
【问题描述】:

我有一个整数字段,我只在其中显示使用“on_change”函数计算的值。

无论如何不要将该值存储在我的数据库中(使用函数字段的另一种方式)?

我也尝试设置 store=False 但我猜它不适用于整数字段

这是我的整数字段:

'quantite_op': fields.integer('Quantité produite par opération',store=False,readonly=True),

还有onchange函数:

def onchange_num_of(self,cr,uid,ids,of_num,operation_nom,quantite,context=None):
    res = {}
    if of_num:
        ordre_f = self.pool.get('ordres_fabrication').browse(cr, uid,of_num,context=context)
        res['delai_of'] =ordre_f.delai
        res['quantite_of'] =ordre_f.quantite
        if operation_nom:
            record =self.search(cr, uid, [('of_num','=',of_num),('operation_nom','=',operation_nom)])
            qte=0
            for item in record:
                prod = self.browse(cr, uid,item,context=context)
                qte += prod.quantite
            res['quantite_op'] = qte+quantite
    return {'value': res}

谢谢

【问题讨论】:

    标签: openerp openerp-7


    【解决方案1】:

    您将始终在您的数据库中拥有该字段,除非它是一个非存储的函数字段。但您可以操作模型的创建或写入方法。您可以将整数字段设置为 None 。该方法中为 False,因此该 db 列中不会存储任何值。

    【讨论】:

    • 感谢您的回复。我不仅不希望它被存储,而且我也不希望在数据库中创建该列。我想我会创建一个 function_field 并在 onchange 函数中调用相关函数。仍在努力,但我想它会做到的。
    猜你喜欢
    • 2014-05-13
    • 1970-01-01
    • 1970-01-01
    • 2013-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多