i'm trying to cancel the advance payment which is created against the payment which is conformed
inherited the account.payment and override the action_draft payment method, i have passed the current payment reference into advance payment while creating advance payment
here is my code for canceling the advance payment
def action_draft(self):
moves = self.mapped('move_line_ids.move_id')
moves.filtered(lambda move: move.state == 'posted').button_draft()
moves.with_context(force_delete=True).unlink()
self.write({'state': 'draft', 'invoice_ids': False})
advance_payment = self.search([('base_payment_id', '=', self.id),
('payment_category', '=', 'advance_payment'), ('state', '=', 'posted')])
if advance_payment:
advance_payment.action_draft()
advance_payment.cancel()
this code work fine and cancel the advance payment but its give warning
Comparing Apples and oranges