延伸re.合伙人,在opener中

2024-10-01 00:15:34 发布

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

我目前正在使用开放式ERP。我想扩展客户/组织表单,添加一些字段。在

我的印象是客户对象模型res.合伙人. 在

以下是我目前为止的代码:

from osv import fields, osv

class starstream_customers(osv.osv):
    _name = 'starstream.customers'
    _inherit = 'res.partner'
    _table = 'res_partner'
    _columns = {
        'caller_id': fields.char('Caller ID',size=128),
        'rating': fields.selection([
            ('none', '--None--'),
            ('shutdown', 'Shutdown'),
            ('aquired', 'Aquired'),
            ('active', 'Active'),
            ('cancelled', 'Project Cancelled')
            ], 'Rating'),
        'industry': fields.char('Industry',size=265),
        'type':fields.selection([
            ('supplier', 'Supplier'),
            ('customer', 'Customer'),
            ('old_customer', 'Old Customer'),
            ('supplier', 'Supplier'),
            ('customer_support_team', 'Customers Support Team'),
            ('none', '--None--'),
            ], 'Type'),
        'invoice_address': fields.char('Invoice Address',size=512),
        'employees': fields.integer('Employees'),
    }
starstream_customers()

以及我的视图文件:

^{pr2}$

现在,我只想加入评级字段,直到它起作用为止。在

每次我试图重写这篇文章时,我都会:

TypeError: The model "('res.partner',)" specifies an unexisting parent class "('res.partner',)"
You may need to add a dependency on the parent class' module.

我看不出哪里出了问题,有人能帮忙吗?在


Tags: nonefieldspartnersize客户rescustomerclass
2条回答

确保已将crm添加到依赖项中。在

\uu openerp\uu.py

'depends': ['base', 'crm'],

这里有几个问题:

您已经定义了_name_inherit,它们具有不同的值。如果您想要的是一个名为starstream.customers的全新表,该表的列是res.partner模型的超集,并且添加了新的列,但是您使用现有的res砦partner表进行存储。在

但是,如果只想将列添加到现有的当事人建模,这样合作伙伴就有了所有现有的信息,再加上你的新列,那么通常的模式就是让你继承并去掉你的名字和表。你会发现一些有这种图案的地方,库存领料以及库存拣选比如说,但是除非你确定自己在做什么,否则我不会推荐它。在

如果您想要后者,即95%的表扩展的模式,请删除\u name和\u table属性并保留inherit。在

这是可选的,但是如果您是为OpenERP版本7编码的话,您应该继承osv.Model,而不是{}。osv.osv可以使用,但已弃用。同样对于版本7,您不需要实例化模型。在

在您的表单定义中,您使用的是模型starstream.customers,但尝试为不同的模型(res.partners)继承一个表单,这正是触发您看到的实际错误的原因。由于您使用的是不同的模型,因此您需要完成一个完整的表单。如果您按照上面的建议,从模型中删除_name和{},那么您可以将表单上的模型改为res.partner,这样就可以了。在

不知道为什么要为上面的代码添加对crm的依赖,res.合伙人在基本模块中。在

相关问题 更多 >