Skip to Content
Menu
This question has been flagged
7 Replies
21667 Views

models

class Lead(models.Model):

    _inherit = 'crm.lead'

    service_id = fields.Many2one('lmc.service', required=True, string="Service")

class SaleOrder(models.Model):

    _inherit = "sale.order"

   service_id = fields.Many2one('lmc.service', required=True, string="Service")

Notes

I want to pass service_id of lead to sale order when the New Quotation button(action) button is clicked.I worked in similar situation, but sometimes I pass values from one module to another using object button.please help me how it is possible through action button

Reference

This is the button in lead 

<button string="New Quotation" name="%(sale_action_quotations_new)d" type="action" class="oe_highlight"

                        context="{'search_default_partner_id': partner_id,

                                  'default_partner_id': partner_id,

                                  'default_team_id': team_id}"/>

that id used in sale order and defined like this


<record id="sale_action_quotations_new" model="ir.actions.act_window">

        <field name="name">Quotation</field>

        <field name="res_model">sale.order</field>

        <field name="view_mode">form,tree,graph</field>

        <field name="domain">[('opportunity_id', '=', active_id)]</field>

        <field name="context">{'search_default_opportunity_id': active_id, 'default_opportunity_id': active_id}</field>

    </record>

How to pass values through this button.Thanks in advance

Avatar
Discard
Best Answer

Hello,

just add to/ redefine the context in a button required parameter with 'default_' prefix. E.g.:

<button string="New Quotation" name="%(sale_action_quotations_new)d" type="action" class="oe_highlight"
                        context="{
        'default_service_id': service_id,
       'search_default_partner_id': partner_id,
        'default_partner_id': partner_id,
        'default_team_id': team_id}"/>



Avatar
Discard
Author

Thanks IT Libertas for the answer.

Author

I try to hide New Quotation button like this

<xpath expr="//button[@name='%(sale_action_quotations_new)d']" position="attributes">

<attribute name="invisible">1</attribute>

But there is an error external id not found.is possible to hide action button like object button

Best Answer

I did not create a new button. However, I had to overwrite the context of the original button and in fact I would just like to increment the context of the button without having to overwrite.

<record id="workshop_vehicle_crm_opportunity_form_view_inherit" model="ir.ui.view">
<field name="name">workshop.vehicle.crm.opportunity.form.inherit</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">

<button name='%(sale_crm.sale_action_quotations_new)d' position='attributes'>
<attribute name="context">{
'search_default_partner_id': partner_id,
'default_partner_id': partner_id,
'default_team_id': team_id,
'default_campaign_id': campaign_id,
'default_medium_id': medium_id,
'default_source_id': source_id,
'default_vehicle_id': vehicle_id,
}
</attribute>
</button>

<xpath expr="//field[@name='partner_id']" position="after">
<field name="vehicle_id" string="Vehicle"/>
</xpath>
</field>
</record>
Avatar
Discard
Best Answer

Hello Muhammed. for Your action button hiding query -->  You may replace it with attributes="replace" . eg:   <xpath expr="//button[@name='%(sale.action_quotations_salesteams)d']" position="replace"/>
I have not seen action hiding button in the base code itself. 

Avatar
Discard
Author

Thanks Annadurai

welcome :)

Related Posts Replies Views Activity
1
Mar 21
3349
2
Jul 18
2358
3
Mar 15
8262
2
Apr 24
3870
2
Feb 23
1607