Pb with complex domain expressions

Bug #816561 reported by Alexis de Lattre

This bug report was converted into a question: question #166085: Pb with complex domain expressions.

10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Won't Fix
Undecided
Unassigned

Bug Description

I have a problem with complex domain expressions ; it may be a bug of the OpenERP server, but it may also be a bad domain expression due to a bad comprehension of the way it is supposed to work.

In an ir.actions.act_window on the object account.invoice :

1) I want to filter on open invoice/refunds that are either from Asustek with country = Taiwan or from Direct PC with country = Belgium, so I write the following expression :

<field name="domain">['&amp;', '|', '&amp;', ('address_invoice_id.country_id.name', '=', 'Taiwan'), ('partner_id.name', '=', 'ASUStek'), '&amp;', ('address_invoice_id.country_id.name', '=', 'Belgium'), ('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open')]</field>

Result : it works OK.

2) I want to filter on open customer invoices that are either from Asustek with country = Taiwan or from Direct PC with country = Belgium, so I write the following expression :

<field name="domain">['&amp;', '&amp;', '|', '&amp;', ('address_invoice_id.country_id.name', '=', 'Taiwan'), ('partner_id.name', '=', 'ASUStek'), '&amp;', ('address_invoice_id.country_id.name', '=', 'Belgium'), ('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open'), ('type', '=', 'out_invoice')]</field>

Result : NOT OK, I get ALL the invoices !

I have this problem with OpenERP server branch 5.0 and branch 6.0 ; I wanted to test on trunk, but I can't find the "Modules" menu entry to install my module !

By the way, my source of information about complex domain expressions is this one :
http://christophe-simonis-at-tiny.blogspot.com/2008/08/new-new-domain-notation.html
plus wikipedia to understand "polish expressions" and "arity".

description: updated
description: updated
Revision history for this message
xrg (xrg) wrote : Re: [Bug 816561] [NEW] Pb with complex domain expressions
Download full text (3.3 KiB)

On Tuesday 26 July 2011, you wrote:
> Public bug reported:
>
> I have a problem with complex domain expressions ; it may be a bug of
> the OpenERP server, but it may also be a bad domain expression due to a
> bad comprehension of the way it is supposed to work.
>
> In an ir.actions.act_window on the object account.invoice :
>
> 1) I want to filter on open invoice/refunds that are either from Asustek
> with country = Taiwan or from Direct PC with country = Belgium, so I
> write the following expression :
>
> <field name="domain">['&amp;', '|', '&amp;',
> ('address_invoice_id.country_id.name', '=', 'Taiwan'),
> ('partner_id.name', '=', 'ASUStek'), '&amp;',
> ('address_invoice_id.country_id.name', '=', 'Belgium'),
> ('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open')]</field>
>
> Result : it works OK.
>
> 2) I want to filter on open customer invoices that are either from
> Asustek with country = Taiwan or from Direct PC with country = Belgium,
> so I write the following expression :
>
> <field name="domain">['&amp;', '&amp;', '|', '&amp;',
> ('address_invoice_id.country_id.name', '=', 'Taiwan'),
> ('partner_id.name', '=', 'ASUStek'), '&amp;',
> ('address_invoice_id.country_id.name', '=', 'Belgium'),
> ('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open'), ('type',
> '=', 'out_invoice')]</field>
>
> Result : NOT OK, I get ALL the invoices !
>

Strange, to me, it seems to be working fine with both of your expressions:

BQI account.invoice> table id, partner_id, state from read([6,7,8,9])
id| partner_id | state
-----------------------------------------------------------------------------------------------------
9 |[7, 'Axelor'] |open
8 |[11, 'Distrib PC']|draft
7 |[11, 'Distrib PC']|open
6 |[2, 'ASUStek'] |open

BQI account.invoice> do search(['&', '|', '&',
('address_invoice_id.country_id.name', '=', 'Taiwan'), ('partner_id.name',
'=', 'ASUStek'), '&', ('address_invoice_id.country_id.name', '=', 'Belgium'),
('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open')])
Res: [7, 6]
BQI account.invoice> do search(['&', '&', '|', '&',
('address_invoice_id.country_id.name', '=', 'Taiwan'), ('partner_id.name',
'=', 'ASUStek'), '&', ('address_invoice_id.country_id.name', '=', 'Belgium'),
('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open'), ('type', '=',
'out_invoice')])
Res: [7, 6]

BQI> server get environment
execute: 'get_server_environment' ()
Result:

Environment Information :
System : Linux-3.0.0-rc4+-x86_64-with-mandrake-1-Official
OS Name : posix
LSB Version: *
Distributor ID: Mageia
Description: Mageia 1
Release: 1
Codename: valstar
Operating System Release : 3.0.0-rc4+
Operating System Version : #5 SMP Sat Jun 25 14:36:11 EEST 2011
Operating System Architecture : 64bit
Operating System Locale : el_GR.UTF-8
Python Version : 2.7.1
OpenERP-Server Version : 6.0.2

(also tested...

Read more...

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

xrg : thanks for investigating this issue with me !

I am currently reproducing the issue with OpenERP server 6.0 (up-to-date bzr branch) and OpenERP client 6.0 (up-to-date bzr branch).

The module in which my code is : coface_credit_insurance
lp:~akretion-team/+junk/coface_credit_insurance last revision (rev 27)

Once the module is installed, I create 4 invoices :
- 1 customer invoice for Asustek in state open
- 1 customer invoice for Distrib PC in state open
- 1 customer refund for Asustek in state open
- 1 customer invoice for Distrib PC in state draft

Then, go to Financial management > Coface > "DMS to do", and you have a tree view with 4 invoices, where as you should only get 2 invoices if you refer to invoice_view.xml line 73.

This time, I started my OpenERP client 6.0 through command line, and I saw this message when opening the "DMS to do" menu entry :

ERROR:tools.expr_eval:['&', '&', '|', '&', ('address_invoice_id.country_id.name', '=', 'Taiwan'), ('partner_id.name', '=', 'ASUStek'), '&', ('address_invoice_id.country_id.name', '=', 'Belgium'), ('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open'), ('type','=',
Traceback (most recent call last):
  File "/home/alexis/new_boite/dev/openobject-client-6.0/bin/tools/__init__.py", line 52, in expr_eval
    temp = eval(string, context)
  File "<string>", line 1
     ['&', '&', '|', '&', ('address_invoice_id.country_id.name', '=', 'Taiwan'), ('partner_id.name', '=', 'ASUStek'), '&', ('address_invoice_id.country_id.name', '=', 'Belgium'), ('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open'), ('type','=',
                                                                                                                                                                                                                                                              ^
 SyntaxError: unexpected EOF while parsing

So it's clearly linked to my problem ! I guess we are getting closer to finding the issue !

Revision history for this message
xrg (xrg) wrote : Re: [Bug 816561] Re: Pb with complex domain expressions

On Wednesday 27 July 2011, you wrote:

> File "<string>", line 1
> ['&', '&', '|', '&', ('address_invoice_id.country_id.name', '=',
> 'Taiwan'), ('partner_id.name', '=', 'ASUStek'), '&',
> ('address_invoice_id.country_id.name', '=', 'Belgium'),
> ('partner_id.name', '=', 'Distrib PC'), ('state', '=', 'open'),
> ('type','=', ^ SyntaxError: unexpected EOF while parsing
>
> So it's clearly linked to my problem ! I guess we are getting closer to
> finding the issue !

That's 251 chars in the expression so far.. Magic number! ;)

--
Say NO to spam and viruses. Stop using Microsoft Windows!

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

domain is limited to 240 char on actions, will be replaced by a text in trunk

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

the size of a domain and context on actions is limited to 240 chars

Changed in openobject-server:
status: New → Invalid
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Ok, the problem was very stupid : the "domain" field was limited to 250 characters !!!
For what I want to do, I need 415 caracters ! Enclosed is a patch to limit the domain field to 1000 characters. I tested this patch and it works fine on OpenERP server v6.0.

Changed in openobject-server:
status: Invalid → In Progress
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Fabien, I saw your comments after sending my last comment with the patch. Converting the domain field on actions from char with size=250 to a text field is a great idea. Thanks for your help !

Changed in openobject-server:
status: In Progress → Triaged
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

I had a look at the code currently in trunk (server-trunk/openerp/addons/base/ir/ir_actions.py and server-trunk/openerp/addons/base/base.sql) and I see the 'domain' field is still a char(250) and has not been converted to a text field, as proposed by Fabien.

It would be great to have this change in trunk before the release of OpenERP 6.1 !

Revision history for this message
Antony Lesuisse (OpenERP) (al-openerp) wrote :

We plan to make varchar size optional for 6.2 when varchar size is not specified it will be unlimited. But also I dont think it is reasonable to define such long domains on actions use ir_filters to do that.

Changed in openobject-server:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.