Merge lp:~julie-w/unifield-server/US-5616 into lp:unifield-server
- US-5616
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 5372 |
Proposed branch: | lp:~julie-w/unifield-server/US-5616 |
Merge into: | lp:unifield-server |
Diff against target: |
199 lines (+86/-27) 6 files modified
bin/addons/account_hq_entries/hq_entries.py (+23/-0) bin/addons/account_hq_entries/wizard/hq_entries_import.py (+3/-0) bin/addons/analytic_distribution/analytic_distribution.py (+0/-3) bin/addons/msf_profile/i18n/es_MF.po (+0/-6) bin/addons/msf_profile/i18n/fr_MF.po (+18/-6) bin/addons/sync_so/specific_xml_id.py (+42/-12) |
To merge this branch: | bzr merge lp:~julie-w/unifield-server/US-5616 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+364810@code.launchpad.net |
Commit message
Description of the change
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/account_hq_entries/hq_entries.py' | |||
2 | --- bin/addons/account_hq_entries/hq_entries.py 2019-01-09 10:36:58 +0000 | |||
3 | +++ bin/addons/account_hq_entries/hq_entries.py 2019-03-27 16:03:16 +0000 | |||
4 | @@ -496,9 +496,31 @@ | |||
5 | 496 | # If destination given, search if given | 496 | # If destination given, search if given |
6 | 497 | return res | 497 | return res |
7 | 498 | 498 | ||
8 | 499 | def _check_cc(self, cr, uid, ids, context=None): | ||
9 | 500 | """ | ||
10 | 501 | At synchro time sets HQ entry to Not Run if the Cost Center used in the line doesn't exist or is inactive | ||
11 | 502 | """ | ||
12 | 503 | if isinstance(ids, (int, long)): | ||
13 | 504 | ids = [ids] | ||
14 | 505 | if context is None: | ||
15 | 506 | context = {} | ||
16 | 507 | if context.get('sync_update_execution'): | ||
17 | 508 | for hq_entry in self.browse(cr, uid, ids, fields_to_fetch=['cost_center_id', 'date', 'name'], context=context): | ||
18 | 509 | if not hq_entry.cost_center_id: | ||
19 | 510 | raise osv.except_osv(_('Warning'), _('The Cost Center of the HQ entry "%s" doesn\'t exist in the system.') % hq_entry.name) | ||
20 | 511 | elif hq_entry.date: # posting date | ||
21 | 512 | hq_date = hq_entry.date | ||
22 | 513 | cc_date_start = hq_entry.cost_center_id.date_start | ||
23 | 514 | cc_date_end = hq_entry.cost_center_id.date or False | ||
24 | 515 | if (hq_date < cc_date_start) or (cc_date_end and hq_date >= cc_date_end): | ||
25 | 516 | raise osv.except_osv(_('Warning'), _('The Cost Center %s used in the HQ entry "%s" is inactive.') % | ||
26 | 517 | (hq_entry.cost_center_id.code or '', hq_entry.name)) | ||
27 | 518 | return True | ||
28 | 519 | |||
29 | 499 | def create(self, cr, uid, vals, context=None): | 520 | def create(self, cr, uid, vals, context=None): |
30 | 500 | new_id = super(hq_entries, self).create(cr, uid, vals, context) | 521 | new_id = super(hq_entries, self).create(cr, uid, vals, context) |
31 | 501 | self._check_active_account(cr, uid, [new_id], context=context) | 522 | self._check_active_account(cr, uid, [new_id], context=context) |
32 | 523 | self._check_cc(cr, uid, [new_id], context=context) | ||
33 | 502 | return new_id | 524 | return new_id |
34 | 503 | 525 | ||
35 | 504 | def write(self, cr, uid, ids, vals, context=None): | 526 | def write(self, cr, uid, ids, vals, context=None): |
36 | @@ -531,6 +553,7 @@ | |||
37 | 531 | self.check_ad_change_allowed(cr, uid, ids, vals, context=context) | 553 | self.check_ad_change_allowed(cr, uid, ids, vals, context=context) |
38 | 532 | res = super(hq_entries, self).write(cr, uid, ids, vals, context) | 554 | res = super(hq_entries, self).write(cr, uid, ids, vals, context) |
39 | 533 | self._check_active_account(cr, uid, ids, context=context) | 555 | self._check_active_account(cr, uid, ids, context=context) |
40 | 556 | self._check_cc(cr, uid, ids, context=context) | ||
41 | 534 | return res | 557 | return res |
42 | 535 | 558 | ||
43 | 536 | def unlink(self, cr, uid, ids, context=None): | 559 | def unlink(self, cr, uid, ids, context=None): |
44 | 537 | 560 | ||
45 | === modified file 'bin/addons/account_hq_entries/wizard/hq_entries_import.py' | |||
46 | --- bin/addons/account_hq_entries/wizard/hq_entries_import.py 2019-02-06 09:25:31 +0000 | |||
47 | +++ bin/addons/account_hq_entries/wizard/hq_entries_import.py 2019-03-27 16:03:16 +0000 | |||
48 | @@ -178,6 +178,9 @@ | |||
49 | 178 | raise osv.except_osv(_('Error'), _('Cost Center "%s" doesn\'t exist!') % (cost_center,)) | 178 | raise osv.except_osv(_('Error'), _('Cost Center "%s" doesn\'t exist!') % (cost_center,)) |
50 | 179 | cc_id = cc_id[0] | 179 | cc_id = cc_id[0] |
51 | 180 | if cc_id: | 180 | if cc_id: |
52 | 181 | # check that the CC or its parent is targeted to an instance | ||
53 | 182 | if not hq_obj.get_target_id(cr, uid, cc_id, context=context): | ||
54 | 183 | raise osv.except_osv(_('Error'), _('The Cost Center "%s" (or its parent) must be "targeted" to a Proprietary Instance.') % (cost_center,)) | ||
55 | 181 | aa_check_ids.append(cc_id) | 184 | aa_check_ids.append(cc_id) |
56 | 182 | 185 | ||
57 | 183 | vals.update({'destination_id_first_value': destination_id, 'destination_id': destination_id, 'cost_center_id': cc_id, 'analytic_id': fp_id, 'cost_center_id_first_value': cc_id, 'analytic_id_first_value': fp_id, 'free_1_id': free1_id, 'free_2_id': free2_id,}) | 186 | vals.update({'destination_id_first_value': destination_id, 'destination_id': destination_id, 'cost_center_id': cc_id, 'analytic_id': fp_id, 'cost_center_id_first_value': cc_id, 'analytic_id_first_value': fp_id, 'free_1_id': free1_id, 'free_2_id': free2_id,}) |
58 | 184 | 187 | ||
59 | === modified file 'bin/addons/analytic_distribution/analytic_distribution.py' | |||
60 | --- bin/addons/analytic_distribution/analytic_distribution.py 2017-02-10 08:51:30 +0000 | |||
61 | +++ bin/addons/analytic_distribution/analytic_distribution.py 2019-03-27 16:03:16 +0000 | |||
62 | @@ -93,9 +93,6 @@ | |||
63 | 93 | if analytic_id == fp_id: | 93 | if analytic_id == fp_id: |
64 | 94 | is_private_fund = True | 94 | is_private_fund = True |
65 | 95 | # DISTRIBUTION VERIFICATION | 95 | # DISTRIBUTION VERIFICATION |
66 | 96 | # Check account user_type | ||
67 | 97 | if account.user_type_code != 'expense': | ||
68 | 98 | return res, _('Not an expense account') | ||
69 | 99 | # Check that destination is compatible with account | 96 | # Check that destination is compatible with account |
70 | 100 | if destination_id not in [x.id for x in account.destination_ids]: | 97 | if destination_id not in [x.id for x in account.destination_ids]: |
71 | 101 | return 'invalid', _('Destination not compatible with account') | 98 | return 'invalid', _('Destination not compatible with account') |
72 | 102 | 99 | ||
73 | === modified file 'bin/addons/msf_profile/i18n/es_MF.po' | |||
74 | --- bin/addons/msf_profile/i18n/es_MF.po 2018-03-16 11:02:37 +0000 | |||
75 | +++ bin/addons/msf_profile/i18n/es_MF.po 2019-03-27 16:03:16 +0000 | |||
76 | @@ -44707,12 +44707,6 @@ | |||
77 | 44707 | msgid "Text Error" | 44707 | msgid "Text Error" |
78 | 44708 | msgstr "Error de texto" | 44708 | msgstr "Error de texto" |
79 | 44709 | 44709 | ||
80 | 44710 | #. module: analytic_distribution | ||
81 | 44711 | #: code:addons/analytic_distribution/analytic_distribution.py:448 | ||
82 | 44712 | #, python-format | ||
83 | 44713 | msgid "Not an expense account" | ||
84 | 44714 | msgstr "Not an expense account" | ||
85 | 44715 | |||
86 | 44716 | #. module: service_purchasing | 44710 | #. module: service_purchasing |
87 | 44717 | #: code:addons/service_purchasing/service_purchasing.py:244 | 44711 | #: code:addons/service_purchasing/service_purchasing.py:244 |
88 | 44718 | #, python-format | 44712 | #, python-format |
89 | 44719 | 44713 | ||
90 | === modified file 'bin/addons/msf_profile/i18n/fr_MF.po' | |||
91 | --- bin/addons/msf_profile/i18n/fr_MF.po 2019-03-04 11:05:48 +0000 | |||
92 | +++ bin/addons/msf_profile/i18n/fr_MF.po 2019-03-27 16:03:16 +0000 | |||
93 | @@ -20463,12 +20463,6 @@ | |||
94 | 20463 | msgid "Selected Version is for a different product." | 20463 | msgid "Selected Version is for a different product." |
95 | 20464 | msgstr "Version Sélectionnée est pour un produit différent." | 20464 | msgstr "Version Sélectionnée est pour un produit différent." |
96 | 20465 | 20465 | ||
97 | 20466 | #. module: analytic_distribution | ||
98 | 20467 | #: code:addons/analytic_distribution/analytic_distribution.py:98 | ||
99 | 20468 | #, python-format | ||
100 | 20469 | msgid "Not an expense account" | ||
101 | 20470 | msgstr "Not an expense account" | ||
102 | 20471 | |||
103 | 20472 | #. module: account | 20466 | #. module: account |
104 | 20473 | #: model:process.transition,name:account.process_transition_confirmstatementfromdraft0 | 20467 | #: model:process.transition,name:account.process_transition_confirmstatementfromdraft0 |
105 | 20474 | msgid "Confirm statement" | 20468 | msgid "Confirm statement" |
106 | @@ -105320,6 +105314,24 @@ | |||
107 | 105320 | msgid "File line %s: Column \"Item\" must be an integer" | 105314 | msgid "File line %s: Column \"Item\" must be an integer" |
108 | 105321 | msgstr "Fichier ligne %s: La Colonne \"Article\" doit être un entier" | 105315 | msgstr "Fichier ligne %s: La Colonne \"Article\" doit être un entier" |
109 | 105322 | 105316 | ||
110 | 105317 | #. module: account_hq_entries | ||
111 | 105318 | #: code:addons/account_hq_entries/wizard/hq_entries_import.py:183 | ||
112 | 105319 | #, python-format | ||
113 | 105320 | msgid "The Cost Center \"%s\" (or its parent) must be \"targeted\" to a Proprietary Instance." | ||
114 | 105321 | msgstr "Le Centre de Coût \"%s\" (ou son parent) doit avoir une Instance Propriétaire \"cible\"." | ||
115 | 105322 | |||
116 | 105323 | #. module: account_hq_entries | ||
117 | 105324 | #: code:addons/account_hq_entries/hq_entries.py:510 | ||
118 | 105325 | #, python-format | ||
119 | 105326 | msgid "The Cost Center of the HQ entry \"%s\" doesn't exist in the system." | ||
120 | 105327 | msgstr "Le Centre de Coût de l'entrée Siège \"%s\" n'existe pas dans le système." | ||
121 | 105328 | |||
122 | 105329 | #. module: account_hq_entries | ||
123 | 105330 | #: code:addons/account_hq_entries/hq_entries.py:516 | ||
124 | 105331 | #, python-format | ||
125 | 105332 | msgid "The Cost Center %s used in the HQ entry \"%s\" is inactive." | ||
126 | 105333 | msgstr "Le Centre de Coût %s utilisé dans l'entrée Siège \"%s\" est inactif." | ||
127 | 105334 | |||
128 | 105323 | #. module: purchase | 105335 | #. module: purchase |
129 | 105324 | #: code:addons/purchase/purchase_order_line.py:24 | 105336 | #: code:addons/purchase/purchase_order_line.py:24 |
130 | 105325 | #, python-format | 105337 | #, python-format |
131 | 105326 | 105338 | ||
132 | === modified file 'bin/addons/sync_so/specific_xml_id.py' | |||
133 | --- bin/addons/sync_so/specific_xml_id.py 2018-10-25 12:38:09 +0000 | |||
134 | +++ bin/addons/sync_so/specific_xml_id.py 2019-03-27 16:03:16 +0000 | |||
135 | @@ -146,23 +146,53 @@ | |||
136 | 146 | 146 | ||
137 | 147 | _inherit = 'hq.entries' | 147 | _inherit = 'hq.entries' |
138 | 148 | 148 | ||
139 | 149 | def get_target_id(self, cr, uid, cost_center_id, context=None): | ||
140 | 150 | """ | ||
141 | 151 | Returns the id of the target CC linked to the cost_center_id, or to its parent if there isn't any. | ||
142 | 152 | """ | ||
143 | 153 | if context is None: | ||
144 | 154 | context = {} | ||
145 | 155 | target_ids = [] | ||
146 | 156 | if cost_center_id: | ||
147 | 157 | analytic_cc_obj = self.pool.get('account.analytic.account') | ||
148 | 158 | target_cc_obj = self.pool.get('account.target.costcenter') | ||
149 | 159 | target_ids = target_cc_obj.search(cr, uid, | ||
150 | 160 | [('cost_center_id', '=', cost_center_id), ('is_target', '=', True)], | ||
151 | 161 | context=context) | ||
152 | 162 | if not target_ids: | ||
153 | 163 | cc = analytic_cc_obj.browse(cr, uid, cost_center_id, fields_to_fetch=['parent_id'], context=context) | ||
154 | 164 | if cc and cc.parent_id: | ||
155 | 165 | target_ids = target_cc_obj.search(cr, uid, | ||
156 | 166 | [('cost_center_id', '=', cc.parent_id.id), ('is_target', '=', True)], | ||
157 | 167 | context=context) | ||
158 | 168 | return target_ids and target_ids[0] or False | ||
159 | 169 | |||
160 | 149 | def get_destination_name(self, cr, uid, ids, dest_field, context=None): | 170 | def get_destination_name(self, cr, uid, ids, dest_field, context=None): |
161 | 171 | """ | ||
162 | 172 | Gets the instances to which the HQ entries should sync. | ||
163 | 173 | For each HQ entry: | ||
164 | 174 | 1) Search for the instance: | ||
165 | 175 | - to which the CC used in the entry is targeted to | ||
166 | 176 | - if there isn't any, to which the PARENT CC is targeted to | ||
167 | 177 | 2) The entry will sync to the coordo of the corresponding mission | ||
168 | 178 | """ | ||
169 | 179 | if context is None: | ||
170 | 180 | context = {} | ||
171 | 181 | target_cc_obj = self.pool.get('account.target.costcenter') | ||
172 | 150 | if dest_field == 'cost_center_id': | 182 | if dest_field == 'cost_center_id': |
173 | 151 | res = dict.fromkeys(ids, False) | 183 | res = dict.fromkeys(ids, False) |
174 | 152 | for line_data in self.browse(cr, uid, ids, context=context): | 184 | for line_data in self.browse(cr, uid, ids, context=context): |
175 | 153 | if line_data.cost_center_id: | 185 | if line_data.cost_center_id: |
188 | 154 | cost_center_name = line_data.cost_center_id and \ | 186 | targeted_instance = False |
189 | 155 | line_data.cost_center_id.code and \ | 187 | target_id = self.get_target_id(cr, uid, line_data.cost_center_id.id, context=context) |
190 | 156 | line_data.cost_center_id.code[:3] or "" | 188 | if target_id: |
191 | 157 | cost_center_ids = self.pool.get('account.analytic.account').search(cr, uid, [('category', '=', 'OC'), | 189 | target = target_cc_obj.browse(cr, uid, target_id, fields_to_fetch=['instance_id'], context=context) |
192 | 158 | ('code', '=', cost_center_name)], context=context) | 190 | if target.instance_id.level == 'coordo': |
193 | 159 | if len(cost_center_ids) > 0: | 191 | targeted_instance = target.instance_id |
194 | 160 | target_ids = self.pool.get('account.target.costcenter').search(cr, uid, [('cost_center_id', '=', cost_center_ids[0]), | 192 | elif target.instance_id.level == 'project': |
195 | 161 | ('is_target', '=', True)]) | 193 | targeted_instance = target.instance_id.parent_id or False |
196 | 162 | if len(target_ids) > 0: | 194 | if targeted_instance: |
197 | 163 | target = self.pool.get('account.target.costcenter').browse(cr, uid, target_ids[0], context=context) | 195 | res[line_data.id] = targeted_instance.instance |
186 | 164 | if target.instance_id and target.instance_id.instance: | ||
187 | 165 | res[line_data.id] = target.instance_id.instance | ||
198 | 166 | return res | 196 | return res |
199 | 167 | return super(hq_entries, self).get_destination_name(cr, uid, ids, dest_field, context=context) | 197 | return super(hq_entries, self).get_destination_name(cr, uid, ids, dest_field, context=context) |
200 | 168 | 198 |