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

in the past we had @api.constraint function that checks amount_total of purchase_order. If some condition was true it raised an ValidationError. This worked fine.


But now we need some other logic that only shows a Warning-Messagebox when Save-Button is clicked in purchase order (if some condition is true), but the Save-Logic still should go On. Raising a ValidationError stops this logic.


can this be achieved with @aoi.constraint? Any other ideas to make such logic?


아바타
취소

I doubt you can do this... not with the default Save/Create buttons.

베스트 답변

No, there is no proper way to achieve it. 
once the odoo raise the error it will rollback cursor on dispatch and nothing will save.

so before raise the error if you explicitly commit the cursor using (self.env.cr.commit()) it will save the record. but the client still raise the warning  (view stay in edit mode because it receives warning instead of True/False value of write)

it's a hack I don't recommend it to use until it absolutely necessary.
move the logic from api.constrains to api.onchange seems a good alternative

아바타
취소
베스트 답변

Hi Jack:

You can define an Automated Action for this. Activate developer mode and go to Settings > Technical > Automated Actions. Specify the details per our need. For the Action To Do, select Execute Python Code and you should be able to write code to raise a Warning which will popup a message but allow the user to proceed.


아바타
취소
작성자

we just have "scheduled actions", but i do not find "Automated Actions". is this a enterperise feature?

I asked similar question, and the answer was that it does not give you the option to save. It will stop the process.

@Jack The "Automated Action Rules" module will need to be installed.

베스트 답변

raise warning


import odoo.exceptions
raise Warning(_('msg'))

아바타
취소
작성자

no if i use this within the @api.constraint it will stop saving the purchase.order.

i want a PopUp Message but still save the purchase.order

You raise a warning 
Not constraint 

On Tue, Nov 5, 2019, 7:53 PM Jack <lorenz.strouhal@mediatesystems.at> wrote:

no if i use this within the @api.constraint it will stop saving the purchase.order.

i want a PopUp Message but still save the purchase.order

Gesendet durch Odoo S.A. in benutzung Odoo.