This question has been flagged
2 Replies
3152 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.

Avatar
Discard
Author Best Answer

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


Avatar
Discard

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.

Best Answer

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.


Avatar
Discard