From 924c8076da6537c8eecb4a046dd9decbfdf3bf15 Mon Sep 17 00:00:00 2001 From: eLBati Date: Thu, 10 Sep 2015 10:46:43 +0200 Subject: [PATCH] FIX duplicate key value violates unique constraint "ir_model_data_module_name_uniq" while installing modules which create qweb view before report Now, report duplication is only activated by dedicated wizard --- base_report_auto_create_qweb/models/report_xml.py | 4 ++++ base_report_auto_create_qweb/wizard/report_duplicate.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base_report_auto_create_qweb/models/report_xml.py b/base_report_auto_create_qweb/models/report_xml.py index c6b47160f..6c719f34d 100644 --- a/base_report_auto_create_qweb/models/report_xml.py +++ b/base_report_auto_create_qweb/models/report_xml.py @@ -45,6 +45,8 @@ class IrActionsReport(models.Model): @api.model def create(self, values): + if not self.env.context.get('enable_duplication', False): + return super(IrActionsReport, self).create(values) if (values.get('report_type') in ['qweb-pdf', 'qweb-html'] and values.get('report_name') and values['report_name'].find('.') == -1): @@ -78,6 +80,8 @@ class IrActionsReport(models.Model): @api.one def copy(self, default=None): + if not self.env.context.get('enable_duplication', False): + return super(IrActionsReport, self).copy(default=default) if default is None: default = {} suffix = self.env.context.get('suffix', 'copy') diff --git a/base_report_auto_create_qweb/wizard/report_duplicate.py b/base_report_auto_create_qweb/wizard/report_duplicate.py index 75687d8ac..b461f1f99 100644 --- a/base_report_auto_create_qweb/wizard/report_duplicate.py +++ b/base_report_auto_create_qweb/wizard/report_duplicate.py @@ -18,5 +18,6 @@ class IrActionsReportDuplicate(models.TransientModel): model = self.env.context.get('active_model') if model: object = self.env[model].browse(active_id) - object.with_context(suffix=self.suffix).copy() + object.with_context( + suffix=self.suffix, enable_duplication=True).copy() return {}