Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
13919 Widoki

Hello, I know my question seems kinda dumb (there is an attribute "domain" so what's the point ?) but here's my problem:

I created a default filter:

<filter string="My Validations" icon="terp-personal" name="my_validations"
domain="['|',('employee_id.parent_id.user_id','=', uid),'&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]"
help="My validations"/>

with this domain, I have no problem, but it's not exactly what I want ... i want to add an other constraint: state = confirm so I tried many things and nothing worked (in order to have something like ( employee.parent AND state confirm) OR (employee.coach AND state validate1)

domain="['&amp;',('employee_id.parent_id.user_id','=', uid),'|',('state','=','confirm'),'&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]" 

This one works, but only for the first part (employee.parent and confirm), the second one is not seen.


domain="['|',('&amp;',('employee_id.parent_id.user_id','=', uid),('state','=','confirm')),('&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1'))]"  

This one throw an error " Invalid leaf ['&', ['employee_id.parent_id.user_id', '=', 316], ['state', '=', 'confirm']]"


domain="['|',['&amp;',('employee_id.parent_id.user_id','=', uid),('state','=','confirm')],['&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]]"   

And this one throw an error "TypeError:results.groupby is undefined"

And I'm lost ... I don't know what to try now ...

Please ... Help ç_ç


Awatar
Odrzuć
Najlepsza odpowiedź

a problem is that you're trying to use wrong notation, you've to write odoo domains using prefix notation.

The main advantage of prefixed/postfixed operators are to avoid to use brackets for determine a sequence of calculation. in these domains there is used prefixed notation, so each operator takes it's following operands. there is no need to use extra brackets.

I'll take fseudocode from your question and transform it step by step:

you wrote

in order to have something like ( employee.parent AND state confirm) OR (employee.coach AND state validate1)

(BTW you've written above statement using infix notation, in order to get worked it in odoo domains, we've to transform it into the prefix notation)

first transform statements in the brackets, move AND condition to the start of each of them:

(AND, employee.parent , state confirm) OR ( AND, employee.coach , state validate1) 

-here AND takes it's two following arguments, then it's caclulated and considered as argument for OR.  (same for another AND), now move the OR operator to the left of it's arguments:

OR, (AND, employee.parent , state confirm),( AND, employee.coach , state validate1)

but here brackets are extra, they can't determine anything in rapport of sequence of calculation, each AND takes it's following two operands(as binary operator), and OR takes it's following two operands as well (results of two AND). so now we remove brackets, and your fseudo statement will become something as:

OR, AND, employee.parent , state confirm, AND, employee.coach , state validate1

-it's prefix notation equivalent of your infix notation fseudostatement.

of course you'll have some other brackets in real domain statement, but not the ones used for sequence/prioritize calculations.

you'll have something like:

domain="['|','&amp;',('employee_id.parent_id.user_id','=', uid),('state','=','confirm'),'&amp;',('employee_id.coach_id.user_id','=',uid),('state', '=', 'validate1')]" 

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
mar 15
20441
3
lip 20
8073
0
mar 15
3983
3
kwi 23
34010
5
wrz 20
12875