I have a relation between the fuel and voucher classes with the field 'amount_used' that calculates the number of voucher x used in fuel without problems
_name = 'fleet.vehicle.log.fuel' 'voucher_id': fields.many2one('fleet.voucher', 'Voucher'),
_name = 'fleet.voucher'
'amount_used': fields.function(_count_all, type='integer', string="Amount Used")
def _count_all(self, cr, uid, ids, field_name, arg, context=None): Fuel = self.pool['fleet.vehicle.log.fuel'] return { voucher_id: Fuel.search_count(cr, uid, [('voucher_id', '=', voucher_id)], context=context)
for voucher_id in ids
}
when I add the store parameter in 'amount_used' I have an update problem
store=True or store={'fleet.vehicle.log.fuel': (lambda self, cr, uid, ids, c={}: ids, ['voucher_id'], 10)}