How to hide/remove an "Add a line" in transfers when the status is done/cancelled?
Version: odoo 18 e+
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
How to hide/remove an "Add a line" in transfers when the status is done/cancelled?
Version: odoo 18 e+
Hello,
This will hide the "Add a line" in transfers when the status is done/cancelled.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_picking_form_inherit_restrict_new" model="ir.ui.view">
<field name="name">stock.picking.restrict.new</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_ids_without_package']" position="attributes">
<attribute name="options">{'create':[('state','not in',['done','cancel'])]}</attribute>
</xpath>
</field>
</record>
</odoo>
Hi,
Please refer to the code:
<record id="view_picking_form_inherit" model="ir.ui.view">
<field name="name">stock.picking.form.inherit.disable_add_line</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_line_ids']" position="attributes">
<attribute name="readonly">state in ['done','cancel']</attribute>
</xpath>
</field>
</record>
When state is done or cancel, the field becomes readonly, so users cannot add new lines, and the “Add a line” button disappears automatically.
Hope it helps.
Hello Vashmitha, here's how to remove or hide the "Add a line" option in transfers when the status is 'Done' or 'Cancelled'.
This happens because the default Odoo views allow modifications unless explicitly restricted based on status.
To hide the "Add a line" button, you'll need to customize the view for stock transfers. Here’s a common approach:
First, activate developer mode in Odoo.
Next, navigate to the transfer form view (Inventory -> Operations -> Transfers) and edit the view using the "Edit View: Form" option in the Developer Tools dropdown.
Add a condition to the button's `attrs` attribute to make it invisible when the state is 'done' or 'cancelled'. For example:
`<button name="action_add_line" string="Add a line" type="object" attrs="{'invisible': ['|', ('state', '=', 'done'), ('state', '=', 'cancelled')]}"/>`
Alternatively, you can remove the button entirely from the view if it's not needed in those states.
For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html
Hello Vashmitha, here's how you can remove or hide the "Add a line" option in transfers when the status is 'Done' or 'Cancelled'.
This happens because the default Odoo views allow modifications unless explicitly restricted based on status.
To remove the "Add a line" option, you'll need to customize the view for stock.move.line objects.
First, inherit the relevant form view in a custom module. Identify the view using "Inspect View" from the Odoo developer tools.
Next, add a condition to hide the button based on the state of the transfer. For example:
<xpath expr="//button[@name='action_add_line']" position="attributes">
<attribute name="invisible">state in ('done', 'cancel')</attribute>
</xpath>
Finally, update your module and check the transfer view in 'Done' or 'Cancelled' states to ensure the button is hidden.
For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html
Thanks! Sandeep
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 11 24
|
19447 | ||
|
5
thg 8 24
|
3351 | ||
|
0
thg 8 22
|
12770 | ||
|
0
thg 1 22
|
2820 | ||
|
1
thg 3 25
|
4794 |