Hello,
In order to create multiple sequences for different types of purchase orders,
I tried overriding a create method in purchase module but getting an error -
return super(new_purchase, self.with_context(company_id=company_id)).create(vals) TypeError: super(type, obj): obj must be an instance or subtype of type
My code -
@api.model
def create(self, vals):
company_id = vals.get('company_id', self.default_get(['company_id'])['company_id'])
if vals.get('name', 'New') == 'New':
seq_date = None
if 'date_order' in vals:
seq_date = fields.Datetime.context_timestamp(self, fields.Datetime.to_datetime(vals['date_order']))
vals['name'] = self.env['ir.sequence'].with_context(force_company=company_id).next_by_code('purchase.order', sequence_date=seq_date) or '/'
return super(new_purchase, self.with_context(company_id=company_id)).create(vals)
new_purchase is the name of inherited purchase.order class
How to fix this error?
Thanks in advance!