Hi All,
We have an Accept & Sign button in the sale order portal.
I want to disable this button if the is user is logged in, this is because the button for customer not for internal user.
So I inherited the sale_order_portal_content template the tried the disable the button but it is not working.
below that attached one.
Why getting xpath error
I also tried with a different xpath
Below I have attached the actual template.
What I'm doing wrong here?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
Hii,
Use t-if + group check
To fully remove the button for internal users please try below code:
<template id="cw_sale_order_portal_content_inherit" inherit_id="sale.sale_order_portal_content">
<xpath expr="//span[@id='shipping_address']/h5" position="replace">
<h5 class="mb-1">Delivery Address</h5>
</xpath>
<xpath expr="//a[contains(normalize-space(text()), 'Accept & Sign')]" position="replace">
<t t-if="not request.env.user.has_group('base.group_user')">
<a href="/my/orders/accept" class="btn btn-primary">Accept & Sign</a>
</t>
</xpath>
</template>
base.group_user → This is the internal user group.
So not request.env.user.has_group('base.group_user') means: show this only to non-internal users → portal or public .
i hope it is use full
I'm getting xpath error
Element '<xpath expr="//a[contains(normalize-space(text()), 'Accept & Sign')]">' cannot be located in parent view
Try this improved XPath:
<xpath expr="//a[contains(@href, '/accept') and contains(@class, 'btn-primary')]" position="replace">
<t t-if="not request.env.user.has_group('base.group_user')">
<a href="/my/orders/accept" class="btn btn-primary">Accept & Sign</a>
</t>
</xpath>
contains(@href, '/accept') → Matches the route of the button.
contains(@class, 'btn-primary') → Ensures it's the actual button.
If you're unsure of the structure:
Go to Developer Tools in your browser (F12).
Inspect the "Accept & Sign" button.
Confirm the structure and attributes — like href, class, or even id.
please try this
Thanks, but your xpath is also not working.
error solve?
Yes
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
2
มี.ค. 22
|
5260 | ||
|
1
มี.ค. 15
|
4220 | ||
|
1
มี.ค. 15
|
7550 | ||
|
2
ต.ค. 22
|
6445 | ||
|
0
พ.ย. 20
|
3249 |