Question

I have an integer field in which i just display a value calculated with an 'on_change' function.

Is there anyway to not store that value in my Database(another way than using a function field)?

I also tried to put store=False but i guess it doesn't work with an integer field

here's my integer field:

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

And the onchange function:

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}

Thanks

Was it helpful?

Solution

you will always have that field in your db, except it's a non-stored functional field. but you can manipulate the create or write methods of the model. you can set your integer field on None resp. False in that methods, so no value will be stored in that db column.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top