奥杜 SAAS : Add field from associated model into a tree view of another model

标签 odoo saas odoo-9

我在 res.partner 中有 2 个字段,我想根据partner_id 字段在 account.invoice 的 TreeView 中显示它们。我想知道如何通过 TreeView Web 界面做到这一点(引用另一个模型和字段),因为 SaaS 版本不允许编程访问。

提前致谢!

最佳答案

在 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 

关于奥杜 SAAS : Add field from associated model into a tree view of another model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38492096/

相关文章:

linux - Odoo 容器 : Database connection failure: could not connect to server: Connection refused (linking odoo with localhost postgres)

css - 执行与 Firebug、Chrome 开发者工具等类似功能的网站

saas - Sandstorm.io 等服务的技术术语

odoo - 将消息添加到 message_post odoo 9

python - 使用 systemctl 重新启动和更新 Odoo 服务

python - 如何使用动态字段odoo-10过滤 TreeView

postgresql - 为什么开始使用 PostgreSQL 时必须创建一个新用户?

ubuntu - 如何将 Odoo 9 从一台服务器移动到另一台服务器?

css - Odoo:如何编辑发票/报价布局 CSS

css - @mixin 未在 saas 文件中定义