Openerp Odoo SAAS:将关联模型中的字段添加到另一个模型的树视图中
我在res.partner中有两个字段,我希望根据partner_id字段在account.invoice的树状视图中显示。由于SaaS版本不允许编程访问,我想知道如何通过树视图web界面做到这一点(引用另一个模型和字段)Openerp Odoo SAAS:将关联模型中的字段添加到另一个模型的树视图中,openerp,saas,odoo-9,Openerp,Saas,Odoo 9,我在res.partner中有两个字段,我希望根据partner_id字段在account.invoice的树状视图中显示。由于SaaS版本不允许编程访问,我想知道如何通过树视图web界面做到这一点(引用另一个模型和字段) 提前谢谢 在account.invoice模型中创建与res.partner字段相关的字段 x_invoice_preference=fields.Selection(related="partner_id.x_invoice_preference") 将相关字段命名为另一
提前谢谢 在account.invoice模型中创建与res.partner字段相关的字段
x_invoice_preference=fields.Selection(related="partner_id.x_invoice_preference")
将相关字段命名为另一个模型中的相同名称是一种很好的做法
小例子:
class class1(models.Model):
_name = 'table1'
name = fields.Char()
class class2(models.Model):
_name = 'table2'
table1_id = fields.Many2one('table1','table 1');
#this how you create a related field in order to
#show it in the form or the tree when you select the value of the many2one field it
# will have the same value of the vield name of the tabl1
name = fields.Char(related="table1_id.name",readonly=True)
#field_name m2onField.field_name
如果你不明白我的回答,请告诉我嘿,查里夫,谢谢你的回答。该字段是型号“res.partner”中类型为“selection”的“x\u发票\u首选项”。我在account.invoice中创建了类型选择的x\u invoice\u首选项字段,并在相关字段(高级属性选项卡下)下放置以下内容:x\u invoice\u preference=fields.SameType(related=“partner\u id.x\u invoice\u preference”)。保存模型时,我收到以下消息:相关字段“x\u发票\u首选项=字段”中的未知字段名“x\u发票\u首选项=字段”。SameType(related=“partner\u id.x\u发票\u首选项”)“无。。。我做错了什么?如果字段是一个选择,那么您需要执行此x_invoice_preference=fields.Selection(related=“partner\u id.x_invoice_preference”)和我的新编辑答案,您应该了解相关字段和工作方式我为您感到非常高兴很好,您做了很多工作,谢谢