Hi,
I give the smart button of create RFQ
Py file
class createRfq (models.Model):
_inherit = 'product.template'
create_rfq = fields.Integer ('RFQ')
def action_view_rfq (self):
products = self.mapped ('product_variant_ids')
action = self.env.ref (' purchase.purchase_form_action '). read () [0]
if products and len (products) == 1:
action ['context'] = {'default_product_id': products.ids [0], 'search_default_product_id': products.ids [0], 'default_partner_id' : 16}
else:
action ['domain'] = [('product_id', 'in', products.ids)]
action ['context'] = {}
return action
Xml file
<odoo>
<record model = "ir.actions.act_window" id = "create_rfq">
<field name = "context"> {'default_product_id': active_id, 'search_default_product_id': active_id} </field>
<field name = " name "> Reordering Rules </field>
<field name =" res_model "> purchase.order </field>
</record>
<record id =" product_template_form_create_rfq_button "model =" ir.ui.view ">
<field name =" name "> product.template.procurement </field>
<field name =" model "> product.template </field>
<field name =" inherit_id "ref = "product.product_template_only_form_view" />
<! - <field name = "groups_id" eval = "[(4, ref ('mrp.group_mrp_user'))]" /> ->
<field name = "arch" type = "xml">
<button name = "toggle_active" position = "before">
<button type = "object" name = "action_view_rfq" class = "oe_stat_button" icon = "fa-refresh" >
<field name = "create_rfq" widget = "statinfo" />
</button>
</button>
</field>
</record>
</odoo>
Thanks