为什么odoo向导无法从代码中打开并且没有错误?

2024-09-29 01:24:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我在“购买”模块中创建了一个向导,用于检查附件。

该过程是,如果附件数量为0,则create bill按钮应打开一个向导,要求用户上载附件,如果有附件,则按钮应继续其创建账单的常规功能。

问题是向导没有打开,并且没有错误。 下面是函数。 先谢谢你

def action_view_invoice(self):
        if self.attachment_count == 0:
            wiz = self.env.ref(
                'beth_check_attachments.purchase_confirm_attachments')
            view = self.env.ref(
                'beth_check_attachments.purchase_confirm_attachments_form')
       
            return {
                'name': _('Create Bill With No Attachments'),
                'type': 'ir.actions.act_window',
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'purchase.attachment',
                'views': [(view.id, 'form')],
                'view_id': view.id,
                'nodestroy': True,
                'target': 'new',
                'res_id': wiz.id,
                'context': self.env.context,
            }
        else:
            return super().action_view_invoice()

Tags: selfformenvrefviewid附件attachment