콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
8 답글
4294 화면

Hello to all

I would like to have a readonly on stage fields with Studio (Odoo online 13). Only modify under some conditions.

By example :

IF

stage=1 (New) OR the probability is under 10% OR x_studio_financial_fiability is not true 

THEN

readonly on change stage

IF ON stage=2 (Qualified) 

the probability is under 40% OR  x_studio_applicable_legals is not true   

THEN

readonly on change stage  

...


This is what I have writing but it does'nt work :

["|","|","|","|","&",["stage_id","=",1],"|",["x_studio_financial_fiability","!=",True],["planned_revenue","=",0],"&",["stage_id","=",2],"|","|","|",["x_studio_financial_fiability","!=",True],["planned_revenue","=",0],["probability","<",40],["x_studio_applicable_legals","=",False],"&",["stage_id","=",3],"|","|","|",["probability","<",40],["x_studio_financial_fiability","!=",True],["x_studio_applicable_legals","=",False],["x_studio_qualified_bu_director","!=",True],"&",["stage_id","=",4],"|","|","|","|","|",["probability","<",40],["x_studio_financial_fiability","!=",True],["x_studio_applicable_legals","=",False],["x_studio_qualified_bu_director","=",True],["x_studio_proposition_bu_director","=",True],["x_studio_proposition_ceo","=",True],"&",["stage_id","=",5],"|","|","|","|","|",["probability","<",40],["x_studio_financial_fiability","!=",True],["x_studio_applicable_legals","=",False],["x_studio_qualified_bu_director","=",True],["x_studio_proposition_bu_director","=",True],["x_studio_proposition_ceo","=",True]]

Is it clear ?

Thanks by advance !

아바타
취소

Thanks for answer Chris.

For the 1st, I don't have problem. It's when I want to cumulate conditions that I have some troubles

Could you use Automated Actions instead? That might be easier to setup:

https://www.odoo.com/forum/help-1/question/13232/#answer-147170

I prefer manual action

Automated Actions can allow you to define rules (e.g. cannot move to stage 5 unless it has been qualified by the BU Director and probability > 40%). I think it's quite challenging to put all of that into a domain statement as per your question.

https://odootricks.tips/automated-actions/

Thanks Chris ! It's exactly that ! Thanks so much.

Now I have another problem for give the right access to just 1 group

Suggest you ask another question about access rights with details of what you need.

Chris,

I want to block the access to some fields (like an approval on/off button). Only users with special rights can write on this checkbox. Others users must have readonly rights.

I have trying to do invisible fields for groups but it's not realy that I want, it's not realy user friendly and not UX

I found a solution that works in Odoo 12, but not in Odoo 13. Will try to see whether it can be adapted for Odoo 13!

This is the way to make a field read-only based on user access groups: https://odootricks.tips/odoo-studio-field-attributes-based-on-user-access-groups/

베스트 답변

Original answer: 

I don't fully understand your logic, but your first condition should be:

["|","|", 
    ["stage_id","=",1],
    ["probability","<",40],                  
    ["x_studio_financial_fiability","!=",True]
]

One way to get familiar with the notation is to create user-defined filters through the standard Odoo front-end, and you can see what Odoo generates for various combinations of operators and conditions.  

https://odootricks.tips/domain-in-odoo/

----------------------------------------------

Revised answer: I think that rather than trying to put all that logic into one long domain expression it's easier to use Automated Actions for validation  (details and screenshots in link).

As an example, I added an Automated Action on crm. lead (which already has stages)

Trigger condition: On Update

Action To Do: Execute Python Code

Python Code:

# Require Financial Viability
if record.stage_id.name in ['Qualified', 'Proposition', 'Won'] and not record.x_studio_financial_viability:
raise Warning('Please check Financial Viability for this Opportunity!')

# Require Legal Approval
if record.stage_id.name in ['Proposition', 'Won'] and not record.x_studio_legal_approval:
raise Warning('Please check Legal Approval for this Opportunity!')

----------------------------

Part three: Control field attributes based on User Access Groups

아바타
취소
관련 게시물 답글 화면 활동
1
10월 24
2011
1
10월 24
5552
2
10월 24
3340
1
7월 24
2618
0
6월 24
1371