Skip to Content
Menu
This question has been flagged

Hello, 

Odoo V11

The model is 'hr.payslip' I study . I am getting  an error when update field in 'hr.contract' object

I have a depends method:


@api.one

    @api.depends('line_ids')

    def _compute_cumulative_income_tax(self):

        for record in self:

            if record.line_ids:

               .... some calculations

               #error code 

                if record.cumulative_income_tax_base:

                    contract = self.env['hr.contract'].browse(record.contract_id.id)

                    if contract:

                        total = contract.varsa_devir_vergi_matrahi + temp_line_amount or 0.0

                       #After I use write method,error was occurred

                        contract.write({

                            'varsa_devir_vergi_matrahi': total

                        })



Avatar
Discard
Best Answer

You can not write in compute method. You can use related field instead.

Avatar
Discard
Author

Thanks , I agree with your idea. Therefore, I tried this operation in a custom action method with @api.multi decorator and this ran successfully.

Related Posts Replies Views Activity
2
Feb 24
13200
1
Dec 22
3863
2
Dec 22
12725
2
Jun 22
4688
2
Jun 22
3505