[Openerp-community] Advanced filters in odoo

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Openerp-community] Advanced filters in odoo

Mohamed M. Hagag

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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Advanced filters in odoo

Humberto Arocha

One way you can achieve that :

Define a functional field as the subtraction of both two fields,
Define for your newly created field a search function, as functional field that are not store true can not be searched, as of v7, I have not tested that on v8, though I was aware that was a coming feature,

And viola, you will be able to look for your new fields values greater or less than zero,

Best regards

On Oct 26, 2014 6:42 AM, "Mohamed M. Hagag" <[hidden email]> 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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Openerp-community] Domain filters comparing 2 fields

Mohamed M. Hagag
In reply to this post by Mohamed M. Hagag

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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Domain filters comparing 2 fields

atchuthantu@gmail.com
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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp

--
Thanks & Regards,
Atchuthan

_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Domain filters comparing 2 fields

Holger Brunn
In reply to this post by Mohamed M. Hagag
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

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

no.

Write a boolean function field called 'credit_limit_exceeded' whose
search function searches for your term in sql and returns a domain
with the ids for which the condition is met:
https://doc.odoo.com/trunk/server/03_module_dev_02/#fnct-search-parameter

Bonus points for reversing that when searching for
[('credit_limit_exceeded', '=', False)]

- --
Therp - Maatwerk in open ontwikkeling

Holger Brunn - Ontwerp en implementatie

mail: [hidden email]
web: http://therp.nl
phone: +31 (0)20 3093096
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iF4EAREIAAYFAlSFW/kACgkQAcl2D+yjrhjqLQD9ErJPnV26GWgFYojWJkiPpI0e
+zx8qyZHn2pPdalGZDsA/R5h3FdUS7ItL0Pw26z5kBPejK/ezH8obo3tkHHmfDNm
=SU5X
-----END PGP SIGNATURE-----

_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Domain filters comparing 2 fields

Mohamed M. Hagag
In reply to this post by atchuthantu@gmail.com

Dear,


Thanks for your reply.


But even after adding the fields to tree "res.partner.tree" view and doing the filter in search view I still get the 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 tried the same on v.7 and I got the error:

Uncaught TypeError: Cannot read property 'length' of undefined



Regards,


On 12/08/2014 09:47 AM, [hidden email] wrote:
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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp

--
Thanks & Regards,
Atchuthan


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Domain filters comparing 2 fields

Mohamed M. Hagag

Dears,


Anybody tried this ?


is it a bug ? should we report ?



Regards,



On 12/08/2014 11:47 AM, Mohamed M. Hagag wrote:

Dear,


Thanks for your reply.


But even after adding the fields to tree "res.partner.tree" view and doing the filter in search view I still get the 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 tried the same on v.7 and I got the error:

Uncaught TypeError: Cannot read property 'length' of undefined



Regards,


On 12/08/2014 09:47 AM, [hidden email] wrote:
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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp

--
Thanks & Regards,
Atchuthan



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Domain filters comparing 2 fields

Mohamed M. Hagag
In reply to this post by Mohamed M. Hagag

Dears,


Anybody tried this ?


is it a bug ? should we report ?



Regards,



On 12/08/2014 11:47 AM, Mohamed M. Hagag wrote:

Dear,


Thanks for your reply.


But even after adding the fields to tree "res.partner.tree" view and doing the filter in search view I still get the 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 tried the same on v.7 and I got the error:

Uncaught TypeError: Cannot read property 'length' of undefined



Regards,


On 12/08/2014 09:47 AM, [hidden email] wrote:
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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp

--
Thanks & Regards,
Atchuthan



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Domain filters comparing 2 fields

Humberto Arocha
I think, and that is my opinion, there is not such a bug,

Some of the fields your are trying to compare are functional fields, 
in order to allow comparing each functional field has to bear a function 
search as pointed in class function


:param fnct_search: the callable that allows searching on the field (if not provided, search will not return any result)

This is true either to fields.property() which inherits from function,

in this case credit, is searchable
'credit': fields.function(_credit_debit_get, fnct_search=_credit_search, string='Total Receivable', multi='dc', help="Total amount this customer owes you."),

As Holger pointed out your chances of getting what you want improves by defining a functional field of type boolean,
which for instance will bear as a mandatory requirement a fnct_search, because you want to know when it is true
and when is false, and the field is dynamic as previous fields are always changing,

Hope this could clarify any doubt about dealing with functional fields.

Just to highlight something that is wierd for me I think that both  credit & debit functional fields shoud bear type=float,
as of now is lacking that argument.

Once this lack of argument in property fields get some overnight debuggings,

Best Regards.

2014-12-08 15:51 GMT-04:30 Mohamed M. Hagag <[hidden email]>:

Dears,


Anybody tried this ?


is it a bug ? should we report ?



Regards,



On 12/08/2014 11:47 AM, Mohamed M. Hagag wrote:

Dear,


Thanks for your reply.


But even after adding the fields to tree "res.partner.tree" view and doing the filter in search view I still get the 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 tried the same on v.7 and I got the error:

Uncaught TypeError: Cannot read property 'length' of undefined



Regards,


On 12/08/2014 09:47 AM, [hidden email] wrote:
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     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp

--
Thanks & Regards,
Atchuthan



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Loading...