Borealis
Borealis

Reputation: 1137

create function creates two record

this is my create function:

    @api.model
    def create(self, vals):
        record = super(Shift, self).create(vals)
        flag = False
        if record.Date_range:
          do smth   


        return super(Shift, self).create(vals)

but when I try to create a record by clicking on save button, it creates two records

Upvotes: 1

Views: 62

Answers (1)

Bhavesh Odedra
Bhavesh Odedra

Reputation: 11143

In your method, you have called super method twice that's lead to create two record.

Replace code from

return super(Shift, self).create(vals)

to

return record

Upvotes: 3

Related Questions