odoo中如何向用户提示数据?

How to prompt data to the user in odoo?

我正在处理一个表单,我正在尝试获取一个数字,该数字将用于克隆当前数据的次数。

模板

        <record id="form_view" model="ir.ui.view">
            <field name="name">data form</field>
            <field name="model">sf.data</field>
            <field name="arch" type="xml">
                <tree>
                    <field name="name" string="Name" />
                    <field name="age" string="Age"/>
                </tree>
            </field>
        </record>

型号

    class data(models.Model):
        _name = 'sf.data'
        name = fields.Char('Name')
        age= fields.Integer('Age')

有没有办法在模板中设置一个不响应模型的新字段?

显然我需要的是一个向导。我是这样做的:

模板

<record id="wizard_form" model="ir.ui.view">
    <field name="name">test wizard</field>
    <field name="model">sf.datawizard</field>
    <field name="arch" type="xml">
        <form>
            <group>
                <field name="amount" string="Amount" />
            </group>
            <footer>
                <button string="Save" type="object" name="btn_cloning"/>
                <button string="Cancel" type="object" special="cancel" />
            </footer>
        </form>
    </field>
</record>


<record id="form_view" model="ir.ui.view">
    <field name="name">data form</field>
    <field name="model">sf.data</field>
    <field name="arch" type="xml">
        <form>
            <header>
                <button name="btn_wizard" string="Clon" type="object" />
            </header>
            <sheet>
                <field name="name" string="Name" />
                <field name="age" string="Age"/>
            </sheet>
        </form>
    </field>
</record>

型号

class cloningwizard(models.TransientModel):
    _name='sf.cloningwizard'
    amount= fields.Integer('Amount')

    @api.multi
    def btn_cloning(self):
        data= self.env['sf.data'].search([('id','=',self._context.get('active_id', False))])
        for item in range(1,self.amount+1):
            data.copy()
        return True

class data(models.Model):
    _name = 'sf.data'
    name = fields.Char('Name')
    age= fields.Integer('Age')

    def btn_wizard(self):
        return {
            'name': 'Amount of times to be cloned',
            'type': 'ir.actions.act_window',
            'res_model': 'sf.datawizard',
            'view_type': 'form',
            'view_mode': 'form',
            'target': 'new',
            }