Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
152 Vizualizări

How to hide/remove an "Add a line" in transfers when the status is done/cancelled?


Version: odoo 18 e+

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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>
Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

Thanks! Sandeep

Related Posts Răspunsuri Vizualizări Activitate
1
nov. 24
19447
5
aug. 24
3351
0
aug. 22
12770
0
ian. 22
2820
1
mar. 25
4794