In odoo 18. Navigate to projects -> Project A dashboard -> Tasks -> Task A Form View. When i click New to create a new task, the new task form view shows with Sales Order Item field is prefilled by the sale order item of the project. I want to change this behaviour so that the Sales Order Item field is not prefilled by default.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- โปรเจกต์
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
Hi,
When creating a new task from the Project dashboard, Odoo automatically passes certain context values — such as sale_line_id — especially if the task is being created from a related Sales Order. If you want to remove the sale_line_id from the context to make the task independent of the sale order, you can override the context in your custom module.
Here’s how you can handle it:
Inherit the Action or Button:
Go to Settings → Technical → Views and locate the action used for creating tasks.
Override the Context:
In your custom module, inherit this action and remove the sale_line_id from its context:
<record id="action_view_task_custom" model="ir.actions.act_window">
<field name="inherit_id" ref="project.action_view_task"/>
<field name="context">{'default_sale_line_id': False}</field>
</record>
Alternative:
You can also override the create method of the task model and simply pop the key:
@api.model
def create(self, vals):
vals.pop('sale_line_id', None)
return super(ProjectTask, self).create(vals)
This ensures that the sale_line_id won’t be linked automatically when creating new tasks from the dashboard.
Hope it helps
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อ| Related Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
|---|---|---|---|---|
|
|
1
ก.พ. 25
|
1725 | ||
|
|
0
ต.ค. 25
|
3 | ||
|
|
3
ต.ค. 25
|
3850 | ||
|
|
2
ก.ย. 25
|
1178 | ||
|
|
2
ก.ย. 25
|
2029 |