← Back to team overview

openerp-community team mailing list archive

Re: Domain filters comparing 2 fields

 

Hello Mohamed,

To search for a field credit_limit and credit using *filter*, you need these fields defined at TREE view.

        <record model="ir.ui.view" id="base_view_partner_tree_inherit">
            <field name="name">res.partner.tree.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_tree" />
            <field name="arch" type="xml">
                <field name="email" position="after">
                    <field name="credit_limit" invisible="1"/>
                    <field name="credit" invisible="1"/>
                </field>
            </field>
        </record>

    Then add the filter condition at *SEARCH* view.

On Monday 08 December 2014 12:35 AM, Mohamed M. Hagag wrote:

Dears,


Again Plz let me know how to make this filter work, adding filter on partners search form:


                    <field name="credit_limit"/>
                    <field name="credit"/>

<filter name="credit limit" domain="[('credit','>',credit_limit)]"/>


Applying this filter gives below error:


|Uncaught Error: Failed to evaluate search criterions: ||
||{"code":400,"message":"Evaluation Error","data":{"type":"local_exception","debug":"Local evaluation failure\nNameError: name 'credit_limit' is not defined\n\n{\"domains\":[[],\"[('customer','=',1)]\",\"[('credit','=',credit_limit)]\"],\"contexts\":[{\"lang\":\"en_US\",\"tz\":\"Africa/Cairo\",\"uid\":1,\"search_default_customer\":1}],\"group_by_seq\":[]}"}}|



I googled many times to find a solution without finding anyone .


the simple form [('credit_limit','<',credit)] always returns the error "can not convert string to float" where string is credit and float is credit_limit.


is there any way to say [('credit_limit','<',valueof(credit))] or [('field1','=',valueof(field2))] ??



Regards,


On 10/26/2014 01:11 PM, Mohamed M. Hagag wrote:

Dears,


How can i add filter that compares 2 fields in the object for ex. [('credit_limit','<',credit)] on partners ?


Now I'm making an advanced search and saving it then using the automated actions I edit the search.


But if I wrote it like the previous example I always get "credit not defined" error.


I always get the second field  not defined error .


Any idea how this should be done in the code?


And why the second field is always not defined, how should i code it ??!


Regards,




_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : openerp-community@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp

--
Thanks & Regards,
Atchuthan


Follow ups

References