首页 > 解决方案 > 在 Odoo 的字段中显示警报图标?

问题描述

如果partner_id的税号为空,我想在partner_id (客户)字段中显示一个警报图标。如果给出了未来日期,该图标应该类似于我们在发票日期中看到的图标。

在此处输入图像描述

应显示图标的条件

我怎样才能实现这样的功能?

标签: python-3.xxmlodooodoo-13

解决方案


您可以添加一个 onchange 方法,如果您更改合作伙伴,则会显示图标,但如果您想要日期图标,它有点长,因为它是一个小部件

适合这样的方法

class AccountInvoice(models.Model):
    _inherit = 'account.invoice' 

    @api.onchange('partner_id')
    def tax_check(self):  
        if self.partner_id.parent_id and self.partner_id.company_type == 'person':
            if not self.partner_id.parent_id.vat :
              #  display your icon
            else:
               # chose the tax for parent_id
        elif not self.partner_id.parent_id and self.partner_id.company_type == 'person':
            if self.partner_id.vat :
                # chose the tax in partner_id
            else:
                #  afficher votre icone 
        elif not self.partner_id.vat and self.partner_id.company_type == 'company':
            #  display your icon

您想在报告中显示 TaxID 吗?


推荐阅读