Skip to Content
Menu
This question has been flagged
1 Reply
1214 Views

Hii.

I have a One2Many relation in a header table. My child table has a status field. I want when the status of all child lines is done, then the status of header status field should turn to done automatically. How it could be achieved?


Avatar
Discard
Best Answer

Hello Muhammad Anees

You can add header status field computed type and computed function like below

@ api.depends ('child_ids.state')

    def _compute_count (self):

        for parent in self:

            doneIds = parent.child_ids.filtered (lambda child: child.state == 'done'). ids

            if len (doneIds) == len (parent.child_ids):

                parent.state = "done"

Regards

Anisha Bahukhandi

Technical Content Writer

Webkul

Avatar
Discard