Odoo Help

Welcome!

This community 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.

0

Update function field that uses a different field function

By
mehdi
on 5/27/15, 8:14 AM 413 views

I have a problem since a month of updating the function field 'result' that uses a different field function 'field2' (updated without problems) ?


_name = 'x'
'field1': fields.integer(readonly=True),
'field2': fields.function(count_x_id_in_y, type='integer',
          store={'y': (get_x_id_from_y, ['x_id'], 10)}),
'result': fields.function(add, type='integer',
          store={'x': (lambda self, cr, uid, ids, c={}: ids, ['field1','field2'], 10)}),


def add(self, cr, uid, ids, field_name, args, context=None):
    res = {}
    for record in self.browse(cr, uid, ids, context=context):
        res[record.id] = record.field1 + record.field2

    return res

1
Kinner Vachhani
On 5/28/15, 10:07 AM

Check the following code from sale/sale.py


 'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Untaxed Amount',
            store={
                'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
                'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
            },
            multi='sums', help="The amount without tax.", track_visibility='always'),
'amount_tax': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='VAT', store={ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10), }, multi='sums', help="The tax amount."),
'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Total', store={ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10), }, multi='sums', help="The total amount."),


The use of multi parameter will solve your problem. 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/27/15, 8:14 AM
Seen: 413 times
Last updated: 5/29/15, 1:09 PM