pycharm-odoo icon indicating copy to clipboard operation
pycharm-odoo copied to clipboard

Determine type of variable by its name and usages

Open trinhanhngoc opened this issue 2 years ago • 0 comments

Being able to determine type of variable is important in providing accurate code completion and navigation. But sometimes it's difficult to determine type of variable. For example, in QWeb template, variables can come from controller definition which makes it difficult to analysis.

                <t t-call="portal.portal_record_sidebar">
                    <t t-set="classes" t-value="'col-lg-auto d-print-none'"/>
                    <t t-set="title">
                        <h2 class="mb-0">
                            <b t-if="invoice.amount_residual > 0" t-field="invoice.amount_residual"/>
                            <b t-else="1" t-field="invoice.amount_total"/>
                        </h2>
                        <div class="small" t-if="invoice.payment_state not in ('paid', 'in_payment') and invoice.move_type == 'out_invoice'"><i class="fa fa-clock-o"/><span class="o_portal_sidebar_timeago ml4" t-att-datetime="invoice.invoice_date_due"/></div>
                    </t>

https://github.com/odoo/odoo/blob/4d184bc6ca3b1308ffd7c890928b1c3244f89d45/addons/account/views/account_portal_templates.xml#L88

In the above code, it's possible determine type of invoice by its name and usages (access field amount_residual, payment_state ...)

trinhanhngoc avatar Aug 14 '22 09:08 trinhanhngoc