如何创建向导openerp?

时间:2014-04-11 06:59:50

标签: xml openerp

我正在研究向导,问题是我没有弹出屏幕。

from osv import fields, osv

import datetime

class wiz_file(osv.osv_memory):

    _name = 'wiz_test'
    _columns = {
               'dob':fields.date('Date of birth'),
               'name':fields.char('Name', size=30),
               'gender':fields.selection([('female','Female'), ('male','Male')], string='Gender'),
                }


    _defaults = {}

    def wizfun(self, cr, uid, ids, context=None):
        res=self.pool.get('client.client')
        dt = res.cp1val()
        if dt > 0:
           print "GREATER"
        else:
            raise osv.except_osv('CP1VAL less than 0')
        return res    

wiz_file()

------------------- XML ----------------

<record id="test_wizard" model="ir.ui.view">
    <field name="name">wiz_test_form</field>
    <field name="model">wiz_test</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
        <form string="wizard_form">
            <group col="8">
                <field name="name" string="NAME"/>
                <field name="gender" string="GENDER"/>
                <field name="dob" string="DATE OF BIRTH"/>
            </group>
            <button string="Cancel" special="cancel" icon="gtk-cancel"/>
            <button string="Cleanup" name="cleanup" type="object" icon="gtk-ok"/>
        </form>
    </field>
</record>

<record id="acton_wizard" model="ir.actions.act_window">
    <field name="name">Wizards</field>
    <field name="type">ir.action.act_window</field>
    <field name="res_model">wiz_test</field>
    <field name="view_type">form</field>
    <field name="view_mode">form</field>
</record>

<act_window
    id="action_test_wizard"
    name="Test wizard"
    res_model="wiz_test"
    src_model="client.client"
    view_type="form"
    view_mode="form"
    key2="client_action_multi"
    target="new"
    multi="True"
    />

1 个答案:

答案 0 :(得分:1)

如果您只想在弹出窗口中打开向导表单,则必须在操作中添加字段目标:

<record id="acton_wizard" model="ir.actions.act_window">
  <field name="name">Wizards</field>
  <field name="type">ir.action.act_window</field>
  <field name="res_model">wiz_test</field>
  <field name="view_type">form</field>
  <field name="view_mode">form</field>

  <field name="target">new</field> <!-- default is current -->

</record>