Merge lp:~julie-w/unifield-server/US-2539 into lp:unifield-server
- US-2539
- Merge into trunk
Proposed by
jftempo
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+326753@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/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 | 671 | 'target': 'current', | 671 | 'target': 'current', |
6 | 672 | } | 672 | } |
7 | 673 | 673 | ||
8 | 674 | def get_pending_cheque_ids(self, cr, uid, register_ids, account_ids, min_posting_date, context=None): | ||
9 | 675 | """ | ||
10 | 676 | Returns a list containing the ids of the JIs matching the following criteria: | ||
11 | 677 | - booked in the register(s) and in the account(s) in parameters | ||
12 | 678 | - either not reconciled or reconciled partially or totally with at least one reconciliation leg having a | ||
13 | 679 | posting date later than the min_posting_date in parameter | ||
14 | 680 | """ | ||
15 | 681 | if context is None: | ||
16 | 682 | context = {} | ||
17 | 683 | aml_obj = self.pool.get('account.move.line') | ||
18 | 684 | aml_ids = aml_obj.search(cr, uid, [('statement_id', 'in', register_ids), | ||
19 | 685 | ('account_id', 'in', account_ids), ], | ||
20 | 686 | order='date DESC', context=context) | ||
21 | 687 | aml_list = [] | ||
22 | 688 | for aml in aml_obj.browse(cr, uid, aml_ids, | ||
23 | 689 | fields_to_fetch=['is_reconciled', 'reconcile_id', 'reconcile_partial_id'], context=context): | ||
24 | 690 | total_rec_ok = aml.reconcile_id and aml_obj.search_exist(cr, uid, | ||
25 | 691 | [('reconcile_id', '=', aml.reconcile_id.id), | ||
26 | 692 | ('date', '>', min_posting_date)], context=context) | ||
27 | 693 | partial_rec_ok = aml.reconcile_partial_id and aml_obj.search_exist(cr, uid, | ||
28 | 694 | [('reconcile_partial_id', '=', aml.reconcile_partial_id.id), | ||
29 | 695 | ('date', '>', min_posting_date)], context=context) | ||
30 | 696 | if not aml.is_reconciled or total_rec_ok or partial_rec_ok: | ||
31 | 697 | aml_list.append(aml.id) | ||
32 | 698 | return aml_list | ||
33 | 699 | |||
34 | 674 | account_bank_statement() | 700 | account_bank_statement() |
35 | 675 | 701 | ||
36 | 676 | class account_bank_statement_line(osv.osv): | 702 | class account_bank_statement_line(osv.osv): |
37 | 677 | 703 | ||
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 | 67 | ids = abs_obj.search(self.cr, self.uid, abs_args, context=self.context) | 67 | ids = abs_obj.search(self.cr, self.uid, abs_args, context=self.context) |
43 | 68 | 68 | ||
44 | 69 | amvl_obj = self.pool.get('account.move.line') | 69 | amvl_obj = self.pool.get('account.move.line') |
47 | 70 | amvl_ids = amvl_obj.search(self.cr, self.uid, [('statement_id', 'in', ids), ('is_reconciled', '=', False), | 70 | # include in the report only the JIs that are either not reconciled, |
48 | 71 | ('account_id', 'in', account_ids)], context=self.context) | 71 | # or reconciled (totally or partially) with at least one entry belonging to a later period |
49 | 72 | amvl_ids = abs_obj.get_pending_cheque_ids(self.cr, self.uid, ids, account_ids, period.date_stop, context=self.context) | ||
50 | 73 | |||
51 | 72 | # amount in booking currency | 74 | # amount in booking currency |
52 | 73 | for line in amvl_obj.read(self.cr, self.uid, amvl_ids, ['debit_currency', 'credit_currency'], context=self.context): | 75 | for line in amvl_obj.read(self.cr, self.uid, amvl_ids, ['debit_currency', 'credit_currency'], context=self.context): |
53 | 74 | self.amount_pending_cheque += line['credit_currency'] | 76 | self.amount_pending_cheque += line['credit_currency'] |
54 | 75 | 77 | ||
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 | 30 | }) | 30 | }) |
60 | 31 | return | 31 | return |
61 | 32 | 32 | ||
62 | 33 | def _keep_register_line(self, cr, uid, acc_bank_statement_line, min_posting_date, context=None): | ||
63 | 34 | """ | ||
64 | 35 | Checks the move lines linked to the acc_bank_statement_line in parameter, and returns True if one of them is: | ||
65 | 36 | - either reconciled partially or totally with at least one reconciliation leg having a posting date later than | ||
66 | 37 | the min_posting_date in parameter | ||
67 | 38 | - or not reconciled (but reconcilable) | ||
68 | 39 | """ | ||
69 | 40 | if context is None: | ||
70 | 41 | context = {} | ||
71 | 42 | aml_obj = self.pool.get('account.move.line') | ||
72 | 43 | if acc_bank_statement_line.move_ids and acc_bank_statement_line.state == 'hard': | ||
73 | 44 | for move in acc_bank_statement_line.move_ids: | ||
74 | 45 | for move_line in move.line_id: | ||
75 | 46 | if move_line.account_id.reconcile: | ||
76 | 47 | total_rec_ok = move_line.reconcile_id and \ | ||
77 | 48 | aml_obj.search_exist(cr, uid, | ||
78 | 49 | [('reconcile_id', '=', move_line.reconcile_id.id), | ||
79 | 50 | ('date', '>', min_posting_date)], context=context) | ||
80 | 51 | partial_rec_ok = move_line.reconcile_partial_id and \ | ||
81 | 52 | aml_obj.search_exist(cr, uid, | ||
82 | 53 | [('reconcile_partial_id', '=', move_line.reconcile_partial_id.id), | ||
83 | 54 | ('date', '>', min_posting_date)], context=context) | ||
84 | 55 | if not move_line.is_reconciled or total_rec_ok or partial_rec_ok: | ||
85 | 56 | return True | ||
86 | 57 | return False | ||
87 | 58 | |||
88 | 33 | def getLines(self, statement): | 59 | def getLines(self, statement): |
89 | 34 | """ | 60 | """ |
91 | 35 | Return list of lines from given register and previous ones that are not reconciled | 61 | Return list of lines from given register and previous ones that are either not reconciled, or reconciled partially |
92 | 62 | or totally with at least one reconciliation leg having a posting date belonging to a later period than the register one | ||
93 | 36 | """ | 63 | """ |
94 | 37 | # Prepare some values | 64 | # Prepare some values |
95 | 38 | res = [] | 65 | res = [] |
96 | 39 | absl_obj = self.pool.get('account.bank.statement.line') | 66 | absl_obj = self.pool.get('account.bank.statement.line') |
97 | 67 | period_obj = self.pool.get('account.period') | ||
98 | 40 | # Fetch all previous registers linked to this one | 68 | # Fetch all previous registers linked to this one |
99 | 41 | prev_reg_ids = [statement.id] | 69 | prev_reg_ids = [statement.id] |
100 | 42 | if statement.prev_reg_id: | 70 | if statement.prev_reg_id: |
101 | @@ -46,9 +74,15 @@ | |||
102 | 46 | prev_reg_id = prev_reg_id.prev_reg_id or False | 74 | prev_reg_id = prev_reg_id.prev_reg_id or False |
103 | 47 | if prev_reg_id: | 75 | if prev_reg_id: |
104 | 48 | prev_reg_ids.append(prev_reg_id.id) | 76 | prev_reg_ids.append(prev_reg_id.id) |
108 | 49 | absl_ids = absl_obj.search(self.cr, self.uid, [('statement_id', 'in', prev_reg_ids), ('reconciled', '=', False)]) | 77 | absl_ids = absl_obj.search(self.cr, self.uid, [('statement_id', 'in', prev_reg_ids)]) |
109 | 50 | if absl_ids: | 78 | period_r = period_obj.read(self.cr, self.uid, statement.period_id.id, |
110 | 51 | res = absl_obj.browse(self.cr, self.uid, absl_ids) | 79 | ['date_stop']) # used not to format the date in the user language |
111 | 80 | absl_ids_to_keep = [] | ||
112 | 81 | for absl in absl_obj.browse(self.cr, self.uid, absl_ids, fields_to_fetch=['move_ids', 'state']): | ||
113 | 82 | if self._keep_register_line(self.cr, self.uid, absl, period_r['date_stop']): | ||
114 | 83 | absl_ids_to_keep.append(absl.id) | ||
115 | 84 | if absl_ids_to_keep: | ||
116 | 85 | res = absl_obj.browse(self.cr, self.uid, absl_ids_to_keep) | ||
117 | 52 | return res | 86 | return res |
118 | 53 | 87 | ||
119 | 54 | SpreadsheetReport('report.cheque.inventory.2','account.bank.statement','addons/register_accounting/report/cheque_inventory_xls.mako', parser=report_cheque_inventory) | 88 | SpreadsheetReport('report.cheque.inventory.2','account.bank.statement','addons/register_accounting/report/cheque_inventory_xls.mako', parser=report_cheque_inventory) |
120 | 55 | 89 | ||
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 | 237 | # Search register lines | 237 | # Search register lines |
126 | 238 | journal = reg.journal_id | 238 | journal = reg.journal_id |
127 | 239 | account_ids = [journal.default_debit_account_id.id, journal.default_credit_account_id.id] | 239 | account_ids = [journal.default_debit_account_id.id, journal.default_credit_account_id.id] |
132 | 240 | aml_ids = aml_obj.search(self.cr, self.uid, [('statement_id', '=', reg.id), ('is_reconciled', '=', False), | 240 | # include in the report only the JIs that are either not reconciled, |
133 | 241 | ('account_id', 'in', account_ids),]) | 241 | # or reconciled (totally or partially) with at least one entry belonging to a later period |
134 | 242 | if isinstance(aml_ids, (int, long)): | 242 | aml_ids = reg_obj.get_pending_cheque_ids(self.cr, self.uid, [reg.id], account_ids, self.getPeriod().date_stop) |
131 | 243 | aml_ids = [aml_ids] | ||
135 | 244 | lines = aml_obj.browse(self.cr, self.uid, aml_ids) | 243 | lines = aml_obj.browse(self.cr, self.uid, aml_ids) |
136 | 245 | 244 | ||
137 | 246 | # Get the amounts in booking and functional currency | 245 | # Get the amounts in booking and functional currency |
138 | 247 | 246 | ||
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 | 41 | pool = pooler.get_pool(self.cr.dbname) | 41 | pool = pooler.get_pool(self.cr.dbname) |
144 | 42 | aml_obj = pool.get('account.move.line') | 42 | aml_obj = pool.get('account.move.line') |
145 | 43 | 43 | ||
147 | 44 | period_r = self.pool.get('account.period').read(self.cr, self.uid, register.period_id.id, ['date_start']) | 44 | period_r = self.pool.get('account.period').read(self.cr, self.uid, register.period_id.id, |
148 | 45 | ['date_start', 'date_stop']) # used not to format dates in the user language | ||
149 | 45 | # Search for all registers with the same Journal, and the same period or a previous period | 46 | # Search for all registers with the same Journal, and the same period or a previous period |
150 | 46 | period_ids = self.pool.get('account.period').\ | 47 | period_ids = self.pool.get('account.period').\ |
151 | 47 | search(self.cr, self.uid, [('date_start', '<=', period_r['date_start'])]) | 48 | search(self.cr, self.uid, [('date_start', '<=', period_r['date_start'])]) |
154 | 48 | registers_ids = self.pool.get('account.bank.statement').\ | 49 | reg_obj = self.pool.get('account.bank.statement') |
155 | 49 | search(self.cr, self.uid, ['&', ('journal_id', '=', journal.id), ('period_id', 'in', period_ids)]) | 50 | registers_ids = reg_obj.search(self.cr, self.uid, ['&', ('journal_id', '=', journal.id), ('period_id', 'in', period_ids)]) |
156 | 50 | 51 | ||
157 | 51 | # Search register lines | 52 | # Search register lines |
161 | 52 | 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') | 53 | # include in the report only the JIs that are either not reconciled, |
162 | 53 | if isinstance(aml_ids, (int, long)): | 54 | # or reconciled (totally or partially) with at least one entry belonging to a later period |
163 | 54 | aml_ids = [aml_ids] | 55 | aml_ids = reg_obj.get_pending_cheque_ids(self.cr, self.uid, registers_ids, account_ids, period_r['date_stop']) |
164 | 55 | return aml_obj.browse(self.cr, self.uid, aml_ids) | 56 | return aml_obj.browse(self.cr, self.uid, aml_ids) |
165 | 56 | 57 | ||
166 | 57 | def getTotals(self, register): | 58 | def getTotals(self, register): |