Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4471 มุมมอง

Hello,


I tried to get the sum of invoices related to sale orders so that it can be available in sale.order.tree view for example. My code is:

from openerp import fields, models, api

 


class AAA(models.Model):

_inherit = 'sale.order'

  @api.one

@api.depends('invoice_ids.invoice_line.price_subtotal')

def _my_amount_total(self):

total=self.env['account.invoice.line'].search([('invoice_id','in',self.invoice_ids)])

self.my_amount_total_invoice = sum(item.price_subtotal for item in total)

my_amount_total_invoice = fields.Float(string="# Sum", compute='_my_amount_total')


AAA()

ButI got the following error

AssertionError: Invalid value account.invoice(1,) in domain term ('invoice_id', 'in', account.invoice(1,))


The problem is with this line:

total=self.env['account.invoice.line'].search([('invoice_id','in',self.invoice_ids)])

 

Can anyone help me?


Thanks in advance,

Regards

 


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

self.invoice_ids in new api return a recordset (not a set of ids), see documentation

 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.พ. 19
3726
0
ต.ค. 22
7728
0
ส.ค. 22
59
1
ม.ค. 19
8497
1
มี.ค. 15
6447