콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
7 답글
24248 화면

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

아바타
취소
베스트 답변

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}"/>



아바타
취소
작성자

Thanks IT Libertas for the answer.

작성자

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

베스트 답변

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>
아바타
취소
베스트 답변

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. 

아바타
취소
작성자

Thanks Annadurai

welcome :)

관련 게시물 답글 화면 활동
1
3월 21
5035
2
7월 18
3641
3
3월 15
10243
2
4월 24
5221
2
2월 23
3668