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

Expected singleton stock.picking

By
Arturo B.
on 9/20/16, 8:41 AM 363 views

I have a problem in Odoo 8 whenever I try to print an invoice that has two different delivery order. I get the following error:

File "C:\Program Files (x86)\Odoo 8.0-20160326\server\openerp\addons\company_accounts\account_invoice.py",line 24, in get_delivery_order File "C:\Program Files (x86)\Odoo 8.0-20160326\server\.\openerp\fields.py", line 824, in __get__ File "C:\Program Files (x86)\Odoo 8.0-20160326\server\.\openerp\models.py", line 5306, in ensure_oneQWebException: "ValueErrorExpected singleton: stock.picking(59, 58)" while evaluating"translate_doc(doc_id, doc_model, 'partner_id.lang', 'account.report_invoice_document')"

when I access account_invoice.py the code affected is the following:

def get_delivery_order(self, cr, uid, order_origin, context=None):
 p_id = self.pool.get('stock.picking').search(cr, uid, [('origin', '=', order_origin)])
return self.pool.get('stock.picking').browse(cr, uid, p_id).name

This error only happens if my invoice has more than one delivery order related to it, and I don't know how to solve it. It was coding done by a third party, and we didn't run into problems with it until now. I think that the problem is that it is expecting only one delivery order and it is getting more than one, but I'm unsure on how to solve it.

0
Arturo B.
On 9/20/16, 12:00 PM

It works to some extent, but now I get an error when trying to print any invoice. The error is as follows

QWebException: ""'account.invoice' object has no attribute 'get_delivery_order'" while evaluating'o.get_delivery_order(o.origin)'" while evaluating"translate_doc(doc_id, doc_model, 'partner_id.lang', 'account.report_invoice_document')"


I think this is referencing "report_invoice.xml", which has the following


<div class="col-xs-3" t-if="o.origin">
<strong>Delivery Order:</strong>
<p t-esc="o.get_delivery_order(o.origin)" />
</div>


Thank you very much for your help


Have you removed get_delivery_order method completely?

This method has to be present in account.invoice class. Please check that if it exists in inherited class.

Asmita Chavan
on 9/21/16, 2:44 AM
0
Asmita Chavan
On 9/20/16, 11:17 AM

Replace def get_delivery_order method with :

def get_delivery_order((self, cr, uid, order_origin, context=None):
     p_name = []
     p_ids = self.pool.get('stock.picking').search(cr, uid, [('origin', '=', order_origin)])
     for p_id in p_ids:
         name = self.pool.get('stock.picking').browse(cr, uid, p_id).name
         p_name.append(name)
     return ','.join(p_name)

Hope it works for you.


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: 9/20/16, 8:41 AM
Seen: 363 times
Last updated: 9/20/16, 12:00 PM