joins in rml report

Asked by Alberto Garcia (Factor Libre)

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:
Last query:
Last reply:
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) said :
#1

Hi,

What do you mean by 2 joins?

This line you referenced is correct and is working.

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) said :
#2

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.

Revision history for this message
Alberto Garcia (Factor Libre) (agarcia-flibre) said :
#3

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]) ]]

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) said :
#4

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.

Revision history for this message
Alberto Garcia (Factor Libre) (agarcia-flibre) said :
#5

at the end nothing get in the report.

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

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) said :
#6

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.

Revision history for this message
Alberto Garcia (Factor Libre) (agarcia-flibre) said :
#7

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()

Revision history for this message
Alberto Garcia (Factor Libre) (agarcia-flibre) said :
#8

Jay some tip to solve this?

Revision history for this message
Best Jay Vora (Serpent Consulting Services) (jayvora) said :
#9

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.

Revision history for this message
Alberto Garcia (Factor Libre) (agarcia-flibre) said :
#10

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))

Revision history for this message
Alberto Garcia (Factor Libre) (agarcia-flibre) said :
#11

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