Odoo Help

0
2 Answers
0
simmeringc
18/01/18 22:50

Here's my method for generating quotation_order pdf's with Java if anyone finds this in the future:


private void generateOrderReport(final Object internalOdooQuoteId) throws XmlRpcException, IOException {
logger.info("generating quote report pdf for order #: " + internalOdooQuoteId);
final Object internalOdooQuoteIds = asList((Object[]) models.execute("execute_kw", asList(
db, uid, password,
"sale.order", "search",
asList(asList(
asList("id", "=", internalOdooQuoteId)
)),
new HashMap() {{
put("limit", 1);
}}
)));
final XmlRpcClientConfigImpl report_config = new XmlRpcClientConfigImpl();
report_config.setServerURL(
new URL(String.format("%s/xmlrpc/2/report", url)));
final Map<String, Object> result = (Map<String, Object>)models.execute(
report_config, "render_report", asList(
db, uid, password,
"sale.report_saleorder",
internalOdooQuoteIds));
final byte[] report_data = DatatypeConverter.parseBase64Binary(
(String)result.get("result"));
File file = new File("records/quotation_order.pdf");
FileUtils.writeByteArrayToFile(file, report_data);
}
3 Comments
Niyas Raphy
18/01/18 23:02

If you are looking to get the report of a sale, suppose you have to print the Quotation/Order of the sales having the id is 5, then you can get the report from the url as follows :- 0.0.0.0:8014/report/pdf/sale.report_sale_order/5

simmeringc
18/01/18 23:08

Do you know how I could do this with the Java example from the docs? sale.report_sale_order doesn't seem to be a model:

final Object[] reportIds = (Object[])models.execute(

"execute_kw", asList(

db, uid, password,

"sale.order", "search",

asList(asList(

))

));

System.out.println(reportIds);

final XmlRpcClientConfigImpl report_config = new XmlRpcClientConfigImpl();

report_config.setServerURL(

new URL(String.format("%s/xmlrpc/2/report", url)));

final Map<String, Object> result = (Map<String, Object>)models.execute(

report_config, "render_report", asList(

db, uid, password,

"sale.report_sale_order",

reportIds));

final byte[] report_data = DatatypeConverter.parseBase64Binary(

(String)result.get("result"));

File file = new File("proposal/odooOutput.pdf");

byte[] bytes = Base64.decodeBase64(report_data);

FileUtils.writeByteArrayToFile(file, report_data);

Niyas Raphy
18/01/18 23:29

Try this : 0.0.0.0:8014/report/pdf/sale.report_saleorder/5

1
Avatar

Niyas Raphy

--Niyas Raphy--
13760
| 6 6 9
Calicut, India
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to connect :  niyasraphyk@gmail.com

Twitter:https://twitter.com/niyasraphy
LinkedIn: https://www.linkedin.com/in/niyasraphy/
FB:https://www.facebook.com/niyasraphy123

Happy to help :)

Niyas Raphy
18/01/18 22:47

Hi,

To get the reports from the code without going to the user interface you can check this, after authenticating you can choose any of this methods explained in it :

https://www.odoo.com/forum/help-1/question/how-to-print-report-from-website-121485

Suppose if you have to print the Quotation/Order in the sale order having the id 5, then from url you can get the report like this : http://0.0.0.0:8014/report/pdf/sale.report_saleorder/5

Thanks

Ask a Question
Writer
Keep Informed
1 follower(s)
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.

Register
Odoo Training Center

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

Test it now