Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
17657 มุมมอง

Hello everybody, I have the doubt that if is possible create a qweb with data from different models, for example, if I have the models A, B, C (each one with data completely different) but the 3 models have one field in common, the employee_id, but I don't know how can I put the 3 models in a pdf and group the data of each one by the employee.


Anyone could help me? Thanks!!!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Just adding a point to what Yenthe told.

You can also search the any models from the qweb like this,

<t t-foreach="request.env['model_name'].search([('user_id', '=', o.user_id.id)])" t-as="obj">
# ..........................
</t

Thanks

อวตาร
ละทิ้ง

Yep, that is also an option if you don't need to do any operations with the data or nothing very advanced. :)

Thanks a lot.

คำตอบที่ดีที่สุด

Hi Jorge,

Usually in this case you should have one model from where you print the report, let us say it is account.invoice. If you then want to access data from two other models you should have a link to these models to easily access the data. Let us say you have account.invoice.one and account.ionvoice.two.
The account.invoice.one model is linked to the account.invoice with a field named invoice_one_id and the account.invoice.two model is linked to the account.invoice with a field named invoice_two_id. You could then do this in the code:

<span t-field="o.invoice_one_id.field1"/> <span t-field="o.invoice_two_id.field2"/>

If this is not the case you could call a Python function from the QWeb report like this:

<t t-set="record_collection" t-value="doc.get_data()"/>

And in the Python code you can then call this function and do whatever you want:

@api.multi

def get_data(self): record_collection = [] # Do your browse, search, calculations, .. here and then return the data (which you can then use in the QWeb) record_collection = self.env['account.invoice.two'].search([('name', '=', 'Example')]) return record_collection

Regards,
Yenthe

อวตาร
ละทิ้ง

What about <t t-if="doc_model in ['account.invoice','sale.order']"> DO SOMETHING </t> See https://www.odoo.com/documentation/11.0/reference/reports.html for a complete list of all variables accessible in reports - docs, doc_ids, doc_model, time, user and res_company.

คำตอบที่ดีที่สุด

Create a report in odoo from scratch using Qweb reporting engine. I am not going to paste here complete code please visit these links :

1- http://learnopenerp.blogspot.com/2016/11/how-to-create-qweb-reports-in-openerp.html

2- http://learnopenerp.blogspot.com/2016/09/how-to-create-custom-reports-in-odoo.html


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try this modules:

Print Multiple Reports In Single File

Print Multiple Invoice Reports To Single File

Print Multiple Sales Reports To Single File

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 20
2884
3
ส.ค. 18
10599
1
มี.ค. 17
2951
5
พ.ย. 24
46930
0
ม.ค. 23
1716