Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
3869 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Auteur

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

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

Auteur

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)

Publications associées Réponses Vues Activité
1
mai 21
13525
1
juil. 20
3681
4
mai 24
12649
1
avr. 24
3279
0
nov. 23
2030