我想在res.partner中有2个字段,这些字段要在基于partner_id字段的account.invoice的树形视图中显示。我想知道由于SaaS版本不允许编程访问,因此如何通过树形视图Web界面做到这一点(引用其他模型和字段)。
提前致谢!
在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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句