Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

get the sum of the invoices relevant to sale order with new API

By
test
on 12/30/15, 11:31 AM 443 views

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

 


0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 12/31/15, 8:58 AM

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

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/30/15, 11:31 AM
Seen: 443 times
Last updated: 12/31/15, 8:58 AM