2017-09-13 13 views
0

J'ai essayé de nombreuses façons d'afficher le bouton "Lettre d'offre" uniquement lorsqu'un client est enregistré. Mais il semble que je ne reçois pas la condition ici:Condition d'affichage d'un bouton d'en-tête uniquement après la sauvegarde d'un client

<xpath expr="//form/*" position="before"> 
        <header> 
         <button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight" 
           attrs="{'invisible':[('what condition?')]}"/> 
        </header> 
       </xpath> 

Ci-dessous mon extrait de code:

Le modèle:

class res_partner(models.Model): 
    _inherit = 'res.partner' 

    baf = fields.Boolean("Application Form", help="Specify customer who bought application form") 

    @api.multi 
    def offer_letter_method(self): 
     return self.env['report'].get_action(self, 'sales_custom.offer_letter_view') 

La vue:

<record model="ir.ui.view" id="customer_custom_form_view"> 
      <field name="name">customer.custom</field> 
      <field name="model">res.partner</field> 
      <field name="inherit_id" ref="base.view_partner_form"/> 
      <field name="arch" type="xml"> 
       <xpath expr="//form/*" position="before"> 
        <header> 
         <button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight" 
           attrs="{'invisible':[('what condition?')]}"/> 
        </header> 
       </xpath> 
       <xpath expr="//field[@name='name']" position="after"> 
        <field name="baf"/> 
        <label for="baf"/> 
       </xpath> 
      </field> 
     </record> 

Veuillez aider.

Répondre

2

Vous devriez essayer comme suivant:

<record model="ir.ui.view" id="customer_custom_form_view"> 
    <field name="name">customer.custom</field> 
    <field name="model">res.partner</field> 
    <field name="inherit_id" ref="base.view_partner_form"/> 
    <field name="arch" type="xml"> 
     <xpath expr="//form/*" position="before"> 
      <header> 
       <button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight" 
         attrs="{'invisible':[('id','=',False)]}"/> 
         <field name="id" invisible="1"/> 
      </header> 
     </xpath> 
     <xpath expr="//field[@name='name']" position="after"> 
      <field name="baf"/> 
      <label for="baf"/> 
     </xpath> 
    </field> 
</record>