cr.fetchall() can't get a value of a stored function in the database

Bug #1126141 reported by Yug Faa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Invalid
Undecided
Unassigned

Bug Description

When we herit from hr_payroll module I encounter a bug, please follow me :

class hr_payslip(osv.osv):
    _inherit = 'hr.payslip'

    def _compute_slip_worked2(self, cr, uid, ids, field_name, arg, context):
        if not context : context = {}
        res = {}
        for slip in self.browse(cr, uid, ids, context=context) :
            sb = 0.0
            for line in slip.line_ids :
                    sb += line.total
            res[slip.id] = {
                'sb_val': sb,
            }
        return res

    _columns = {
        'payment_mode': fields.char('Mode de paiement', size=64),
        'sb_val': fields.function(_compute_slip_worked2, method=True, type='float', string='Salaire brut', store=True, multi='compute_valss',),
    }
hr_payslip()

When I compute the payslip I get 10 lines with the sum = 23400 but 'sb_val' equal 0 <-- This is the problem, sb_val must equal 23400 not 0

When I edit code, modfying sb += line.total to sb += 3 I get 30 so there is an interfernce that prevent the calcul and this is a bug because the field total in the object hr.payslip.line is a stored function

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Yug,

When you use the store="True" on function field the value will be stored on database. So it will fetch the value which exists on database, it doesn't update the value after that only update when function will execute.

Would you please try without store="True", or let you know what you want to try.

Thank you!

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for OpenERP Addons because there has been no activity for 60 days.]

Changed in openobject-addons:
status: Incomplete → Expired
Amit Parik (amit-parik)
Changed in openobject-addons:
status: Expired → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.