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

Proposed by jftempo on 2017-07-04
Status: Merged
Merge reported by: jftempo
Merged at revision: not available
Proposed branch: lp:~julie-w/unifield-server/US-2539
Merge into: lp:unifield-server
Diff against target: 166 lines (+78/-16)
5 files modified
bin/addons/register_accounting/account_bank_statement.py (+26/-0)
bin/addons/register_accounting/report/report_bank_reconciliation.py (+4/-2)
bin/addons/register_accounting/report/report_cheque_inventory.py (+38/-4)
bin/addons/register_accounting/report/report_liquidity_position.py (+3/-4)
bin/addons/register_accounting/report/report_pending_cheque.py (+7/-6)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-2539
Reviewer Review Type Date Requested Status
UniField Reviewer Team 2017-07-04 Pending
Review via email: mp+326753@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/register_accounting/account_bank_statement.py'
2--- bin/addons/register_accounting/account_bank_statement.py 2017-05-26 10:28:09 +0000
3+++ bin/addons/register_accounting/account_bank_statement.py 2017-07-04 09:20:48 +0000
4@@ -671,6 +671,32 @@
5 'target': 'current',
6 }
7
8+ def get_pending_cheque_ids(self, cr, uid, register_ids, account_ids, min_posting_date, context=None):
9+ """
10+ Returns a list containing the ids of the JIs matching the following criteria:
11+ - booked in the register(s) and in the account(s) in parameters
12+ - either not reconciled or reconciled partially or totally with at least one reconciliation leg having a
13+ posting date later than the min_posting_date in parameter
14+ """
15+ if context is None:
16+ context = {}
17+ aml_obj = self.pool.get('account.move.line')
18+ aml_ids = aml_obj.search(cr, uid, [('statement_id', 'in', register_ids),
19+ ('account_id', 'in', account_ids), ],
20+ order='date DESC', context=context)
21+ aml_list = []
22+ for aml in aml_obj.browse(cr, uid, aml_ids,
23+ fields_to_fetch=['is_reconciled', 'reconcile_id', 'reconcile_partial_id'], context=context):
24+ total_rec_ok = aml.reconcile_id and aml_obj.search_exist(cr, uid,
25+ [('reconcile_id', '=', aml.reconcile_id.id),
26+ ('date', '>', min_posting_date)], context=context)
27+ partial_rec_ok = aml.reconcile_partial_id and aml_obj.search_exist(cr, uid,
28+ [('reconcile_partial_id', '=', aml.reconcile_partial_id.id),
29+ ('date', '>', min_posting_date)], context=context)
30+ if not aml.is_reconciled or total_rec_ok or partial_rec_ok:
31+ aml_list.append(aml.id)
32+ return aml_list
33+
34 account_bank_statement()
35
36 class account_bank_statement_line(osv.osv):
37
38=== modified file 'bin/addons/register_accounting/report/report_bank_reconciliation.py'
39--- bin/addons/register_accounting/report/report_bank_reconciliation.py 2016-06-16 15:14:08 +0000
40+++ bin/addons/register_accounting/report/report_bank_reconciliation.py 2017-07-04 09:20:48 +0000
41@@ -67,8 +67,10 @@
42 ids = abs_obj.search(self.cr, self.uid, abs_args, context=self.context)
43
44 amvl_obj = self.pool.get('account.move.line')
45- amvl_ids = amvl_obj.search(self.cr, self.uid, [('statement_id', 'in', ids), ('is_reconciled', '=', False),
46- ('account_id', 'in', account_ids)], context=self.context)
47+ # include in the report only the JIs that are either not reconciled,
48+ # or reconciled (totally or partially) with at least one entry belonging to a later period
49+ amvl_ids = abs_obj.get_pending_cheque_ids(self.cr, self.uid, ids, account_ids, period.date_stop, context=self.context)
50+
51 # amount in booking currency
52 for line in amvl_obj.read(self.cr, self.uid, amvl_ids, ['debit_currency', 'credit_currency'], context=self.context):
53 self.amount_pending_cheque += line['credit_currency']
54
55=== modified file 'bin/addons/register_accounting/report/report_cheque_inventory.py'
56--- bin/addons/register_accounting/report/report_cheque_inventory.py 2014-05-16 09:11:47 +0000
57+++ bin/addons/register_accounting/report/report_cheque_inventory.py 2017-07-04 09:20:48 +0000
58@@ -30,13 +30,41 @@
59 })
60 return
61
62+ def _keep_register_line(self, cr, uid, acc_bank_statement_line, min_posting_date, context=None):
63+ """
64+ Checks the move lines linked to the acc_bank_statement_line in parameter, and returns True if one of them is:
65+ - either reconciled partially or totally with at least one reconciliation leg having a posting date later than
66+ the min_posting_date in parameter
67+ - or not reconciled (but reconcilable)
68+ """
69+ if context is None:
70+ context = {}
71+ aml_obj = self.pool.get('account.move.line')
72+ if acc_bank_statement_line.move_ids and acc_bank_statement_line.state == 'hard':
73+ for move in acc_bank_statement_line.move_ids:
74+ for move_line in move.line_id:
75+ if move_line.account_id.reconcile:
76+ total_rec_ok = move_line.reconcile_id and \
77+ aml_obj.search_exist(cr, uid,
78+ [('reconcile_id', '=', move_line.reconcile_id.id),
79+ ('date', '>', min_posting_date)], context=context)
80+ partial_rec_ok = move_line.reconcile_partial_id and \
81+ aml_obj.search_exist(cr, uid,
82+ [('reconcile_partial_id', '=', move_line.reconcile_partial_id.id),
83+ ('date', '>', min_posting_date)], context=context)
84+ if not move_line.is_reconciled or total_rec_ok or partial_rec_ok:
85+ return True
86+ return False
87+
88 def getLines(self, statement):
89 """
90- Return list of lines from given register and previous ones that are not reconciled
91+ Return list of lines from given register and previous ones that are either not reconciled, or reconciled partially
92+ or totally with at least one reconciliation leg having a posting date belonging to a later period than the register one
93 """
94 # Prepare some values
95 res = []
96 absl_obj = self.pool.get('account.bank.statement.line')
97+ period_obj = self.pool.get('account.period')
98 # Fetch all previous registers linked to this one
99 prev_reg_ids = [statement.id]
100 if statement.prev_reg_id:
101@@ -46,9 +74,15 @@
102 prev_reg_id = prev_reg_id.prev_reg_id or False
103 if prev_reg_id:
104 prev_reg_ids.append(prev_reg_id.id)
105- absl_ids = absl_obj.search(self.cr, self.uid, [('statement_id', 'in', prev_reg_ids), ('reconciled', '=', False)])
106- if absl_ids:
107- res = absl_obj.browse(self.cr, self.uid, absl_ids)
108+ absl_ids = absl_obj.search(self.cr, self.uid, [('statement_id', 'in', prev_reg_ids)])
109+ period_r = period_obj.read(self.cr, self.uid, statement.period_id.id,
110+ ['date_stop']) # used not to format the date in the user language
111+ absl_ids_to_keep = []
112+ for absl in absl_obj.browse(self.cr, self.uid, absl_ids, fields_to_fetch=['move_ids', 'state']):
113+ if self._keep_register_line(self.cr, self.uid, absl, period_r['date_stop']):
114+ absl_ids_to_keep.append(absl.id)
115+ if absl_ids_to_keep:
116+ res = absl_obj.browse(self.cr, self.uid, absl_ids_to_keep)
117 return res
118
119 SpreadsheetReport('report.cheque.inventory.2','account.bank.statement','addons/register_accounting/report/cheque_inventory_xls.mako', parser=report_cheque_inventory)
120
121=== modified file 'bin/addons/register_accounting/report/report_liquidity_position.py'
122--- bin/addons/register_accounting/report/report_liquidity_position.py 2016-06-08 09:40:53 +0000
123+++ bin/addons/register_accounting/report/report_liquidity_position.py 2017-07-04 09:20:48 +0000
124@@ -237,10 +237,9 @@
125 # Search register lines
126 journal = reg.journal_id
127 account_ids = [journal.default_debit_account_id.id, journal.default_credit_account_id.id]
128- aml_ids = aml_obj.search(self.cr, self.uid, [('statement_id', '=', reg.id), ('is_reconciled', '=', False),
129- ('account_id', 'in', account_ids),])
130- if isinstance(aml_ids, (int, long)):
131- aml_ids = [aml_ids]
132+ # include in the report only the JIs that are either not reconciled,
133+ # or reconciled (totally or partially) with at least one entry belonging to a later period
134+ aml_ids = reg_obj.get_pending_cheque_ids(self.cr, self.uid, [reg.id], account_ids, self.getPeriod().date_stop)
135 lines = aml_obj.browse(self.cr, self.uid, aml_ids)
136
137 # Get the amounts in booking and functional currency
138
139=== modified file 'bin/addons/register_accounting/report/report_pending_cheque.py'
140--- bin/addons/register_accounting/report/report_pending_cheque.py 2016-05-23 14:56:46 +0000
141+++ bin/addons/register_accounting/report/report_pending_cheque.py 2017-07-04 09:20:48 +0000
142@@ -41,17 +41,18 @@
143 pool = pooler.get_pool(self.cr.dbname)
144 aml_obj = pool.get('account.move.line')
145
146- period_r = self.pool.get('account.period').read(self.cr, self.uid, register.period_id.id, ['date_start'])
147+ period_r = self.pool.get('account.period').read(self.cr, self.uid, register.period_id.id,
148+ ['date_start', 'date_stop']) # used not to format dates in the user language
149 # Search for all registers with the same Journal, and the same period or a previous period
150 period_ids = self.pool.get('account.period').\
151 search(self.cr, self.uid, [('date_start', '<=', period_r['date_start'])])
152- registers_ids = self.pool.get('account.bank.statement').\
153- search(self.cr, self.uid, ['&', ('journal_id', '=', journal.id), ('period_id', 'in', period_ids)])
154+ reg_obj = self.pool.get('account.bank.statement')
155+ registers_ids = reg_obj.search(self.cr, self.uid, ['&', ('journal_id', '=', journal.id), ('period_id', 'in', period_ids)])
156
157 # Search register lines
158- aml_ids = aml_obj.search(self.cr, self.uid, [('statement_id', 'in', registers_ids), ('is_reconciled', '=', False), ('account_id', 'in', account_ids),], order='date DESC')
159- if isinstance(aml_ids, (int, long)):
160- aml_ids = [aml_ids]
161+ # include in the report only the JIs that are either not reconciled,
162+ # or reconciled (totally or partially) with at least one entry belonging to a later period
163+ aml_ids = reg_obj.get_pending_cheque_ids(self.cr, self.uid, registers_ids, account_ids, period_r['date_stop'])
164 return aml_obj.browse(self.cr, self.uid, aml_ids)
165
166 def getTotals(self, register):

Subscribers

People subscribed via source and target branches