在OpenErp中创建功能字段 [英] Create a functional field in OpenErp

查看:72
本文介绍了在OpenErp中创建功能字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在OpenERP中创建功能字段?

How do I create a functional field in OpenERP?

似乎我需要在python中创建该函数,然后使用XML对其进行调用.我看到了需要编辑的XML,但是python代码进入了哪个文件?

It seems that I need to create the function in python, then call it with XML. I see the XML that needs to be edited, but what file does the python code go in?

推荐答案

py文件的代码.

class some_model(osv.osv):

    _name = 'some.model'

    def Method_of_Function(self, cr, uid, ids, fld_name, arg, context=None):
        #Logic
        return value 

    _columns = {
        "functional_filed":fields.function(Method_of_Function, 
                   method=True,type='int',string='Label', store=True),

    }
some_model()

并且在xml文件中,记录标记看起来像...

and in xml file record tag look like...

<record model="ir.ui.view" id="object_name_form_view">
        <field name="name">objectname.form</field>
        <field name="model">some.model</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="form_string">
                <field name="functional_filed" />
            </form>
        </field>
    </record>

这篇关于在OpenErp中创建功能字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆