pythonodoo

odoo 表单按钮显示数量

2020-05-25  本文已影响0人  隔壁小红馆

在form视图中添加按钮,并显示关联此单据的数量


image.png image.png
<button type="object" name="action_view_technical"
  class="oe_stat_button" icon="fa-pencil"
  attrs="{'invisible': [('technical_count', '=', 0)]}">
  <field name="technical_count" widget="statinfo" string="技术评审 
  单"/>
</button>
technical_count = fields.Integer(string='Delivery Orders', compute='_compute_technical_count')
@api.depends('technical_count')
    def _compute_technical_count(self):
        technical = self.env['technical.review'].search([('sale_id', '=', self.id), ('state', '!=', 'scrap')])
        self.technical_count = len(technical)
    def action_view_technical(self):
        self.ensure_one()
        action = self.env.ref('master_production_plan.technical_review_action').read()[0]
        action['domain'] = [('sale_id', '=', self.id)]
        action['context'] = dict(self._context, default_origin=self.name)
        return action

即可正确显示

制作不易,点赞鼓励哈

上一篇 下一篇

猜你喜欢

热点阅读