Hello
I have one button in sale order, I also set on change for this button to set visible or invisible (readonly),
When I create a sale order and add one product in the sale order line.
My problem was that my button will readonly still I'll not save the sale order.
What should I do, if I want to make visible this button and I can open wizard using this button without saving the sale order.?
Here my code:
Py:
def onchange_check_related_product (self):
for order_line in self:
if order_line.product_id.cross_product_ids:
order_line.is_related_product = True
else:
order_line.is_related_product = False
is_related_product = fields.Boolean ('Is Related')
is_related_product = fields.boolean ( ' Is Related ' )
XML:record model = "ir.ui.view" id = "sale_order_cross_product_view">
<field name = "name"> sale.order.cross.product.view </ field>
<field name = "model"> sale.order </ field>
<field name = "inherit_id" ref = "sale.view_order_form" />
<field name = "arch" type = "xml">
<xpath expr = "// notebook / page [@ name = 'order_lines'] / field [@ name = 'order_line'] / tree / field [@ name = 'product_id'] "
position =" after ">
<field name =" is_related_product "invisible =" 1 "/>
<button type ="object "name =" action_cross_sell "string =" Cross Sell "
icon =" fa-th-list "
attrs = "{'invisible': ['|', ('state', 'not in', ['draft', 'sent']), ('is_related_product', '=', False)]}"> < / button>
</ xpath>
</ field>
</ record>