Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3849 Vistas

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


Avatar
Descartar
Mejor respuesta

Hi, 

This error occurs when you are comparing two unrelated things say, objects and id

Example: purchase.order(1,) == 15      ## In this case it throws kinda error

I guess the error is here,  ('payment_category', '=', 'advance_payment')

Thanks.


Avatar
Descartar
Autor

Comparing apples and oranges: account.payment(82,) == 82

Sorry typo error...it should be model( 15,) == 15 nd thanks

Autor

its okay but can you please elaborate this because i'm searching record set of account.payment in account.payment model and still did not get the point.

or any other way to do this thing

Hi,

advance_payment variable should be declared before using in domain . what model does payment_category points to ?

For many2one comparision

it should be ('many2one_field', '=', many2one_field.id)

For many2many comparision

it should be ('many2one_field', 'in', many2many.ids)

Publicaciones relacionadas Respuestas Vistas Actividad
1
may 21
13461
1
jul 20
3665
4
may 24
12623
1
abr 24
3265
0
nov 23
2012