@api.multi
def action_undo_history(self):
history_obj = self.env['membership.history']
for reg in self:
history_ids = history_obj.search([('name_id', '=', reg.name_id.id)], history_ids[0].date)
history_ids = self.env['membership.history'].search([('name_id', '=', reg.name_id.id)], order='date desc')
current_state = reg.name_id.state
history_state = reg.state_new
if history_ids[0] == reg and current_state == history_state:
reg.name_id.state == reg.state_old
else :
message = _("Only the latest history can be cancelled !")
mess= {
'title': _('Error : Cancelling State'),
'message' : message
}
return {'warning': mess}
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
1
ตอบกลับ
12204
มุมมอง
Hi,
You are getting this error because you are accessing the value from the field named history_ids in this line of the code before defining the field.
history_ids = history_obj.search([('name_id', '=', reg.name_id.id)], history_ids[0].date)
but, you haven't assigned what value should that variable hold. You should update your code such a way that you have to define the variable before using it.
for reg in self:
history_ids = ?
history_ids = history_obj.search([('name_id', '=', reg.name_id.id)], history_ids[0].date)
history_ids = self.env['membership.history'].search([('name_id', '=', reg.name_id.id)], order='date desc')
Thanks
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
1
ก.ค. 23
|
3005 | ||
|
2
ก.ค. 22
|
9155 | ||
|
1
พ.ค. 22
|
3118 | ||
|
1
มิ.ย. 21
|
2448 | ||
[SOLVED] Get related field
แก้ไขแล้ว
|
|
2
ก.พ. 21
|
299 |