=== modified file 'bin/addons/msf_instance/account_target_costcenter.py'
--- bin/addons/msf_instance/account_target_costcenter.py	2020-10-21 14:18:30 +0000
+++ bin/addons/msf_instance/account_target_costcenter.py	2021-02-02 17:20:06 +0000
@@ -26,9 +26,38 @@
     _rec_name = 'cost_center_id'
     _trace = True
 
+    def _get_cost_center_code(self, cr, uid, ids, name, args, context=None):
+        """
+        Returns a dict with key = target Cost Center id, and value = related Cost Center code.
+        """
+        if context is None:
+            context = {}
+        if isinstance(ids, (int, long)):
+            ids = [ids]
+        res = {}
+        for target_cc in self.browse(cr, uid, ids, fields_to_fetch=['cost_center_id'], context=context):
+            res[target_cc.id] = target_cc.cost_center_id.code or ''
+        return res
+
+    def _get_target_cc_to_update(self, cr, uid, analytic_acc_ids, context=None):
+        """
+        Returns the list of target CC for which the CC code should be updated.
+        """
+        if context is None:
+            context = {}
+        if isinstance(analytic_acc_ids, (int, long)):
+            analytic_acc_ids = [analytic_acc_ids]
+        return self.pool.get('account.target.costcenter').search(cr, uid, [('cost_center_id', 'in', analytic_acc_ids)],
+                                                                 order='NO_ORDER', context=context)
+
     _columns = {
         'instance_id': fields.many2one('msf.instance', 'Instance', required=True, select=1),
         'cost_center_id': fields.many2one('account.analytic.account', 'Code', domain=[('category', '=', 'OC')], required=True, select=1),
+        'cost_center_code': fields.function(_get_cost_center_code, method=True, string="Code", type='char', size=24, readonly=True,
+                                            store={
+                                                'account.analytic.account': (_get_target_cc_to_update, ['code'], 10),
+                                                'account.target.costcenter': (lambda self, cr, uid, ids, c=None: ids, ['cost_center_id'], 20),
+                                            }),
         'cost_center_name': fields.related('cost_center_id', 'name', string="Name", readonly=True, type="text"),
         'is_target': fields.boolean('Is target'),
         'is_top_cost_center': fields.boolean('Top cost centre for budget consolidation'),

=== modified file 'bin/addons/msf_instance/msf_instance_view.xml'
--- bin/addons/msf_instance/msf_instance_view.xml	2019-05-02 09:38:25 +0000
+++ bin/addons/msf_instance/msf_instance_view.xml	2021-02-02 17:20:06 +0000
@@ -52,7 +52,7 @@
                                     <tree editable="top"
                                     hide_delete_button="PROP_INSTANCE_HIDE_BUTTON or context.get('level')=='project'"
                                     hide_new_button="1" string="Cost Centers">
-                                    <field name="cost_center_id" readonly="1"/>
+                                    <field name="cost_center_code"/>
                                     <field name="cost_center_name"/>
                                     <field name="is_target"/>
                                     <field name="is_top_cost_center"/>

=== modified file 'bin/addons/msf_profile/data/patches.xml'
--- bin/addons/msf_profile/data/patches.xml	2020-11-30 15:46:46 +0000
+++ bin/addons/msf_profile/data/patches.xml	2021-02-02 17:20:06 +0000
@@ -630,8 +630,13 @@
             <field name="method">us_7808_ocg_rename_esc</field>
         </record>
 
+        <!-- UF20.0 -->
         <record id="us_7848_cold_chain" model="patch.scripts">
             <field name="method">us_7848_cold_chain</field>
         </record>
+
+        <record id="us_7866_fill_in_target_cc_code" model="patch.scripts">
+            <field name="method">us_7866_fill_in_target_cc_code</field>
+        </record>
     </data>
 </openerp>

=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
--- bin/addons/msf_profile/i18n/fr_MF.po	2021-02-01 13:51:28 +0000
+++ bin/addons/msf_profile/i18n/fr_MF.po	2021-02-02 17:20:06 +0000
@@ -34772,6 +34772,7 @@
 #: report:addons/stock/report/products_situation_report_xls.mako:216
 #: field:products.situation.report,p_code:0
 #: report:addons/msf_tools/report/report_stock_pipe_per_product_instance_xls.mako:86
+#: field:account.target.costcenter,cost_center_code:0
 #, python-format
 msgid "Code"
 msgstr "Code"

=== modified file 'bin/addons/msf_profile/msf_profile.py'
--- bin/addons/msf_profile/msf_profile.py	2020-11-30 15:46:46 +0000
+++ bin/addons/msf_profile/msf_profile.py	2021-02-02 17:20:06 +0000
@@ -52,6 +52,18 @@
         'model': lambda *a: 'patch.scripts',
     }
 
+    # UF20.0
+    def us_7866_fill_in_target_cc_code(self, cr, uid, *a, **b):
+        """
+        Fills in the new "cost_center_code" field of the Account Target Cost Centers.
+        """
+        cr.execute("""
+                   UPDATE account_target_costcenter t_cc
+                   SET cost_center_code = (SELECT code FROM account_analytic_account a_acc WHERE a_acc.id = t_cc.cost_center_id);
+                   """)
+        self._logger.warn('Cost Center Code updated in %s Target CC.' % (cr.rowcount,))
+        return True
+
     def us_7848_cold_chain(self, cr, uid, *a, **b):
         for table in ['internal_move_processor', 'outgoing_delivery_move_processor', 'return_ppl_move_processor', 'stock_move_in_processor', 'stock_move_processor']:
             cr.execute("update %s set kc_check = '' where kc_check != ''" % (table, )) # not_a_user_entry

