我不懂普通波兰语符号(NPN或PN).如何在Odoo中建立一个复杂的域? [英] I don´t understand Normal Polish Notation (NPN or PN). How to build a complex domain in Odoo?

查看:100
本文介绍了我不懂普通波兰语符号(NPN或PN).如何在Odoo中建立一个复杂的域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以将以下波兰语表示法转换为与其对应的SQL:

['|', '&', ('is_company','=', True),('parent_id', '=', False),('company_name', '!=', False),('company_name', '!=', '')]

我的猜测是:

is_company = True OR parent_id = False AND company_name <> False AND company_name <> ''

无论我多么努力地理解它,我都无法理解这种表示法的概念.请帮忙.

更新

我试图将上述表示法扩展为:

((is_company = True AND parent_id = False) OR company_name <> False) AND company_name <> '' AND customer_type_id <> False

解决方案

我完全同意您的观点,每次我必须使用这种波兰语符号来完成一个复杂的领域时,我都必须绞尽脑汁来管理它. /p>

我认为您要查找的域是:

['&amp;', '|', '&amp;', ('is_company', '=', True), ('parent_id', '=', False), ('company_name', '!=', False), '&amp;', ('company_name', '!=', ''), ('customer_type_id', '!=', False)]

我制定了一种获取这些复杂域的方法,并且可以正常工作:

首先,我写一封信,而不是写每个条件:

A => is_company = True => ('is_company', '=', True)
B => parent_id = False => ('parent_id', '=', False)
C => company_name <> False => ('company_name', '!=', False)
D => company_name <> '' => ('company_name', '!=', '')
E => customer_type_id <> False => ('customer_type_id', '!=', False)

然后仅使用字母和标准运算符来构建所需的表达式,而无需考虑波兰语符号和条件:

Step 0. => ((A and B) or C) and D and E

然后,将您应该首先执行的操作分组(暂时不要理会丢失的操作符):

Step 1. => ((A and B) or C) and D and E
Step 2. => (AB or C) and D and E
Step 3. => ABC and D and E
Step 4. => ABC and DE

现在我们只有一个运算符,让我们开始分解它(然后将运算符移到每对条件的左侧),然后按照将操作分组的相反顺序进行操作(例如,从第3步到第4步,将DE分组,因此现在从第4步到第3步,分解DE并将其运算符移到左侧):

Step 4. => and ABC DE
Step 3. => and ABC and D E
Step 2. => and or AB C and D E
Step 1. => and or and A B C and D E

现在更改运算符并添加逗号,引号和方括号:

['&amp;', '|', '&amp;', A, B, C, '&amp;', D, E]

最后,将字母替换为条件,然后您便拥有了域.最好面对面解释它,但也许您能够理解所有内容.

注意:我不会删除&amp;运算符(尽管您不写 它们,Odoo应该默认使用它们),因为我的经验是 在最大的域中,如果我不写&amp;,则域不 工作.我猜这是在很多嵌套条件下发生的, 但是我的建议是总是写它们.

Could someone translate the following polish notation to its SQL counterpart:

['|', '&amp;', ('is_company','=', True),('parent_id', '=', False),('company_name', '!=', False),('company_name', '!=', '')]

My guess is :

is_company = True OR parent_id = False AND company_name <> False AND company_name <> ''

I could not get the concept of this notation no matter how hard I tried to understand it. Please help.

UPDATE

I was trying to extend the above notation to be:

((is_company = True AND parent_id = False) OR company_name <> False) AND company_name <> '' AND customer_type_id <> False

解决方案

I totally agree with you, each time I have to do a complex domain using this kind of Polish notation, I have to rack my brains to manage it.

I think the domain you're looking for is:

['&amp;', '|', '&amp;', ('is_company', '=', True), ('parent_id', '=', False), ('company_name', '!=', False), '&amp;', ('company_name', '!=', ''), ('customer_type_id', '!=', False)]

I made up a method to get these complex domains, and it's working:

First I write a letter instead of each condition:

A => is_company = True => ('is_company', '=', True)
B => parent_id = False => ('parent_id', '=', False)
C => company_name <> False => ('company_name', '!=', False)
D => company_name <> '' => ('company_name', '!=', '')
E => customer_type_id <> False => ('customer_type_id', '!=', False)

Then build the expression you need using only the letters and the standard operators, forget about the Polish notation and the conditions:

Step 0. => ((A and B) or C) and D and E

Afterwards, group the operations you should execute the first (don't mind about the missing operators by the moment):

Step 1. => ((A and B) or C) and D and E
Step 2. => (AB or C) and D and E
Step 3. => ABC and D and E
Step 4. => ABC and DE

Now we have only an operator, let's start decomposing it again (and moving the operator to the left of each couple of conditions), following the reverse order in which you grouped the operations (for example, from step 3 to 4 you grouped DE, so now, from step 4 to 3, decompose DE and move its operator to its left):

Step 4. => and ABC DE
Step 3. => and ABC and D E
Step 2. => and or AB C and D E
Step 1. => and or and A B C and D E

Now change the operators and add the commas, the quotes and the brackets:

['&amp;', '|', '&amp;', A, B, C, '&amp;', D, E]

Finally, replace the letters with the conditions, and there you have your domain. It would be better to explain it face to face but may be you were able to understand everything.

Note: I don't remove the &amp; operators (despite if you don't write them, Odoo should take them by default) because my experience is that with largest domains, if I didn't write the &amp;, the domain didn't work. I guess this happened when there was a lot of nested conditions, but my advice is to write always them.

这篇关于我不懂普通波兰语符号(NPN或PN).如何在Odoo中建立一个复杂的域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆