Merge lp:~unifield-team/unifield-wm/sync-2389-duy into lp:unifield-wm/sync

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~unifield-team/unifield-wm/sync-2389-duy
Merge into: lp:unifield-wm/sync
Diff against target: 83 lines (+41/-4)
2 files modified
msf_sync_data_server/data/sync_server.sync_rule.csv (+1/-1)
sync_so/specific_xml_id.py (+40/-3)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/sync-2389-duy
Reviewer Review Type Date Requested Status
UniField Sync Reviewer Pending
Review via email: mp+218924@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

463. By dvo@dvo

UF-2389: Minor fix

462. By dvo@dvo

UF-2389: Various modif to calculate the history in sync case

461. By dvo@dvo

UF-2389: Added new fields to rule 422

460. By Duy VO

UF-2389: WIP

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'msf_sync_data_server/data/sync_server.sync_rule.csv'
2--- msf_sync_data_server/data/sync_server.sync_rule.csv 2014-05-06 07:48:20 +0000
3+++ msf_sync_data_server/data/sync_server.sync_rule.csv 2014-05-09 07:10:45 +0000
4@@ -70,7 +70,7 @@
5 msf_sync_data_server.account_move_state,TRUE,TRUE,FALSE,bidirectional,Bidirectional-Private,[],"['instance_id/id', 'state']",OC,account.move,instance_id,Account Move State,Valid,,416
6 msf_sync_data_server.analytical_line,TRUE,TRUE,TRUE,bidirectional,Bidirectional-Private,"[('account_id.category', '=', 'FUNDING'), ('imported_commitment','=',False)]","['account_id/id', 'amount', 'amount_currency', 'correction_date', 'code', 'cost_center_id/id', 'currency_id/id', 'date', 'destination_id/id', 'distrib_line_id', 'distribution_id/id', 'document_date', 'general_account_id/id', 'instance_id/id', 'is_reallocated', 'is_reversal', 'journal_id/id', 'move_id/id', 'name', 'ref', 'source_date', 'entry_sequence']",OC,account.analytic.line,cost_center_id,Analytical Line,Valid,,420
7 msf_sync_data_server.analytical_line_free,TRUE,TRUE,TRUE,bidirectional,Up,"[('account_id.category', 'in', ['FREE1', 'FREE2'])]","['account_id/id', 'amount', 'amount_currency', 'code', 'currency_id/id', 'date', 'distrib_line_id', 'correction_date','document_date', 'general_account_id/id', 'instance_id/id', 'is_reallocated', 'is_reversal', 'journal_id/id', 'move_id/id', 'name', 'ref', 'reversal_origin/id', 'source_date', 'entry_sequence']",MISSION,account.analytic.line,,Analytic Line (Free 1 and Free 2),Valid,,421
8-msf_sync_data_server.analytical_line_correction,TRUE,TRUE,TRUE,bidirectional,Bidirectional-Private,"[('account_id.category', '=', 'FUNDING'), ('imported_commitment','=',False)]","['last_corrected_id/id', 'cost_center_id/id', 'reversal_origin/id']",OC,account.analytic.line,cost_center_id,Analytical Line,Valid,,422
9+msf_sync_data_server.analytical_line_correction,TRUE,TRUE,TRUE,bidirectional,Bidirectional-Private,"[('account_id.category', '=', 'FUNDING'), ('imported_commitment','=',False)]","['corrected_original_xml_ids', 'is_reversal', 'last_corrected_id/id', 'cost_center_id/id', 'reversal_origin/id']",OC,account.analytic.line,cost_center_id,Analytical Line,Valid,,422
10 msf_sync_data_server.budget,TRUE,TRUE,FALSE,bidirectional,Up,"[('type','=','normal'), ('state', '!=', 'draft')]","['code', 'cost_center_id/id', 'currency_id/id', 'decision_moment_id/id', 'decision_moment_order', 'fiscalyear_id/id', 'name', 'type', 'version']",OC,msf.budget,,Budget,Valid,,430
11 msf_sync_data_server.budget_line,TRUE,TRUE,FALSE,bidirectional,Up,"[('budget_id','in',('msf.budget','id',[('type','=','normal'), ('state', '!=', 'draft')]))]","['account_id/id', 'budget_id/id', 'month1', 'month2', 'month3', 'month4', 'month5', 'month6', 'month7', 'month8', 'month9', 'month10', 'month11', 'month12', 'destination_id/id', 'line_type']",OC,msf.budget.line,,Budget line,Valid,,431
12 msf_sync_data_server.budget_status,TRUE,TRUE,FALSE,bidirectional,Up,"[('type','=','normal'), ('state', '!=', 'draft')]",['state'],OC,msf.budget,,Budget status,Valid,,432
13
14=== modified file 'sync_so/specific_xml_id.py'
15--- sync_so/specific_xml_id.py 2014-05-06 14:27:37 +0000
16+++ sync_so/specific_xml_id.py 2014-05-09 07:10:45 +0000
17@@ -6,6 +6,7 @@
18
19 from osv import osv
20 from osv import fields
21+from sync_common import xmlid_to_sdref
22
23 # Note:
24 #
25@@ -297,6 +298,15 @@
26 'correction_date': fields.datetime('Correction Date'), # UF-2343: Add timestamp when making the correction, to be synced
27 }
28
29+ def get_corrected_xml_ids(self, cr, uid, ids, context=None):
30+ # UFTP-182: Calculate the xml_id for the corrected lines
31+ identifier = self.pool.get('sync.client.entity')._get_entity(cr).identifier
32+ list_xml_ids = []
33+ for res_id in ids:
34+ name = self.get_unique_xml_name(cr, uid, identifier, self._table, res_id)
35+ list_xml_ids.append(name)
36+ return ','.join(list_xml_ids)
37+
38 def get_instance_name_from_cost_center(self, cr, uid, cost_center_id, context=None):
39 if cost_center_id:
40 target_ids = self.pool.get('account.target.costcenter').search(cr, uid, [('cost_center_id', '=', cost_center_id),
41@@ -395,12 +405,39 @@
42 def write(self, cr, uid, ids, vals, context=None):
43 if context is None:
44 context = {}
45+ if isinstance(ids, (long, int)):
46+ ids = [ids]
47+
48+ # UFTP-182: Treat the correction history when the link is randomly picked for the reference
49+ if 'corrected_original_xml_ids' in vals:
50+ identifier = self.pool.get('sync.client.entity')._get_entity(cr).identifier
51+ name = self.get_unique_xml_name(cr, uid, identifier, self._table, ids[0])
52+
53+ xml_ids = vals['corrected_original_xml_ids']
54+ if xml_ids:
55+ if name in xml_ids:
56+ vals['corrected_original_xml_ids'] = ''
57+
58+ # For sync update: calculate the xml_id provided to res_id of the original corrected line
59+ if context.get('sync_update_execution', False):
60+ # If come from sync, then calculate the xml_ids to put in the right column: last_corrected_id or reversal_origin
61+ xml_ids = xml_ids.split(',')
62+ # get the res_id from the given xml_ids
63+ res_id = None
64+ for xml_id in xml_ids: # some xml_ids provided may not have res_id in the local system
65+ xml_id = xml_id.strip()
66+ res_id = self.pool.get('account.analytic.line').find_sd_ref(cr, uid, xml_id, context=context)
67+ if res_id:
68+ break
69+ if vals.get('is_reversal', False):
70+ if not vals.get('reversal_origin', False):
71+ vals['reversal_origin'] = res_id
72+ elif not vals.get('last_corrected_id', False):
73+ vals['last_corrected_id'] = res_id
74+
75 if not 'cost_center_id' in vals:
76 return super(account_analytic_line, self).write(cr, uid, ids, vals, context=context)
77
78- if isinstance(ids, (long, int)):
79- ids = [ids]
80-
81 # Only set the correction date if data not come from sync
82 if not context.get('sync_update_execution', False):
83 vals['correction_date'] = fields.datetime.now() # This timestamp is used for the write, but need to set BEFORE

Subscribers

People subscribed via source and target branches

to all changes: