Odoo Help


How to add partner to invoice template?

Pavel Pavlov
on 1/23/14, 6:25 PM 2,144 views


I’m struggling to add some data that I need to my Invoice report…
In Delivery Slip(Tech name: stock.picking.list.out) I get the Invoice
Address from [[ display_address(picking.partner_invoice_id.parent_id) ]]
and Delivery Address from [[ display_address(picking.partner_shipping_id) ]]

I’d like to use same information in my Invoice(Tech name: account.invoice) template,
but the invoice object does not contain the Invoice and Delivery addresses. It has only
display_address(o.partner_id), which is not the one that I need for my invoice document.

I found a nice mapping table in the database “sale_order_invoice_rel” and managed to
build a SQL query that does what I need, but I can’t figure out how to perform the same thing
in the invoice report, when I modify it with Open Office. My query is


  sale_order_invoice_rel.order_id = sale_order.id AND
  account_invoice.id = sale_order_invoice_rel.invoice_id;

and it returns what I need… for example:
“id ;partner_id; partner_invoice_id; partner_shipping_id

Question is how do I get those IDs in the Invoice template via RML tags or where can I extend a python method, that is being used to provide to the template this o object that contains the invoice data…
I found invoice_print method in account.account_invoice, that according to the comment should be ”This function prints the invoice and mark it as sent, so that we can see more easily the next step of the workflow”, but not sure how to extend it – it doesn’t return this o object, so that I could extend it…

If you’ve done something similar please tell me how it worked for you.
Can I somehow modify the report or extend the python code and which method?

Best Regards,
Pavel Pavlov

shashank verma
On 1/24/14, 3:52 AM

Hello pavel

py file

class account_invoice(report_sxw.rml_parse):

def __init__(self, cr, uid, name, context):
    super(account_invoice, self).__init__(cr, uid, name, context=context)

 def _my_new_detail(self,ids):

    return obj_browse

rml file

para style="terp_default_2">[[repeatIn( _my_new_detail(picking), 'my_detail')]]</para>

<blocktable colwidths="410.0" style="Header_Order_Reference_Tbl" &gt;<="" p="">


      <para style="terp_default_1cm_above_space">[my_detail.fieldname ]]</para>


Hope this might help you.

Pavel Pavlov
On 1/24/14, 5:17 AM


shashank verma, thank you for sharing your idea! I believe what you wrote will work, thou I haven't tried it, because after banging my head in this almost whole night I found a smoother solution!

class account_invoice(osv.osv):
_inherit = 'account.invoice'
_columns = {
'zSO': fields.many2many('sale.order', 'sale_order_invoice_rel', 'invoice_id', 'order_id', 'Invoices', readonly=True, help="List of Sales Orders related to this Invoice"),              

Then in the Invoice report I do [[ display_address(o.zSOid[0].partner_shipping_id) ]] and it works! The benefit of using this approach instead of the other one above is that this way no native SQL shall be used and you go thru the openERP framework to get to the DB layer.

Both solutions will work, but please mark this one as answer. thank you!

Regards, Pavel Pavlov

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/23/14, 6:25 PM
Seen: 2144 times
Last updated: 3/16/15, 8:10 AM