# Copyright (C) 2024 Cetmix OÜ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models class CxTowerFileTemplate(models.Model): _inherit = "cx.tower.file.template" git_project_ids = fields.Many2many( comodel_name="cx.tower.git.project", relation="cx_tower_git_project_file_template_rel", column1="file_template_id", column2="git_project_id", string="Git Projects", copy=False, ) git_project_id = fields.Many2one( comodel_name="cx.tower.git.project", compute="_compute_git_project_id", ) @api.depends("git_project_ids") def _compute_git_project_id(self): """ Link to project using the proxy model. """ for record in self: # File is related to project via proxy model. # So there can be only one record in o2m field. record.git_project_id = ( record.git_project_ids and record.git_project_ids[0].id )