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

Proposed by jftempo
Status: Merged
Merged at revision: 4866
Proposed branch: lp:~julie-w/unifield-server/US-4493
Merge into: lp:unifield-server
Diff against target: 191 lines (+44/-20)
4 files modified
bin/addons/account_hq_entries/hq_entries.py (+22/-6)
bin/addons/account_hq_entries/wizard/hq_entries_unsplit.py (+2/-2)
bin/addons/account_hq_entries/wizard/hq_entries_validation.py (+18/-11)
bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv (+2/-1)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-4493
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+343384@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 2018-02-26 09:49:40 +0000
+++ bin/addons/account_hq_entries/hq_entries.py 2018-04-17 09:11:48 +0000
@@ -260,9 +260,9 @@
260260
261 for line in self.browse(cr, uid, ids, context=context):261 for line in self.browse(cr, uid, ids, context=context):
262 res.add(line.id)262 res.add(line.id)
263 if line.is_original:263 if line.is_original and line.split_ids:
264 add_split(line)264 add_split(line)
265 if line.is_split:265 if line.is_split and line.original_id:
266 # add original one266 # add original one
267 res.add(line.original_id.id)267 res.add(line.original_id.id)
268 # then other split lines268 # then other split lines
@@ -282,7 +282,9 @@
282 # Prepare some values282 # Prepare some values
283 res = set()283 res = set()
284 for line in self.browse(cr, uid, ids, context=context):284 for line in self.browse(cr, uid, ids, context=context):
285 if line.user_validated == False and (line.is_original or line.is_split):285 line_original = line.is_original and line.split_ids
286 line_split = line.is_split and line.original_id
287 if not line.user_validated and (line_original or line_split):
286 # First add original and split linked lines288 # First add original and split linked lines
287 for el in self.get_linked_lines(cr, uid, [line.id]):289 for el in self.get_linked_lines(cr, uid, [line.id]):
288 res.add(el)290 res.add(el)
@@ -466,8 +468,13 @@
466468
467 #US-921: Only save the user_validated value if the update comes from sync!469 #US-921: Only save the user_validated value if the update comes from sync!
468 if context.get('sync_update_execution', False):470 if context.get('sync_update_execution', False):
469 if 'user_validated' in vals:471 sync_vals = {}
470 return super(hq_entries, self).write(cr, uid, ids, {'user_validated': vals['user_validated']}, context)472 if 'user_validated' in vals:
473 sync_vals.update({'user_validated': vals['user_validated']})
474 if 'is_original' in vals: # US-4169 also enable to sync the is_original tag
475 sync_vals.update({'is_original': vals['is_original']})
476 if sync_vals:
477 return super(hq_entries, self).write(cr, uid, ids, sync_vals, context)
471 return True478 return True
472479
473 if 'account_id' in vals:480 if 'account_id' in vals:
@@ -480,6 +487,7 @@
480487
481 def unlink(self, cr, uid, ids, context=None):488 def unlink(self, cr, uid, ids, context=None):
482 """489 """
490 At synchro. only delete the entries having the tag is_split (= sync of an unsplit done in coordo). Otherwise:
483 Do not permit user to delete:491 Do not permit user to delete:
484 - validated HQ entries492 - validated HQ entries
485 - split entries493 - split entries
@@ -487,10 +495,18 @@
487 """495 """
488 if isinstance(ids, (int, long)):496 if isinstance(ids, (int, long)):
489 ids = [ids]497 ids = [ids]
498 if context is None:
499 context = {}
500 if context.get('sync_update_execution', False):
501 new_ids = []
502 for hq_entry in self.browse(cr, uid, ids, fields_to_fetch=['is_split'], context=context):
503 if hq_entry.is_split:
504 new_ids.append(hq_entry.id)
505 ids = new_ids
490 if not context.get('from', False) or context.get('from') != 'code' and ids:506 if not context.get('from', False) or context.get('from') != 'code' and ids:
491 if self.search(cr, uid, [('id', 'in', ids), ('user_validated', '=', True)]):507 if self.search(cr, uid, [('id', 'in', ids), ('user_validated', '=', True)]):
492 raise osv.except_osv(_('Error'), _('You cannot delete validated HQ Entries lines!'))508 raise osv.except_osv(_('Error'), _('You cannot delete validated HQ Entries lines!'))
493 if self.search(cr, uid, [('id', 'in', ids), ('is_split', '=', True)]):509 if self.search(cr, uid, [('id', 'in', ids), ('is_split', '=', True)]) and not context.get('sync_update_execution'):
494 raise osv.except_osv(_('Error'), _('You cannot delete split entries!'))510 raise osv.except_osv(_('Error'), _('You cannot delete split entries!'))
495 if self.search(cr, uid, [('id', 'in', ids), ('is_original', '=', True)]):511 if self.search(cr, uid, [('id', 'in', ids), ('is_original', '=', True)]):
496 raise osv.except_osv(_('Error'), _('You cannot delete original entries!'))512 raise osv.except_osv(_('Error'), _('You cannot delete original entries!'))
497513
=== modified file 'bin/addons/account_hq_entries/wizard/hq_entries_unsplit.py'
--- bin/addons/account_hq_entries/wizard/hq_entries_unsplit.py 2015-05-27 15:54:46 +0000
+++ bin/addons/account_hq_entries/wizard/hq_entries_unsplit.py 2018-04-17 09:11:48 +0000
@@ -61,10 +61,10 @@
61 split_ids = []61 split_ids = []
62 original_ids = []62 original_ids = []
63 for line in wiz.process_ids:63 for line in wiz.process_ids:
64 if line.is_original:64 if line.is_original and line.split_ids:
65 original_ids.append(line.id)65 original_ids.append(line.id)
66 continue66 continue
67 if line.is_split:67 if line.is_split and line.original_id:
68 split_ids.append(line.id)68 split_ids.append(line.id)
69 continue69 continue
70 # Process70 # Process
7171
=== modified file 'bin/addons/account_hq_entries/wizard/hq_entries_validation.py'
--- bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2018-04-03 10:18:51 +0000
+++ bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2018-04-17 09:11:48 +0000
@@ -88,19 +88,21 @@
88 return view88 return view
8989
90 # UTP-1101: Extract the method to create AD for being called also for the REV move90 # UTP-1101: Extract the method to create AD for being called also for the REV move
91 def create_distribution_id(self, cr, uid, currency_id, line, account):91 def create_distribution_id(self, cr, uid, currency_id, line, account, split=False):
92 current_date = strftime('%Y-%m-%d')92 current_date = strftime('%Y-%m-%d')
93 line_cc_first = line.cost_center_id_first_value and line.cost_center_id_first_value.id or False93 line_cc_first = line.cost_center_id_first_value and line.cost_center_id_first_value.id or False
94 line_cc_id = line.cost_center_id and line.cost_center_id.id or False94 line_cc_id = line.cost_center_id and line.cost_center_id.id or False
95 line_account_first = line.account_id_first_value and line.account_id_first_value.id or False95 line_account_first = line.account_id_first_value and line.account_id_first_value.id or False
9696
97 cc_id = line_cc_first or line_cc_id or False97 # if split is True the line is a split line: use the current values instead of the original ones
98 cc_id = (not split and line_cc_first) or line_cc_id or False
98 fp_id = line.analytic_id and line.analytic_id.id or False99 fp_id = line.analytic_id and line.analytic_id.id or False
99 if line_cc_id != line_cc_first or line_account_first != line.account_id.id:100 if not split and (line_cc_id != line_cc_first or line_account_first != line.account_id.id):
100 fp_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'analytic_distribution', 'analytic_account_msf_private_funds')[1]101 fp_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'analytic_distribution', 'analytic_account_msf_private_funds')[1]
101 f1_id = line.free_1_id and line.free_1_id.id or False102 f1_id = line.free_1_id and line.free_1_id.id or False
102 f2_id = line.free_2_id and line.free_2_id.id or False103 f2_id = line.free_2_id and line.free_2_id.id or False
103 destination_id = line.destination_id_first_value and line.destination_id_first_value.id or account.default_destination_id and account.default_destination_id.id or False104 destination_id = (split and line.destination_id.id) or line.destination_id_first_value.id or \
105 (account.default_destination_id and account.default_destination_id.id) or False
104 distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {})106 distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {})
105 if distrib_id:107 if distrib_id:
106 common_vals = {'distribution_id':distrib_id,108 common_vals = {'distribution_id':distrib_id,
@@ -124,10 +126,12 @@
124 return distrib_id126 return distrib_id
125127
126 def create_move(self, cr, uid, ids, period_id=False, currency_id=False,128 def create_move(self, cr, uid, ids, period_id=False, currency_id=False,
127 date=None, journal=None, orig_acct=None, doc_date=None, context=None):129 date=None, journal=None, orig_acct=None, doc_date=None, split=False, context=None):
128 """130 """
129 Create a move with given hq entries lines131 Create a move with given hq entries lines
130 Return created lines (except counterpart lines)132 Return created lines (except counterpart lines)
133 Note: if split is True, the lines handled are split lines => the account used is the last given by the user and
134 not the account_id_first_value
131 """135 """
132 # Some verifications136 # Some verifications
133 if context is None:137 if context is None:
@@ -173,9 +177,10 @@
173 if not line.account_id_first_value:177 if not line.account_id_first_value:
174 raise osv.except_osv(_('Error'), _('An account is missing!'))178 raise osv.except_osv(_('Error'), _('An account is missing!'))
175 # create new distribution (only for expense accounts)179 # create new distribution (only for expense accounts)
176 distrib_id = self.create_distribution_id(cr, uid, currency_id, line, line.account_id_first_value)180 line_account = split and line.account_id or line.account_id_first_value
181 distrib_id = self.create_distribution_id(cr, uid, currency_id, line, line_account, split=split)
177 vals = {182 vals = {
178 'account_id': line.account_id_first_value.id,183 'account_id': line_account.id,
179 'period_id': period_id,184 'period_id': period_id,
180 'journal_id': journal_id,185 'journal_id': journal_id,
181 'date': line.date,186 'date': line.date,
@@ -261,10 +266,10 @@
261 #+ original ones266 #+ original ones
262 #+ split ones267 #+ split ones
263 for line in lines:268 for line in lines:
264 if line.is_original:269 if line.is_original and line.split_ids:
265 original_lines.add(line)270 original_lines.add(line)
266 all_lines.add(line.id)271 all_lines.add(line.id)
267 elif line.is_split:272 elif line.is_split and line.original_id:
268 original_lines.add(line.original_id)273 original_lines.add(line.original_id)
269 all_lines.add(line.original_id.id)274 all_lines.add(line.original_id.id)
270 # Create the original line as it is (and its reverse)275 # Create the original line as it is (and its reverse)
@@ -284,7 +289,9 @@
284 aml_obj.write(cr, uid, original_move.id, {'corrected': True, 'have_an_historic': True} , context=context)289 aml_obj.write(cr, uid, original_move.id, {'corrected': True, 'have_an_historic': True} , context=context)
285 original_account_id = original_move.account_id.id290 original_account_id = original_move.account_id.id
286291
287 new_res_move = self.create_move(cr, uid, [x.id for x in line.split_ids], line.period_id.id, line.currency_id.id, date=line.date, doc_date=line.document_date, journal=od_journal_id, orig_acct=original_account_id)292 new_res_move = self.create_move(cr, uid, [x.id for x in line.split_ids], line.period_id.id,
293 line.currency_id.id, date=line.date, doc_date=line.document_date,
294 journal=od_journal_id, orig_acct=original_account_id, split=True, context=context)
288 # original move line295 # original move line
289 original_ml_result = res_move[line.id]296 original_ml_result = res_move[line.id]
290 # Mark new journal items as corrections for the first one297 # Mark new journal items as corrections for the first one
@@ -434,7 +441,7 @@
434 self.write(cr, uid, [wiz.id], {'running': False})441 self.write(cr, uid, [wiz.id], {'running': False})
435 raise osv.except_osv(_('Warning'), _('Invalid analytic distribution!'))442 raise osv.except_osv(_('Warning'), _('Invalid analytic distribution!'))
436 # UTP-760: Do other modifications for split lines443 # UTP-760: Do other modifications for split lines
437 if line.is_original or line.is_split:444 if (line.is_original and line.split_ids) or (line.is_split and line.original_id):
438 split_change.append(line)445 split_change.append(line)
439 continue446 continue
440 if not line.user_validated:447 if not line.user_validated:
441448
=== modified file 'bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv'
--- bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv 2018-03-15 14:46:24 +0000
+++ bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv 2018-04-17 09:11:48 +0000
@@ -38,7 +38,8 @@
38msf_sync_data_server.fp_distribution_line_intermission,FALSE,TRUE,FALSE,FALSE,bidirectional,Bidirectional,"[('cost_center_id' , 'in' , ('account.analytic.account' , 'id' , [('code','=','cc-intermission')]))]","['amount', 'analytic_id/id', 'cost_center_id/id', 'currency_id/id', 'date', 'destination_id/id', 'distribution_id/id', 'name', 'percentage', 'source_date']",COORDINATIONS,funding.pool.distribution.line,,FP Distribution Line - Intermission ,Valid,,21138msf_sync_data_server.fp_distribution_line_intermission,FALSE,TRUE,FALSE,FALSE,bidirectional,Bidirectional,"[('cost_center_id' , 'in' , ('account.analytic.account' , 'id' , [('code','=','cc-intermission')]))]","['amount', 'analytic_id/id', 'cost_center_id/id', 'currency_id/id', 'date', 'destination_id/id', 'distribution_id/id', 'name', 'percentage', 'source_date']",COORDINATIONS,funding.pool.distribution.line,,FP Distribution Line - Intermission ,Valid,,211
39msf_sync_data_server.free_1_distribution_line,TRUE,TRUE,TRUE,FALSE,bidirectional,Bidirectional,[],"['amount', 'analytic_id/id', 'currency_id/id', 'date', 'destination_id/id', 'distribution_id/id', 'name', 'percentage', 'source_date']",HQ + MISSION,free.1.distribution.line,,Free 1 Distribution Line,Valid,,22039msf_sync_data_server.free_1_distribution_line,TRUE,TRUE,TRUE,FALSE,bidirectional,Bidirectional,[],"['amount', 'analytic_id/id', 'currency_id/id', 'date', 'destination_id/id', 'distribution_id/id', 'name', 'percentage', 'source_date']",HQ + MISSION,free.1.distribution.line,,Free 1 Distribution Line,Valid,,220
40msf_sync_data_server.free_2_distribution_line,TRUE,TRUE,TRUE,FALSE,bidirectional,Bidirectional,[],"['amount', 'analytic_id/id', 'currency_id/id', 'date', 'destination_id/id', 'distribution_id/id', 'name', 'percentage', 'source_date']",HQ + MISSION,free.2.distribution.line,,Free 2 Distribution Line,Valid,,22140msf_sync_data_server.free_2_distribution_line,TRUE,TRUE,TRUE,FALSE,bidirectional,Bidirectional,[],"['amount', 'analytic_id/id', 'currency_id/id', 'date', 'destination_id/id', 'distribution_id/id', 'name', 'percentage', 'source_date']",HQ + MISSION,free.2.distribution.line,,Free 2 Distribution Line,Valid,,221
41msf_sync_data_server.hq_entries,TRUE,TRUE,FALSE,FALSE,bidirectional,Bidirectional-Private,[],"['account_id/id', 'account_id_first_value/id', 'amount', 'analytic_id/id', 'analytic_id_first_value/id', 'analytic_state', 'cost_center_id/id', 'cost_center_id_first_value/id', 'currency_id/id', 'date', 'destination_id/id', 'destination_id_first_value/id', 'document_date', 'free_1_id/id', 'free_2_id/id', 'name', 'partner_txt', 'period_id/id', 'ref', 'user_validated']",OC,hq.entries,cost_center_id,HQ Entries,Valid,,25041msf_sync_data_server.hq_entries,TRUE,TRUE,FALSE,FALSE,bidirectional,Bidirectional-Private,[],"['account_id/id', 'account_id_first_value/id', 'amount', 'analytic_id/id', 'analytic_id_first_value/id', 'analytic_state', 'cost_center_id/id', 'cost_center_id_first_value/id', 'currency_id/id', 'date', 'destination_id/id', 'destination_id_first_value/id', 'document_date', 'free_1_id/id', 'free_2_id/id', 'name', 'partner_txt', 'period_id/id', 'ref', 'user_validated', 'is_split', 'is_original']",OC,hq.entries,cost_center_id,HQ Entries,Valid,,250
42msf_sync_data_server.hq_entries_deletion,TRUE,TRUE,TRUE,FALSE,bidirectional,Up,"[('id', '=', 0)]","['name']",OC,hq.entries,,HQ Entries deletion,Valid,,251
42msf_sync_data_server.gl_journal_non_registers,TRUE,TRUE,FALSE,TRUE,bidirectional,Up,"[('type', '!=', 'cash'),('type', '!=', 'cheque'),('type', '!=', 'bank')]","['bank_journal_id/id','analytic_journal_id/id', 'code', 'currency/id', 'default_credit_account_id/id', 'default_debit_account_id/id', 'name', 'type','instance_id/id']",OC,account.journal,,GL Journal (Non Registers),Valid,,26043msf_sync_data_server.gl_journal_non_registers,TRUE,TRUE,FALSE,TRUE,bidirectional,Up,"[('type', '!=', 'cash'),('type', '!=', 'cheque'),('type', '!=', 'bank')]","['bank_journal_id/id','analytic_journal_id/id', 'code', 'currency/id', 'default_credit_account_id/id', 'default_debit_account_id/id', 'name', 'type','instance_id/id']",OC,account.journal,,GL Journal (Non Registers),Valid,,260
43msf_sync_data_server.gl_journals_registers_hq_bank,FALSE,TRUE,FALSE,TRUE,bidirectional,Down,"[('type', '=', 'bank'),('instance_id.level', '=', 'section')]","['bank_journal_id/id','analytic_journal_id/id', 'code', 'currency/id', 'default_credit_account_id/id', 'default_debit_account_id/id', 'name', 'type','instance_id/id']",OC,account.journal,,GL Journals – Bank Registers (HQ),Valid,,26144msf_sync_data_server.gl_journals_registers_hq_bank,FALSE,TRUE,FALSE,TRUE,bidirectional,Down,"[('type', '=', 'bank'),('instance_id.level', '=', 'section')]","['bank_journal_id/id','analytic_journal_id/id', 'code', 'currency/id', 'default_credit_account_id/id', 'default_debit_account_id/id', 'name', 'type','instance_id/id']",OC,account.journal,,GL Journals – Bank Registers (HQ),Valid,,261
44msf_sync_data_server.gl_journals_registers_coordo_bank,FALSE,TRUE,FALSE,TRUE,bidirectional,Down,"[('type', '=', 'bank'),('instance_id.level', '=', 'coordo')]","['bank_journal_id/id','analytic_journal_id/id', 'code', 'currency/id', 'default_credit_account_id/id', 'default_debit_account_id/id', 'name', 'type','instance_id/id']",MISSION,account.journal,,GL Journals – Bank Registers (Coordo),Valid,,26245msf_sync_data_server.gl_journals_registers_coordo_bank,FALSE,TRUE,FALSE,TRUE,bidirectional,Down,"[('type', '=', 'bank'),('instance_id.level', '=', 'coordo')]","['bank_journal_id/id','analytic_journal_id/id', 'code', 'currency/id', 'default_credit_account_id/id', 'default_debit_account_id/id', 'name', 'type','instance_id/id']",MISSION,account.journal,,GL Journals – Bank Registers (Coordo),Valid,,262

Subscribers

People subscribed via source and target branches