joins in rml report

Asked by Alberto Garcia (Factor Libre) on 2009-05-27

How can i do a join in rml with two joins,

example:

REF: [[ ', '.join([(ol.order_id and ol.order_id.client_order_ref) or '' for ol in l.order_ids]) ]]

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Jay Vora (Serpent Consulting Services)
Solved:
2009-05-28
Last query:
2009-05-28
Last reply:
2009-05-28

Hi,

What do you mean by 2 joins?

This line you referenced is correct and is working.

If you are talking about joining by',' from 2 lists, you may write the same line twice.
[[ ', '.join([(ol.order_id and ol.order_id.client_order_ref) or '' for ol in l.order_ids]) ]]
[[ ', '.join([(ol.order_id and ol.order_id.client_order_ref) or '' for ol in l.order_ids]) ]]

Provide specific information please.

Thank you.

I explain, I want put the client reference order (in sale order) in each line of invoice.

The problem is that aren't a relation between account.invoice.line and sale.order.line

For this I have created a field in account.invoice.line:

class account_invoice_line(osv.osv):
        _name = "account.invoice.line"
        _inherit = "account.invoice.line"
        _columns = {
                'order_ids': fields.many2many('sale.order.line', 'sale_order_line_invoice_line__rel', 'invoice_line_id', 'order_id', 'Pedidos', readonly=True),
        }

account_invoice_line()

And next I put this in invoice.rml to get the clien order reference

REF: [[ ', '.join([(ol.order_id and ol.order_id.client_order_ref) or '' for ol in l.order_ids]) ]]

Hello Alberto,

Yes, I understood the requirement, and I tried the same for Tax lines(m2m for invoice lines). It works perfectly.

What problem occurs at your end?

Make sure you have installed sale module, more importantly, I would prefer you to write this code in sale module.

thank you.

at the end nothing get in the report.

Yo say me to do the same thing but in the sale.order.line?

No Alberto,

I say, you write the class stuff in sale module, not in the sale.order.line.

3 things you need to check:

1. Invoice line has sale order lines or not.
2. client_order_ref field on the related sale order is filled or not
3. Try by this line :
[[ ', '.join([(ol.account_collected_id and ol.account_collected_id.name) or '' for ol in l.invoice_line_tax_id]) ]]
Put this line on the first td of invoice line, so you can easily figure it out.

Ok Jay

If i change for sale.order not create content in the new table.

class account_invoice_line(osv.osv):
        _name = "account.invoice.line"
        _inherit = "account.invoice.line"
        _columns = {
                'order_ids': fields.many2many('sale.order', 'sale_order_invoice_line_rel', 'invoice_line_id', 'order_id', 'Pedidos', readonly=True),
        }

account_invoice_line()

Jay some tip to solve this?

Yes Alberto,

Did you try checking the 3 above-mentioned points?
As I said, your code should work,undoubtedly. It might be you are missing something.

Let us do one thing, send me the zip of your module, I will help you making it clean.

Thanks.

I have send you an email to <email address hidden>

thanks.

I have done one thins with this module but only work when i do the invoice from sale orders.

line: 802
file: sale.py

I have add
cr.execute('insert into sale_invoice_line_order_rel (invoice_line_id,order_id) values (%s,%s)', (inv_id, line.id))

Thanks Jay (Open ERP), that solved my question.