콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
6 답글
17645 화면

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


아바타
취소
관련 게시물 답글 화면 활동
0
4월 20
2878
3
8월 18
10595
1
3월 17
2951
5
11월 24
46928
0
1월 23
1707