When opening the view_stock_move_line_operation_tree view from within receiving on a lot controlled item. The Lot Name field and the button are displayed. The user can enter a lot number manually (which is OK), however the following button cannot be selected.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_stock_move_line_operation_tree_inherit_szm" model="ir.ui.view">
<field name="name">stock.move.line.operations.tree.inherit.szm</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='lot_name']" position="before">
<button name="action_create_custom_lot_no_szm" type="object" class="btn btn-primary fa fa-plus-square-o" groups="stock.group_production_lot" context="{'default_company_id': parent.company_id, 'default_product_id': parent.product_id, 'active_picking_id': picking_id}" attrs="{'invisible': [('lot_id', '=', False),('lot_name', '!=', False)]}"/>
</xpath>
</field>
</record>
</odoo>
Sudhir,
The record is "saved" and ready for receipt, but the lot number needs to be entered first. The "Button" is designed to automatically create a lot number based on other rules. I just cannot figure out why the the button is inactive.
Thank you for replying.
It is inactive because of the attrs condition.
attrs="{'invisible': [('lot_id', '=', False),('lot_name', '!=', False)]}"
Odoo does not hide the field/button in the tree view when you use invisible in attrs but instead, it will make the field read-only and button inactive.
Your button is inactive because I think lot_id is blank and lot_name has value. Please double-check this.
I think you are trying to click on the button before saving the record.
You need to first save the record and then you will be able to click on a button otherwise, the button will be inactive.