Jump to content

JOIN 2 tables from OpenERP & iReport


Recommended Posts

Im working with iReport and Ive connected to the db of openERP.

I already pulled data from the invoices table, but it contains a partner_id which is the client name.  I need to get the client name from the res_partner table.  So i think I have to use a join, right?  So I did this:

select * from account_invoice JOIN res_partner ON account_invoice.partner_id = res_partner.id

The problem is that I am not getting the res_partner.name field available from the left pane to drag over to the report designer view.  I only get the account_invoice.partnerid which is no good to me.

If I do select * from res_partner, the res_partner.name field is there, but I need the data joined to the invoices table.

What am I doing wrong?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Ok I opened up the report again and I clicked on Read Fields, this time it did display both name fields, I checked.  But it wont import them to the report designer because it turns out both name and id are duplicate fields, so I get a duplicate fields error, for now, for the id field.  I guess the same thing will happen for the name field once i resolve the id duplicate. 

My question is, how do i resolve that duplicate issue?

Link to comment
Share on other sites

Ok, try to put an alias to yout table query and put another alias to the duplicate field. Exemples

select A.id as ID_A, B.ID as ID_B from account_invoice A JOIN res_partner B ON A.partner_id =B.id

Try to put in the "select" only the fields that you need and do not use *

Let me know


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...