python-3.x - 在 Odoo 的字段中显示警报图标?
问题描述
如果partner_id的税号为空,我想在partner_id (客户)字段中显示一个警报图标。如果给出了未来日期,该图标应该类似于我们在发票日期中看到的图标。
应显示图标的条件
- 如果partner_id的类型是个人并且具有parent_id ( Company ),则应从 parent_id 而不是从 parntner_id 中选择税号。因此,如果 parent_id 的税号为空,则应显示警报图标。
- 如果 partner_id 是个人且没有 parent_id(company),则应从 partner_id 中选择税号。如果它是空的,应该显示一个警告图标。
- 如果 partner_id 是公司类型并且没有税号,则应显示一个图标。
我怎样才能实现这样的功能?
解决方案
您可以添加一个 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 吗?
推荐阅读
- javascript - 如何使用引导日期选择器在您的应用程序中获取正确的日期格式?
- java - java.io.FileNotFoundException:(只读文件系统)Mac
- github - 通过 GitHub 仅在自定义域的子目录上运行 Jekyll
- vb.net - 当用户输入的值不在 00:00 和 23:59 之间时,我想显示错误,但我收到错误
- visual-studio - PUBLISH 按钮未出现在上下文菜单上
- c - C 中的函数仅在存在不相关行时才起作用
- reactjs - Redux 存储呈现倍数状态。正常吗?
- reactjs - jHipster + react 应用程序,将登陆页面更改为新页面
- php - Laravel 验证:如何验证两个相关的外键是否对应
- python - 如何在 Python 中使用分水岭算法分离图像