Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2986 มุมมอง

I have a selection field on a model called hr.overtime.rule like this:

buttons = fields.Selection([('per_day', 'Per Day'), ('monthly', 'Monthly')])

Now I have another model which, based on selected value it should do some computations. The logic is that when it is per_day it should do different computations and when in monthly it should do again different computations and that's why I need to check with an if statement whether is per_day or monthly.


What have I tried:

  • Imported the class to my current working python code: from .hr_attendance_policy import hr_overtime_rule then I checked the value like this: value = hr_overtime_rule.buttons. It works to an extended way, it is just stuck at only one value: monthly

  • Made a Many2one relation field: button_id = fields.Many2one('hr.overtime.rule') it works if you do if not or if but I specifically want either per_day or monthly

Thanks for your time fellas! I'd really appreciate your thoughts into this.


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Have you tried a computed field?

อวตาร
ละทิ้ง
ผู้เขียน

Nope, I haven't tried it. How can I do a computed selection field?

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 22
4119
0
ม.ค. 20
2864
Odoo Selection field issue แก้ไขแล้ว
3
มี.ค. 24
7120
6
ม.ค. 24
13985
0
ธ.ค. 19
2704