仅在保存客户后显示 header 按钮的条件
Condition to display a header button only after a customer have been saved
我已经尝试了很多方法来仅在保存客户时显示 "Offer Letter" 按钮。但似乎我没有得到正确的条件:
<xpath expr="//form/*" position="before">
<header>
<button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight"
attrs="{'invisible':[('what condition?')]}"/>
</header>
</xpath>
下面是我的代码片段:
模特:
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')
观点:
<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>
请提供帮助。
您应该尝试以下操作:
<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>
我已经尝试了很多方法来仅在保存客户时显示 "Offer Letter" 按钮。但似乎我没有得到正确的条件:
<xpath expr="//form/*" position="before">
<header>
<button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight"
attrs="{'invisible':[('what condition?')]}"/>
</header>
</xpath>
下面是我的代码片段:
模特:
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')
观点:
<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>
请提供帮助。
您应该尝试以下操作:
<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>