When I cancel production in the production model, I want to access the data, but the data does not come from the write method. I am using Odoo 17.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
Hello ahmet@patrion.net,
Explanation of Behaviour :
1) Overriding write Method:
- The write method is triggered whenever a record is updated. This includes updates made by various methods, including action_cancel.
When you click the "Cancel" button, it triggers the action_cancel method, which might involve updating the record’s state.
This update invokes the write method.
2) action_cancel Method:
- This method is responsible for changing the state of the record, usually by calling the write method to update the record’s state to 'done'.
Here, When you call action_cancel, it internally calls write to update the record’s state. That’s why both action_cancel and write methods are invoked.
So, Override the 'action_cancel' method to get the record.
Please find the below snippet code.
//Code in Comment//
Hope this helps.
If you need any help in customization feel free to contact us.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Code :
# -*- coding: utf-8 -*-
from odoo import fields, models, api
class MrpProduction(models.Model):
"""Inherited mrp for customization"""
_inherit = 'mrp.production'
def write(self, vals):
if 'state' in vals:
res = super().write(vals)
return res
def action_cancel(self):
res = super().action_cancel()
return res
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
0
ก.ค. 25
|
402 | ||
|
1
ก.ค. 25
|
788 | ||
|
1
ก.ค. 25
|
1217 | ||
|
0
มิ.ย. 25
|
538 | ||
|
1
มิ.ย. 25
|
1000 |