odoo12动作里添加向导
Posted 1314520xh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了odoo12动作里添加向导相关的知识,希望对你有一定的参考价值。
在odoo12的 动作里添加向导
例子1:只会在tree视图里显示,不会在form里显示
<act_window id="action_change_stage_ttest"
name="测试菜单"
src_model="sale.task"
res_model="test.project.shadow.wizard"
view_mode="tree,form"
view_type="form"
target="new"
key2="client_action_multi"
multi="True"
/>
例子2:会在form和tree视图里显示,
<record id="action_change_stage_ttest_inv" model="ir.actions.act_window">
<field name="name">测试任务</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">test.project.shadow.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<!-- TODO: check if we need this -->
<field name="binding_model_id" ref="sale.model_project_task" />
</record>
对应的向导
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo.exceptions import UserError
from odoo.tools.translate import _
import xlrd, base64, datetime
import psycopg2
class TESTProjectShadowWizard(models.TransientModel):
_name = ‘test.project.shadow.wizard‘
_description = u‘测试‘
date_plan = fields.Date(string=u‘计划日期‘)
date_done = fields.Date(string=u‘完成日期‘)
employee_id = fields.Many2one(‘hr.employee‘, string=u‘新人‘ ,track_visibility=‘onchange‘)
@api.multi
def btm_confirm(self):
pass
对应视图:
<record id="test_project_shadow_wizard_form" model="ir.ui.view">
<field name="name">test.project.shadow.wizard.form</field>
<field name="model">test.project.shadow.wizard</field>
<field name="arch" type="xml">
<form>
<group>
<group>
<field name="employee_id" />
<field name="date_plan" />
<field name="date_done" />
</group>
</group>
<footer>
<button name="btm_confirm" string="确认" type="object" class="oe_highlight"/>
or
<button special="cancel" string="取消" class="oe_link"/>
</footer>
</form>
</field>
</record>
例子2:会在form和tree视图里显示,
<record id="action_change_stage_test_inv" model="ir.actions.act_window">
<field name="name">测试任务</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">test.project.shadow.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<!-- TODO: check if we need this -->
<field name="binding_model_id" ref="sale.model_sale_task" />
</record>
以上是关于odoo12动作里添加向导的主要内容,如果未能解决你的问题,请参考以下文章