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
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-seRelated Posts | Respostes | Vistes | Activitat | |
---|---|---|---|---|
|
1
de nov. 24
|
19442 | ||
|
5
d’ag. 24
|
3349 | ||
|
0
d’ag. 22
|
12768 | ||
|
0
de gen. 22
|
2819 | ||
|
1
de març 25
|
4793 |