Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4966 Lượt xem

Hello all

Is there a way to call a method in the .py file from the xml without define a new field?
E.g.:

model.py
@api.model
def get_companies(self):
    return 
self.env['res.partner'].search(['is_company', '=', True])

view.py
<field name="get_companies" colspan="4" nolabel="1">
    <tree string="Companies">
        <field name="id"/>
        <field name="name"/>
        <field name="vat"/>
    </tree>
</field>

Regards
Alejandro

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

If the method does not depends on specific records, you may want to try to use context supplied from fields_view_get.  However I think function field is easier to implement.

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you Ivan, then, I will use a function field to reference those values. Could you please include some source or explanation for fields_view_get usage to accept your answer as the solution?

The two samples that you'll find most useful, AFAIK, is from account.voucher (odoo/addons/account_voucher/account_voucher.py) and account.invoice (odoo/addons/account/account_invoice.py). They are a model that is used for several purposes (types) and the view need to be customised for each purpose/type.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 17
4001
2
thg 5 16
5016
0
thg 2 16
3932
0
thg 1 19
4785
0
thg 2 16
4267