From bbd64c22abc19558c1d83a892fc426bf99a094ce Mon Sep 17 00:00:00 2001
From: Mohit Ghodasara <mgh@odoo.com>
Date: Thu, 31 Jan 2019 10:45:06 +0000
Subject: [PATCH] [IMP] various: prevent unlink of automated activity types

Purpose of this merge is to update main addons and set activity types used
for automated activities as master data. This means they cannot be removed.
Indeed those activity types are used in business flow to generate activities
and removing them may break some flows.

This commit is linked to task ID 1907970 and PR #29257.
---
 addons/fleet/data/mail_data.xml                    | 1 +
 addons/hr_expense/data/mail_data.xml               | 1 +
 addons/hr_holidays/data/mail_data.xml              | 4 ++++
 addons/maintenance/data/mail_data.xml              | 1 +
 addons/product_expiry/data/product_expiry_data.xml | 1 +
 addons/sale/data/mail_data.xml                     | 1 +
 6 files changed, 9 insertions(+)

diff --git a/addons/fleet/data/mail_data.xml b/addons/fleet/data/mail_data.xml
index 0fb2cbc3c96d..401f115b87b4 100644
--- a/addons/fleet/data/mail_data.xml
+++ b/addons/fleet/data/mail_data.xml
@@ -5,6 +5,7 @@
             <field name="name">Contract to Renew</field>
             <field name="icon">fa-car</field>
             <field name="res_model_id" ref="fleet.model_fleet_vehicle_log_contract"/>
+            <field name="is_master_data">True</field>
         </record>
 
         <record id="mt_fleet_driver_updated" model="mail.message.subtype">
diff --git a/addons/hr_expense/data/mail_data.xml b/addons/hr_expense/data/mail_data.xml
index 735771fbff72..06c497b4176e 100644
--- a/addons/hr_expense/data/mail_data.xml
+++ b/addons/hr_expense/data/mail_data.xml
@@ -6,6 +6,7 @@
             <field name="name">Expense Approval</field>
             <field name="icon">fa-dollar</field>
             <field name="res_model_id" ref="hr_expense.model_hr_expense_sheet"/>
+            <field name="is_master_data">True</field>
         </record>
 
         <!-- default alias for expenses -->
diff --git a/addons/hr_holidays/data/mail_data.xml b/addons/hr_holidays/data/mail_data.xml
index 253cac416fe1..a57701e195cc 100644
--- a/addons/hr_holidays/data/mail_data.xml
+++ b/addons/hr_holidays/data/mail_data.xml
@@ -6,11 +6,13 @@
             <field name="name">Time Off Approval</field>
             <field name="icon">fa-sun-o</field>
             <field name="res_model_id" ref="hr_holidays.model_hr_leave"/>
+            <field name="is_master_data">True</field>
         </record>
         <record id="mail_act_leave_second_approval" model="mail.activity.type">
             <field name="name">Time Off Second Approve</field>
             <field name="icon">fa-sun-o</field>
             <field name="res_model_id" ref="hr_holidays.model_hr_leave"/>
+            <field name="is_master_data">True</field>
         </record>
 
         <!-- Leave specific activities -->
@@ -18,11 +20,13 @@
             <field name="name">Allocation Approval</field>
             <field name="icon">fa-sun-o</field>
             <field name="res_model_id" ref="hr_holidays.model_hr_leave_allocation"/>
+            <field name="is_master_data">True</field>
         </record>
         <record id="mail_act_leave_allocation_second_approval" model="mail.activity.type">
             <field name="name">Allocation Second Approve</field>
             <field name="icon">fa-sun-o</field>
             <field name="res_model_id" ref="hr_holidays.model_hr_leave_allocation"/>
+            <field name="is_master_data">True</field>
         </record>
 
         <!-- Holidays-related subtypes for messaging / Chatter -->
diff --git a/addons/maintenance/data/mail_data.xml b/addons/maintenance/data/mail_data.xml
index dd80a8317231..d298a0fb55df 100644
--- a/addons/maintenance/data/mail_data.xml
+++ b/addons/maintenance/data/mail_data.xml
@@ -6,6 +6,7 @@
         <field name="name">Maintenance Request</field>
         <field name="icon">fa-wrench</field>
         <field name="res_model_id" ref="maintenance.model_maintenance_request"/>
+        <field name="is_master_data">True</field>
     </record>
 
     <!-- email alias for maintenance requests -->
diff --git a/addons/product_expiry/data/product_expiry_data.xml b/addons/product_expiry/data/product_expiry_data.xml
index f0effeaaa778..62d95fb701fb 100644
--- a/addons/product_expiry/data/product_expiry_data.xml
+++ b/addons/product_expiry/data/product_expiry_data.xml
@@ -10,6 +10,7 @@
             <field name="res_model_id" ref="stock.model_stock_production_lot"/>
             <field name="icon">fa-tasks</field>
             <field name="delay_count">0</field>
+            <field name="is_master_data">True</field>
         </record>
 </odoo>
 
diff --git a/addons/sale/data/mail_data.xml b/addons/sale/data/mail_data.xml
index 938a39e15762..50c42763b67b 100644
--- a/addons/sale/data/mail_data.xml
+++ b/addons/sale/data/mail_data.xml
@@ -6,6 +6,7 @@
             <field name="name">Order Upsell</field>
             <field name="icon">fa-line-chart</field>
             <field name="res_model_id" ref="sale.model_sale_order"/>
+            <field name="is_master_data">True</field>
         </record>
 
         <!-- Sale-related subtypes for messaging / Chatter -->
-- 
GitLab