This question has been flagged
4 Replies
6221 Views

Hello, I'm using Google Spreadsheet integration to export reports to Google Drive from Odoo 11 Enterprise.

The way the reports works is taking fields from a model depending on the domain we declare.

The thing is that I need to get one2many or many2one fields in this report:

For example, if I call the field product_id for a quotation, it will return the first line from the Quotation but not others; also, I think it's not possible to call fields like this "product_id.id".

I wish to know if someone knows a way to do this, or a way to add a field that can be called in reports adding a new field like all_products containing -> product1, product2, etc.

Thanks beforehand.

Rodrigo

Avatar
Discard
Best Answer

There is a work-around to archive this. You need to get field order_line from sale.order model, result is a string list of order_line ids (eg. "101,102,103"). Create another sheet tab to oe_browse from model sale.order.line, including field "id" in your query. Now you can do some spreadsheet command stuff (split, vlookup,...) to link those 2 sheet based on the id of order line.

Avatar
Discard
Best Answer

Hi,

For calling and printing the one2many or many2many fields, you have to iterate them over a for loop as there is chance/case of having multiple records in it. You might not have used or given for loop, which may result in singleton error.

You can see an example case of printing the one2many fields in report here, see this: Printing One2many fields in report

Thanks

Avatar
Discard
Author

Very informative thanks. but it isn't what im looking for.

I'm new to Odoo & Python, so i'll try to explain it the best way I can.

I'm looking to get the products associated to a Quotation, Saler Order, Subscription, etc. in Google Spreadsheet module.

What I need is to be able to export something like this:

i.e. from CRM module -> for each quotation get all orders lines and link them.

Thanks & sorry for my english

Hi,

if you have an object of the sale order in your hand, suppose sale.order(1) , then if you need to get the products in the sale order line, if you are in python,

for product in sale_order.order_line:

print("product", product) .

you can try something like this