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

how to remove the last entered record from many2many field


@api.depends('member_name')
    def name_member(self):
        list=[]
        for data in self:
            if  len(data.member_name) > self.book_selected.number_of_books:
                for new_item in data.member_name:
                    list.append(new_item)
                print list
                raise exceptions.ValidationError("BOOK NOT AVAILABLE")
            else:
                data.copies_remain = self.book_selected.number_of_books - len(data.member_name)
                new_count = data.copies_remain
                self.book_selected.write({'copies_left': new_count})


i need to remove the record that get entered  into the field  during the exception triggered (when len(data.member_name) > self.book_selected.number_of_books:)  when i print the records in the field i got

[user.info(1,), user.info(2,), user.info(3,), user.info(4,), user.info(5,)]   i need to remove the last record from the field.

Currently new values can be entered even after the exception occurs which make the record not able to access once i save it.


Avatar
Discard
Best Answer

not enough information given to provide solution

Avatar
Discard