Files
reporting-engine/base_comment_template/models/res_partner.py
Pedro M. Baeza 34333c4216 [FIX] base_comment_template: Incorrect m2m column names + script + avoid FK constraint
- The name of the columns were swapped, so better to fix it for avoiding
  mistakes due to this.
- Migration script for detecting the condition and swap column names.
- On v12 > v13 migration, include JOINs for avoiding FK constraint,
  which `ON CONFLICT` clause doesn't protect.
2021-05-17 08:05:33 +02:00

24 lines
786 B
Python

# Copyright 2020 NextERP Romania SRL
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
base_comment_template_ids = fields.Many2many(
comodel_name="base.comment.template",
relation="base_comment_template_res_partner_rel",
column1="res_partner_id",
column2="base_comment_template_id",
string="Comment Templates",
help="Specific partner comments that can be included in reports",
)
@api.model
def _commercial_fields(self):
"""Add comment templates to commercial fields"""
return super()._commercial_fields() + ["base_comment_template_ids"]