Merge lp:~julie-w/unifield-server/US-7866 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5921
Proposed branch: lp:~julie-w/unifield-server/US-7866
Merge into: lp:unifield-server
Diff against target: 108 lines (+48/-1)
5 files modified
bin/addons/msf_instance/account_target_costcenter.py (+29/-0)
bin/addons/msf_instance/msf_instance_view.xml (+1/-1)
bin/addons/msf_profile/data/patches.xml (+5/-0)
bin/addons/msf_profile/i18n/fr_MF.po (+1/-0)
bin/addons/msf_profile/msf_profile.py (+12/-0)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-7866
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+397371@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/msf_instance/account_target_costcenter.py'
2--- bin/addons/msf_instance/account_target_costcenter.py 2020-10-21 14:18:30 +0000
3+++ bin/addons/msf_instance/account_target_costcenter.py 2021-02-02 17:20:06 +0000
4@@ -26,9 +26,38 @@
5 _rec_name = 'cost_center_id'
6 _trace = True
7
8+ def _get_cost_center_code(self, cr, uid, ids, name, args, context=None):
9+ """
10+ Returns a dict with key = target Cost Center id, and value = related Cost Center code.
11+ """
12+ if context is None:
13+ context = {}
14+ if isinstance(ids, (int, long)):
15+ ids = [ids]
16+ res = {}
17+ for target_cc in self.browse(cr, uid, ids, fields_to_fetch=['cost_center_id'], context=context):
18+ res[target_cc.id] = target_cc.cost_center_id.code or ''
19+ return res
20+
21+ def _get_target_cc_to_update(self, cr, uid, analytic_acc_ids, context=None):
22+ """
23+ Returns the list of target CC for which the CC code should be updated.
24+ """
25+ if context is None:
26+ context = {}
27+ if isinstance(analytic_acc_ids, (int, long)):
28+ analytic_acc_ids = [analytic_acc_ids]
29+ return self.pool.get('account.target.costcenter').search(cr, uid, [('cost_center_id', 'in', analytic_acc_ids)],
30+ order='NO_ORDER', context=context)
31+
32 _columns = {
33 'instance_id': fields.many2one('msf.instance', 'Instance', required=True, select=1),
34 'cost_center_id': fields.many2one('account.analytic.account', 'Code', domain=[('category', '=', 'OC')], required=True, select=1),
35+ 'cost_center_code': fields.function(_get_cost_center_code, method=True, string="Code", type='char', size=24, readonly=True,
36+ store={
37+ 'account.analytic.account': (_get_target_cc_to_update, ['code'], 10),
38+ 'account.target.costcenter': (lambda self, cr, uid, ids, c=None: ids, ['cost_center_id'], 20),
39+ }),
40 'cost_center_name': fields.related('cost_center_id', 'name', string="Name", readonly=True, type="text"),
41 'is_target': fields.boolean('Is target'),
42 'is_top_cost_center': fields.boolean('Top cost centre for budget consolidation'),
43
44=== modified file 'bin/addons/msf_instance/msf_instance_view.xml'
45--- bin/addons/msf_instance/msf_instance_view.xml 2019-05-02 09:38:25 +0000
46+++ bin/addons/msf_instance/msf_instance_view.xml 2021-02-02 17:20:06 +0000
47@@ -52,7 +52,7 @@
48 <tree editable="top"
49 hide_delete_button="PROP_INSTANCE_HIDE_BUTTON or context.get('level')=='project'"
50 hide_new_button="1" string="Cost Centers">
51- <field name="cost_center_id" readonly="1"/>
52+ <field name="cost_center_code"/>
53 <field name="cost_center_name"/>
54 <field name="is_target"/>
55 <field name="is_top_cost_center"/>
56
57=== modified file 'bin/addons/msf_profile/data/patches.xml'
58--- bin/addons/msf_profile/data/patches.xml 2020-11-30 15:46:46 +0000
59+++ bin/addons/msf_profile/data/patches.xml 2021-02-02 17:20:06 +0000
60@@ -630,8 +630,13 @@
61 <field name="method">us_7808_ocg_rename_esc</field>
62 </record>
63
64+ <!-- UF20.0 -->
65 <record id="us_7848_cold_chain" model="patch.scripts">
66 <field name="method">us_7848_cold_chain</field>
67 </record>
68+
69+ <record id="us_7866_fill_in_target_cc_code" model="patch.scripts">
70+ <field name="method">us_7866_fill_in_target_cc_code</field>
71+ </record>
72 </data>
73 </openerp>
74
75=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
76--- bin/addons/msf_profile/i18n/fr_MF.po 2021-02-01 13:51:28 +0000
77+++ bin/addons/msf_profile/i18n/fr_MF.po 2021-02-02 17:20:06 +0000
78@@ -34772,6 +34772,7 @@
79 #: report:addons/stock/report/products_situation_report_xls.mako:216
80 #: field:products.situation.report,p_code:0
81 #: report:addons/msf_tools/report/report_stock_pipe_per_product_instance_xls.mako:86
82+#: field:account.target.costcenter,cost_center_code:0
83 #, python-format
84 msgid "Code"
85 msgstr "Code"
86
87=== modified file 'bin/addons/msf_profile/msf_profile.py'
88--- bin/addons/msf_profile/msf_profile.py 2020-11-30 15:46:46 +0000
89+++ bin/addons/msf_profile/msf_profile.py 2021-02-02 17:20:06 +0000
90@@ -52,6 +52,18 @@
91 'model': lambda *a: 'patch.scripts',
92 }
93
94+ # UF20.0
95+ def us_7866_fill_in_target_cc_code(self, cr, uid, *a, **b):
96+ """
97+ Fills in the new "cost_center_code" field of the Account Target Cost Centers.
98+ """
99+ cr.execute("""
100+ UPDATE account_target_costcenter t_cc
101+ SET cost_center_code = (SELECT code FROM account_analytic_account a_acc WHERE a_acc.id = t_cc.cost_center_id);
102+ """)
103+ self._logger.warn('Cost Center Code updated in %s Target CC.' % (cr.rowcount,))
104+ return True
105+
106 def us_7848_cold_chain(self, cr, uid, *a, **b):
107 for table in ['internal_move_processor', 'outgoing_delivery_move_processor', 'return_ppl_move_processor', 'stock_move_in_processor', 'stock_move_processor']:
108 cr.execute("update %s set kc_check = '' where kc_check != ''" % (table, )) # not_a_user_entry

Subscribers

People subscribed via source and target branches