コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3763 ビュー

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)

関連投稿 返信 ビュー 活動
1
5月 21
13211
1
7月 20
3601
4
5月 24
12395
1
4月 24
3075
0
11月 23
1886