odoo如何保存one2many关系的相关字段
我的问题是,当我从B保存模型中的字段时,我没有在模型的视图A中看到结果。由于在同一个模型中声明了员工和部门的名称,一些朋友建议我使用onchnage函数,但如何使用odoo如何保存one2many关系的相关字段,odoo,Odoo,我的问题是,当我从B保存模型中的字段时,我没有在模型的视图A中看到结果。由于在同一个模型中声明了员工和部门的名称,一些朋友建议我使用onchnage函数,但如何使用 class FeuilleTemps(models.Model): # A _name = 'tbrh.feuilletemps' _rec_name = 'name_emp' name_emp = fields.Many2one('hr.employee', string="Employé")
class FeuilleTemps(models.Model): # A
_name = 'tbrh.feuilletemps'
_rec_name = 'name_emp'
name_emp = fields.Many2one('hr.employee', string="Employé")
name_dep = fields.Many2one('hr.department', string="Département")
abscence_ids = fields.One2many('tbrh.abscences', 'feuille_id', string="ma liste ")
relation_id = fields.Many2one('tbrh.abscences')
date2 = fields.Date(related='relation_id.date', store=True, use_parent_address=False)
statut = fields.Selection(related='relation_id.statut', store=True)
class Abscences(models.Model): # B
_name = 'tbrh.abscences'
statut = fields.Selection([('abscent', 'Abscent'), ('present', 'Présent')], string="Statut")
date = fields.Date()
feuille_id = fields.Many2one('tbrh.feuilletemps',
ondelete='cascade', string="feuille ", required=True)
相关字段
date2
和statut
与其中一个字段无关任何字段,只有relation\u id
字段为或设置了related
中指定的字段,才会填充这两个字段。谢谢,但这不是我的问题,如何在视图A中显示其他型号B中的字段在此casSinceAbsence\u ID
中列出了B
中的记录,您只需使用一个2 many列表来显示Absence\u ID
, . 很抱歉,格式很好,非常欢迎您。相关字段date2
和statut
与其中一个字段无关,仅当关系id
字段为或设置了相关
中指定的字段时,才会填充这两个字段。谢谢,但这不是我的问题,我如何在视图中显示其他模型B的字段?在这种情况下缺席id
列出了B
中的记录,您只需使用One2many列表来显示缺席ID即可。对不起,他工作得很好,非常感谢你的光临。