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

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
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+364810@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
=== modified file 'bin/addons/account_hq_entries/hq_entries.py'
--- bin/addons/account_hq_entries/hq_entries.py 2019-01-09 10:36:58 +0000
+++ bin/addons/account_hq_entries/hq_entries.py 2019-03-27 16:03:16 +0000
@@ -496,9 +496,31 @@
496 # If destination given, search if given496 # If destination given, search if given
497 return res497 return res
498498
499 def _check_cc(self, cr, uid, ids, context=None):
500 """
501 At synchro time sets HQ entry to Not Run if the Cost Center used in the line doesn't exist or is inactive
502 """
503 if isinstance(ids, (int, long)):
504 ids = [ids]
505 if context is None:
506 context = {}
507 if context.get('sync_update_execution'):
508 for hq_entry in self.browse(cr, uid, ids, fields_to_fetch=['cost_center_id', 'date', 'name'], context=context):
509 if not hq_entry.cost_center_id:
510 raise osv.except_osv(_('Warning'), _('The Cost Center of the HQ entry "%s" doesn\'t exist in the system.') % hq_entry.name)
511 elif hq_entry.date: # posting date
512 hq_date = hq_entry.date
513 cc_date_start = hq_entry.cost_center_id.date_start
514 cc_date_end = hq_entry.cost_center_id.date or False
515 if (hq_date < cc_date_start) or (cc_date_end and hq_date >= cc_date_end):
516 raise osv.except_osv(_('Warning'), _('The Cost Center %s used in the HQ entry "%s" is inactive.') %
517 (hq_entry.cost_center_id.code or '', hq_entry.name))
518 return True
519
499 def create(self, cr, uid, vals, context=None):520 def create(self, cr, uid, vals, context=None):
500 new_id = super(hq_entries, self).create(cr, uid, vals, context)521 new_id = super(hq_entries, self).create(cr, uid, vals, context)
501 self._check_active_account(cr, uid, [new_id], context=context)522 self._check_active_account(cr, uid, [new_id], context=context)
523 self._check_cc(cr, uid, [new_id], context=context)
502 return new_id524 return new_id
503525
504 def write(self, cr, uid, ids, vals, context=None):526 def write(self, cr, uid, ids, vals, context=None):
@@ -531,6 +553,7 @@
531 self.check_ad_change_allowed(cr, uid, ids, vals, context=context)553 self.check_ad_change_allowed(cr, uid, ids, vals, context=context)
532 res = super(hq_entries, self).write(cr, uid, ids, vals, context)554 res = super(hq_entries, self).write(cr, uid, ids, vals, context)
533 self._check_active_account(cr, uid, ids, context=context)555 self._check_active_account(cr, uid, ids, context=context)
556 self._check_cc(cr, uid, ids, context=context)
534 return res557 return res
535558
536 def unlink(self, cr, uid, ids, context=None):559 def unlink(self, cr, uid, ids, context=None):
537560
=== modified file 'bin/addons/account_hq_entries/wizard/hq_entries_import.py'
--- bin/addons/account_hq_entries/wizard/hq_entries_import.py 2019-02-06 09:25:31 +0000
+++ bin/addons/account_hq_entries/wizard/hq_entries_import.py 2019-03-27 16:03:16 +0000
@@ -178,6 +178,9 @@
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,))
179 cc_id = cc_id[0]179 cc_id = cc_id[0]
180 if cc_id:180 if cc_id:
181 # check that the CC or its parent is targeted to an instance
182 if not hq_obj.get_target_id(cr, uid, cc_id, context=context):
183 raise osv.except_osv(_('Error'), _('The Cost Center "%s" (or its parent) must be "targeted" to a Proprietary Instance.') % (cost_center,))
181 aa_check_ids.append(cc_id)184 aa_check_ids.append(cc_id)
182185
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,})
184187
=== modified file 'bin/addons/analytic_distribution/analytic_distribution.py'
--- bin/addons/analytic_distribution/analytic_distribution.py 2017-02-10 08:51:30 +0000
+++ bin/addons/analytic_distribution/analytic_distribution.py 2019-03-27 16:03:16 +0000
@@ -93,9 +93,6 @@
93 if analytic_id == fp_id:93 if analytic_id == fp_id:
94 is_private_fund = True94 is_private_fund = True
95 # DISTRIBUTION VERIFICATION95 # DISTRIBUTION VERIFICATION
96 # Check account user_type
97 if account.user_type_code != 'expense':
98 return res, _('Not an expense account')
99 # Check that destination is compatible with account96 # Check that destination is compatible with account
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]:
101 return 'invalid', _('Destination not compatible with account')98 return 'invalid', _('Destination not compatible with account')
10299
=== modified file 'bin/addons/msf_profile/i18n/es_MF.po'
--- bin/addons/msf_profile/i18n/es_MF.po 2018-03-16 11:02:37 +0000
+++ bin/addons/msf_profile/i18n/es_MF.po 2019-03-27 16:03:16 +0000
@@ -44707,12 +44707,6 @@
44707msgid "Text Error"44707msgid "Text Error"
44708msgstr "Error de texto"44708msgstr "Error de texto"
4470944709
44710#. module: analytic_distribution
44711#: code:addons/analytic_distribution/analytic_distribution.py:448
44712#, python-format
44713msgid "Not an expense account"
44714msgstr "Not an expense account"
44715
44716#. module: service_purchasing44710#. module: service_purchasing
44717#: code:addons/service_purchasing/service_purchasing.py:24444711#: code:addons/service_purchasing/service_purchasing.py:244
44718#, python-format44712#, python-format
4471944713
=== modified file 'bin/addons/msf_profile/i18n/fr_MF.po'
--- bin/addons/msf_profile/i18n/fr_MF.po 2019-03-04 11:05:48 +0000
+++ bin/addons/msf_profile/i18n/fr_MF.po 2019-03-27 16:03:16 +0000
@@ -20463,12 +20463,6 @@
20463msgid "Selected Version is for a different product."20463msgid "Selected Version is for a different product."
20464msgstr "Version Sélectionnée est pour un produit différent."20464msgstr "Version Sélectionnée est pour un produit différent."
2046520465
20466#. module: analytic_distribution
20467#: code:addons/analytic_distribution/analytic_distribution.py:98
20468#, python-format
20469msgid "Not an expense account"
20470msgstr "Not an expense account"
20471
20472#. module: account20466#. module: account
20473#: model:process.transition,name:account.process_transition_confirmstatementfromdraft020467#: model:process.transition,name:account.process_transition_confirmstatementfromdraft0
20474msgid "Confirm statement"20468msgid "Confirm statement"
@@ -105320,6 +105314,24 @@
105320msgid "File line %s: Column \"Item\" must be an integer"105314msgid "File line %s: Column \"Item\" must be an integer"
105321msgstr "Fichier ligne %s: La Colonne \"Article\" doit être un entier"105315msgstr "Fichier ligne %s: La Colonne \"Article\" doit être un entier"
105322105316
105317#. module: account_hq_entries
105318#: code:addons/account_hq_entries/wizard/hq_entries_import.py:183
105319#, python-format
105320msgid "The Cost Center \"%s\" (or its parent) must be \"targeted\" to a Proprietary Instance."
105321msgstr "Le Centre de Coût \"%s\" (ou son parent) doit avoir une Instance Propriétaire \"cible\"."
105322
105323#. module: account_hq_entries
105324#: code:addons/account_hq_entries/hq_entries.py:510
105325#, python-format
105326msgid "The Cost Center of the HQ entry \"%s\" doesn't exist in the system."
105327msgstr "Le Centre de Coût de l'entrée Siège \"%s\" n'existe pas dans le système."
105328
105329#. module: account_hq_entries
105330#: code:addons/account_hq_entries/hq_entries.py:516
105331#, python-format
105332msgid "The Cost Center %s used in the HQ entry \"%s\" is inactive."
105333msgstr "Le Centre de Coût %s utilisé dans l'entrée Siège \"%s\" est inactif."
105334
105323#. module: purchase105335#. module: purchase
105324#: code:addons/purchase/purchase_order_line.py:24105336#: code:addons/purchase/purchase_order_line.py:24
105325#, python-format105337#, python-format
105326105338
=== modified file 'bin/addons/sync_so/specific_xml_id.py'
--- bin/addons/sync_so/specific_xml_id.py 2018-10-25 12:38:09 +0000
+++ bin/addons/sync_so/specific_xml_id.py 2019-03-27 16:03:16 +0000
@@ -146,23 +146,53 @@
146146
147 _inherit = 'hq.entries'147 _inherit = 'hq.entries'
148148
149 def get_target_id(self, cr, uid, cost_center_id, context=None):
150 """
151 Returns the id of the target CC linked to the cost_center_id, or to its parent if there isn't any.
152 """
153 if context is None:
154 context = {}
155 target_ids = []
156 if cost_center_id:
157 analytic_cc_obj = self.pool.get('account.analytic.account')
158 target_cc_obj = self.pool.get('account.target.costcenter')
159 target_ids = target_cc_obj.search(cr, uid,
160 [('cost_center_id', '=', cost_center_id), ('is_target', '=', True)],
161 context=context)
162 if not target_ids:
163 cc = analytic_cc_obj.browse(cr, uid, cost_center_id, fields_to_fetch=['parent_id'], context=context)
164 if cc and cc.parent_id:
165 target_ids = target_cc_obj.search(cr, uid,
166 [('cost_center_id', '=', cc.parent_id.id), ('is_target', '=', True)],
167 context=context)
168 return target_ids and target_ids[0] or False
169
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):
171 """
172 Gets the instances to which the HQ entries should sync.
173 For each HQ entry:
174 1) Search for the instance:
175 - to which the CC used in the entry is targeted to
176 - if there isn't any, to which the PARENT CC is targeted to
177 2) The entry will sync to the coordo of the corresponding mission
178 """
179 if context is None:
180 context = {}
181 target_cc_obj = self.pool.get('account.target.costcenter')
150 if dest_field == 'cost_center_id':182 if dest_field == 'cost_center_id':
151 res = dict.fromkeys(ids, False)183 res = dict.fromkeys(ids, False)
152 for line_data in self.browse(cr, uid, ids, context=context):184 for line_data in self.browse(cr, uid, ids, context=context):
153 if line_data.cost_center_id:185 if line_data.cost_center_id:
154 cost_center_name = line_data.cost_center_id and \186 targeted_instance = False
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)
156 line_data.cost_center_id.code[:3] or ""188 if target_id:
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)
158 ('code', '=', cost_center_name)], context=context)190 if target.instance_id.level == 'coordo':
159 if len(cost_center_ids) > 0:191 targeted_instance = target.instance_id
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':
161 ('is_target', '=', True)])193 targeted_instance = target.instance_id.parent_id or False
162 if len(target_ids) > 0:194 if targeted_instance:
163 target = self.pool.get('account.target.costcenter').browse(cr, uid, target_ids[0], context=context)195 res[line_data.id] = targeted_instance.instance
164 if target.instance_id and target.instance_id.instance:
165 res[line_data.id] = target.instance_id.instance
166 return res196 return res
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)
168198

Subscribers

People subscribed via source and target branches