Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3878 Представления

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


Аватар
Отменить
Лучший ответ

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.


Аватар
Отменить
Автор

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

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

Автор

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)

Related Posts Ответы Просмотры Активность
1
мая 21
13538
1
июл. 20
3687
4
мая 24
12681
1
апр. 24
3312
0
нояб. 23
2033