Hi,
I’m creating a custom method in sale.sale called credit_sale. I’m not sure how to fill origin correctly. I’m trying with the code below, but I give the message “can’t adapt type ‘sale.sale’”. Any help will be appreciated.
@classmethod
def credit_sale(cls, sale):
pool = Pool()
Complaint = pool.get('sale.complaint')
ComplaintType = pool.get('sale.complaint.type')
ComplaintAction = pool.get('sale.complaint.action')
ActionSaleLine = pool.get('sale.complaint.action-sale.line')
Sale = pool.get('sale.sale')
types = ComplaintType.search([])
if len(types)==1:
type_ = types[0].id
sales = Sale(sale)
complaint, = Complaint.create([{
'type': type_,
'customer': sale.party.id,
'origin': sales,
}])
complaint_action, = ComplaintAction.create([{
'complaint':complaint.id,
'action':'sale_return',
}])
complaint.wait([complaint])
Complaint.approve([complaint])