Skip to Content
Menu
This question has been flagged
3 Replies
1436 Zobrazenia

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!?



Avatar
Zrušiť
Autor Best Answer

Eval does the work!


Avatar
Zrušiť
Best Answer

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'),
]


Avatar
Zrušiť
Best Answer

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

Avatar
Zrušiť