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

Using Odoo 14, I'm preparing some test data in an xml file // data file.




This last line generates the error. How shall I write!?



아바타
취소
작성자 베스트 답변

Eval does the work!


아바타
취소
베스트 답변

schedule_pay field in hr.contract is a related field, and its value comes automatically from the Structure Type.

So you cannot set its value from XML because it will come automatically from the related Structure Type.

Also, if you want to try to pass the value from data XML, you should use its selection key which is as follow:

[
('monthly', 'Monthly'),
('quarterly', 'Quarterly'),
('semi-annually', 'Semi-annually'),
('annually', 'Annually'),
('weekly', 'Weekly'),
('bi-weekly', 'Bi-weekly'),
('bi-monthly', 'Bi-monthly'),
]


아바타
취소
베스트 답변

To select a value for the 'schedule_pay' field using code in Odoo, you can use the write method of the Model class. Here is an example of how you can do this:


Copy co

record = self.env['your.model'].browse(record_id

record.write({'schedule_pay': 'value'}

In this example, your.model is the name of the model that contains the 'schedule_pay' field, and record_id is the ID of the record that you want to update. The write method will update the 'schedule_pay' field of the record with the value 'value'


Note that the write method will only work if the user has the necessary permissions to edit the record. You may need to use the sudo method to execute the write as an administrator if the user does not have sufficient permission


I hope this helps! Let me know if you have any further question

아바타
취소