Merge lp:~akretion-team/account-closing/70-forecast-prepaid into lp:~account-core-editors/account-closing/7.0
- 70-forecast-prepaid
- Merge into 7.0
Status: | Needs review |
---|---|
Proposed branch: | lp:~akretion-team/account-closing/70-forecast-prepaid |
Merge into: | lp:~account-core-editors/account-closing/7.0 |
Diff against target: |
583 lines (+237/-61) 8 files modified
account_cutoff_base/account_cutoff.py (+10/-8) account_cutoff_base/account_cutoff_view.xml (+5/-5) account_cutoff_prepaid/__openerp__.py (+1/-1) account_cutoff_prepaid/account_cutoff.py (+87/-27) account_cutoff_prepaid/account_cutoff_view.xml (+48/-3) account_cutoff_prepaid/account_invoice_view.xml (+5/-2) account_cutoff_prepaid/i18n/account_cutoff_prepaid.pot (+52/-15) account_cutoff_prepaid/migrations/7.0.0.2/pre-migration.py (+29/-0) |
To merge this branch: | bzr merge lp:~akretion-team/account-closing/70-forecast-prepaid |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Fayolle - camptocamp | code review, no tests | Needs Fixing | |
Benoit Guillot - http://www.akretion.com (community) | code review no test | Approve | |
Review via email: mp+210066@code.launchpad.net |
Commit message
Description of the change
The main change in this MP is the addition of one new feature : the ability to compute forecasts of prepaid expense and prepaid revenue. This is important when working on budgets ; it allows the Accountant to easily compute the amount of prepaid revenue and prepaid expense between 2 dates in the future (you can also use it for dates in the past...).
This feature used to be available in the module "account_
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote : | # |
- 39. By Alexis de Lattre
-
Fix invisibility of "Create Journal Entry" button (live from Open Days !)
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
please add automated tests.
Additionally I'm interested in an explanation about the various comparison operators used : sometimes you use strict inequality, sometime -or-equal comparison (e.g. line 241 vs line 248).
- 40. By Alexis de Lattre
-
FIX compatibility with sale_analytic_plans
Unmerged revisions
- 40. By Alexis de Lattre
-
FIX compatibility with sale_analytic_plans
- 39. By Alexis de Lattre
-
Fix invisibility of "Create Journal Entry" button (live from Open Days !)
- 38. By Alexis de Lattre
-
Update POT file.
- 37. By Alexis de Lattre
-
Add Forecast feature for prepaid.
Preview Diff
1 | === modified file 'account_cutoff_base/account_cutoff.py' | |||
2 | --- account_cutoff_base/account_cutoff.py 2013-12-24 15:31:15 +0000 | |||
3 | +++ account_cutoff_base/account_cutoff.py 2016-05-13 13:23:12 +0000 | |||
4 | @@ -61,7 +61,7 @@ | |||
5 | 61 | 61 | ||
6 | 62 | _columns = { | 62 | _columns = { |
7 | 63 | 'cutoff_date': fields.date( | 63 | 'cutoff_date': fields.date( |
9 | 64 | 'Cut-off Date', required=True, readonly=True, | 64 | 'Cut-off Date', readonly=True, |
10 | 65 | states={'draft': [('readonly', False)]}, | 65 | states={'draft': [('readonly', False)]}, |
11 | 66 | track_visibility='always'), | 66 | track_visibility='always'), |
12 | 67 | 'type': fields.selection([ | 67 | 'type': fields.selection([ |
13 | @@ -75,7 +75,7 @@ | |||
14 | 75 | 'account.move', 'Cut-off Journal Entry', readonly=True), | 75 | 'account.move', 'Cut-off Journal Entry', readonly=True), |
15 | 76 | 'move_label': fields.char( | 76 | 'move_label': fields.char( |
16 | 77 | 'Label of the Cut-off Journal Entry', | 77 | 'Label of the Cut-off Journal Entry', |
18 | 78 | size=64, required=True, readonly=True, | 78 | size=64, readonly=True, |
19 | 79 | states={'draft': [('readonly', False)]}, | 79 | states={'draft': [('readonly', False)]}, |
20 | 80 | help="This label will be written in the 'Name' field of the " | 80 | help="This label will be written in the 'Name' field of the " |
21 | 81 | "Cut-off Account Move Lines and in the 'Reference' field of " | 81 | "Cut-off Account Move Lines and in the 'Reference' field of " |
22 | @@ -83,10 +83,9 @@ | |||
23 | 83 | 'cutoff_account_id': fields.many2one( | 83 | 'cutoff_account_id': fields.many2one( |
24 | 84 | 'account.account', 'Cut-off Account', | 84 | 'account.account', 'Cut-off Account', |
25 | 85 | domain=[('type', '<>', 'view'), ('type', '<>', 'closed')], | 85 | domain=[('type', '<>', 'view'), ('type', '<>', 'closed')], |
28 | 86 | required=True, readonly=True, | 86 | readonly=True, states={'draft': [('readonly', False)]}), |
27 | 87 | states={'draft': [('readonly', False)]}), | ||
29 | 88 | 'cutoff_journal_id': fields.many2one( | 87 | 'cutoff_journal_id': fields.many2one( |
31 | 89 | 'account.journal', 'Cut-off Account Journal', required=True, | 88 | 'account.journal', 'Cut-off Account Journal', |
32 | 90 | readonly=True, states={'draft': [('readonly', False)]}), | 89 | readonly=True, states={'draft': [('readonly', False)]}), |
33 | 91 | 'total_cutoff_amount': fields.function( | 90 | 'total_cutoff_amount': fields.function( |
34 | 92 | _compute_total_cutoff, type='float', string="Total Cut-off Amount", | 91 | _compute_total_cutoff, type='float', string="Total Cut-off Amount", |
35 | @@ -165,12 +164,15 @@ | |||
36 | 165 | )] | 164 | )] |
37 | 166 | 165 | ||
38 | 167 | def cutoff_date_onchange( | 166 | def cutoff_date_onchange( |
40 | 168 | self, cr, uid, ids, type, cutoff_date, move_label): | 167 | self, cr, uid, ids, type, cutoff_date, move_label, context=None): |
41 | 168 | if context is None: | ||
42 | 169 | context = {} | ||
43 | 169 | res = {'value': {}} | 170 | res = {'value': {}} |
44 | 170 | if type and cutoff_date: | 171 | if type and cutoff_date: |
46 | 171 | context = {'type': type, 'cutoff_date': cutoff_date} | 172 | ctx = context.copy() |
47 | 173 | ctx.update({'type': type, 'cutoff_date': cutoff_date}) | ||
48 | 172 | res['value']['move_label'] = self._default_move_label( | 174 | res['value']['move_label'] = self._default_move_label( |
50 | 173 | cr, uid, context=context) | 175 | cr, uid, context=ctx) |
51 | 174 | return res | 176 | return res |
52 | 175 | 177 | ||
53 | 176 | def back2draft(self, cr, uid, ids, context=None): | 178 | def back2draft(self, cr, uid, ids, context=None): |
54 | 177 | 179 | ||
55 | === modified file 'account_cutoff_base/account_cutoff_view.xml' | |||
56 | --- account_cutoff_base/account_cutoff_view.xml 2013-10-15 19:35:48 +0000 | |||
57 | +++ account_cutoff_base/account_cutoff_view.xml 2016-05-13 13:23:12 +0000 | |||
58 | @@ -24,7 +24,7 @@ | |||
59 | 24 | <header> | 24 | <header> |
60 | 25 | <button name="back2draft" string="Back to Draft" type="object" states="done" /> | 25 | <button name="back2draft" string="Back to Draft" type="object" states="done" /> |
61 | 26 | <!-- here, we have the 'get_lines' button that is supplied by the other cutoff modules --> | 26 | <!-- here, we have the 'get_lines' button that is supplied by the other cutoff modules --> |
63 | 27 | <button class="oe_highlight" name="create_move" string="Create Journal Entry" type="object" states="draft" attrs="{'invisible': ['|', ('line_ids', '=', False), ('state', '=', 'done')]}"/> | 27 | <button class="oe_highlight" name="create_move" string="Create Journal Entry" type="object" attrs="{'invisible': ['|', ('line_ids', '=', False), ('state', '=', 'done')]}"/> |
64 | 28 | <field name="state" widget="statusbar" /> | 28 | <field name="state" widget="statusbar" /> |
65 | 29 | </header> | 29 | </header> |
66 | 30 | <sheet> | 30 | <sheet> |
67 | @@ -35,15 +35,15 @@ | |||
68 | 35 | </div> | 35 | </div> |
69 | 36 | <group name="top"> | 36 | <group name="top"> |
70 | 37 | <group name="general-params"> | 37 | <group name="general-params"> |
72 | 38 | <field name="cutoff_date" on_change="cutoff_date_onchange(type, cutoff_date, move_label)"/> | 38 | <field name="cutoff_date" on_change="cutoff_date_onchange(type, cutoff_date, move_label, context)"/> |
73 | 39 | <field name="total_cutoff_amount" widget="monetary" options="{'currency_field': 'company_currency_id'}"/> | 39 | <field name="total_cutoff_amount" widget="monetary" options="{'currency_field': 'company_currency_id'}"/> |
74 | 40 | <field name="company_id" groups="base.group_multi_company" widget="selection" /> | 40 | <field name="company_id" groups="base.group_multi_company" widget="selection" /> |
75 | 41 | <field name="company_currency_id" invisible="1"/> | 41 | <field name="company_currency_id" invisible="1"/> |
76 | 42 | </group> | 42 | </group> |
77 | 43 | <group name="accounting-params"> | 43 | <group name="accounting-params"> |
81 | 44 | <field name="cutoff_journal_id"/> | 44 | <field name="cutoff_journal_id" required="1"/> |
82 | 45 | <field name="cutoff_account_id"/> | 45 | <field name="cutoff_account_id" required="1"/> |
83 | 46 | <field name="move_label"/> | 46 | <field name="move_label" required="1"/> |
84 | 47 | <field name="move_id"/> | 47 | <field name="move_id"/> |
85 | 48 | </group> | 48 | </group> |
86 | 49 | </group> | 49 | </group> |
87 | 50 | 50 | ||
88 | === modified file 'account_cutoff_prepaid/__openerp__.py' | |||
89 | --- account_cutoff_prepaid/__openerp__.py 2013-09-09 21:28:50 +0000 | |||
90 | +++ account_cutoff_prepaid/__openerp__.py 2016-05-13 13:23:12 +0000 | |||
91 | @@ -23,7 +23,7 @@ | |||
92 | 23 | 23 | ||
93 | 24 | { | 24 | { |
94 | 25 | 'name': 'Account Cut-off Prepaid', | 25 | 'name': 'Account Cut-off Prepaid', |
96 | 26 | 'version': '0.1', | 26 | 'version': '0.2', |
97 | 27 | 'category': 'Accounting & Finance', | 27 | 'category': 'Accounting & Finance', |
98 | 28 | 'license': 'AGPL-3', | 28 | 'license': 'AGPL-3', |
99 | 29 | 'summary': 'Prepaid Expense, Prepaid Revenue', | 29 | 'summary': 'Prepaid Expense, Prepaid Revenue', |
100 | 30 | 30 | ||
101 | === modified file 'account_cutoff_prepaid/account_cutoff.py' | |||
102 | --- account_cutoff_prepaid/account_cutoff.py 2013-12-24 15:31:15 +0000 | |||
103 | +++ account_cutoff_prepaid/account_cutoff.py 2016-05-13 13:23:12 +0000 | |||
104 | @@ -23,6 +23,7 @@ | |||
105 | 23 | 23 | ||
106 | 24 | from openerp.osv import orm, fields | 24 | from openerp.osv import orm, fields |
107 | 25 | from openerp.tools.translate import _ | 25 | from openerp.tools.translate import _ |
108 | 26 | from openerp.tools import DEFAULT_SERVER_DATE_FORMAT | ||
109 | 26 | from datetime import datetime | 27 | from datetime import datetime |
110 | 27 | 28 | ||
111 | 28 | 29 | ||
112 | @@ -34,6 +35,13 @@ | |||
113 | 34 | 'account.journal', id1='cutoff_id', id2='journal_id', | 35 | 'account.journal', id1='cutoff_id', id2='journal_id', |
114 | 35 | string='Source Journals', readonly=True, | 36 | string='Source Journals', readonly=True, |
115 | 36 | states={'draft': [('readonly', False)]}), | 37 | states={'draft': [('readonly', False)]}), |
116 | 38 | 'forecast': fields.boolean( | ||
117 | 39 | 'Forecast', | ||
118 | 40 | readonly=True, states={'draft': [('readonly', False)]}, | ||
119 | 41 | help="The Forecast mode allows the user to compute " | ||
120 | 42 | "the prepaid revenue/expense between 2 dates in the future."), | ||
121 | 43 | 'start_date': fields.date('Start Date'), | ||
122 | 44 | 'end_date': fields.date('End Date'), | ||
123 | 37 | } | 45 | } |
124 | 38 | 46 | ||
125 | 39 | def _get_default_source_journals(self, cr, uid, context=None): | 47 | def _get_default_source_journals(self, cr, uid, context=None): |
126 | @@ -58,32 +66,71 @@ | |||
127 | 58 | } | 66 | } |
128 | 59 | 67 | ||
129 | 60 | _sql_constraints = [( | 68 | _sql_constraints = [( |
133 | 61 | 'date_type_company_uniq', | 69 | 'date_type_forecast_company_uniq', |
134 | 62 | 'unique(cutoff_date, company_id, type)', | 70 | 'unique(cutoff_date, company_id, type, forecast, start_date, end_date)', |
135 | 63 | 'A cut-off of the same type already exists with this cut-off date !' | 71 | 'A cut-off of the same type already exists with the same date(s) !' |
136 | 64 | )] | 72 | )] |
137 | 65 | 73 | ||
138 | 74 | def _check_start_end_dates(self, cr, uid, ids): | ||
139 | 75 | for prepaid in self.browse(cr, uid, ids): | ||
140 | 76 | if prepaid.forecast and prepaid.start_date and prepaid.end_date \ | ||
141 | 77 | and prepaid.start_date > prepaid.end_date: | ||
142 | 78 | return False | ||
143 | 79 | return True | ||
144 | 80 | |||
145 | 81 | _constraints = [ | ||
146 | 82 | (_check_start_end_dates, "The start date is after the end date!", | ||
147 | 83 | ['start_date', 'end_date', 'forecast']), | ||
148 | 84 | ] | ||
149 | 85 | |||
150 | 86 | def forecast_onchange(self, cr, uid, ids, forecast, context=None): | ||
151 | 87 | res = {'value': {}} | ||
152 | 88 | line_ids = self.pool['account.cutoff.line'].search( | ||
153 | 89 | cr, uid, [('parent_id', 'in', ids)], context=context) | ||
154 | 90 | self.pool['account.cutoff.line'].unlink( | ||
155 | 91 | cr, uid, line_ids, context=context) | ||
156 | 92 | if forecast: | ||
157 | 93 | res['value']['cutoff_date'] = False | ||
158 | 94 | else: | ||
159 | 95 | res['value']['start_date'] = False | ||
160 | 96 | res['value']['end_date'] = False | ||
161 | 97 | return res | ||
162 | 98 | |||
163 | 66 | def _prepare_prepaid_lines( | 99 | def _prepare_prepaid_lines( |
164 | 67 | self, cr, uid, ids, aml, cur_cutoff, mapping, context=None): | 100 | self, cr, uid, ids, aml, cur_cutoff, mapping, context=None): |
169 | 68 | start_date = datetime.strptime(aml['start_date'], '%Y-%m-%d') | 101 | start_date = datetime.strptime( |
170 | 69 | end_date = datetime.strptime(aml['end_date'], '%Y-%m-%d') | 102 | aml['start_date'], DEFAULT_SERVER_DATE_FORMAT) |
171 | 70 | cutoff_date_str = cur_cutoff['cutoff_date'] | 103 | end_date = datetime.strptime( |
172 | 71 | cutoff_date = datetime.strptime(cutoff_date_str, '%Y-%m-%d') | 104 | aml['end_date'], DEFAULT_SERVER_DATE_FORMAT) |
173 | 72 | # Here, we compute the amount of the cutoff | 105 | # Here, we compute the amount of the cutoff |
174 | 73 | # That's the important part ! | 106 | # That's the important part ! |
175 | 74 | total_days = (end_date - start_date).days + 1 | 107 | total_days = (end_date - start_date).days + 1 |
179 | 75 | if aml['start_date'] > cutoff_date_str: | 108 | if cur_cutoff['forecast']: |
180 | 76 | after_cutoff_days = total_days | 109 | out_days = 0 |
181 | 77 | cutoff_amount = -1 * (aml['credit'] - aml['debit']) | 110 | forecast_start_date = datetime.strptime( |
182 | 111 | cur_cutoff['start_date'], DEFAULT_SERVER_DATE_FORMAT) | ||
183 | 112 | forecast_end_date = datetime.strptime( | ||
184 | 113 | cur_cutoff['end_date'], DEFAULT_SERVER_DATE_FORMAT) | ||
185 | 114 | if aml['end_date'] > cur_cutoff['end_date']: | ||
186 | 115 | out_days += (end_date - forecast_end_date).days | ||
187 | 116 | if aml['start_date'] < cur_cutoff['start_date']: | ||
188 | 117 | out_days += (forecast_start_date - start_date).days | ||
189 | 118 | prepaid_days = total_days - out_days | ||
190 | 78 | else: | 119 | else: |
195 | 79 | after_cutoff_days = (end_date - cutoff_date).days | 120 | cutoff_date_str = cur_cutoff['cutoff_date'] |
196 | 80 | if total_days: | 121 | cutoff_date = datetime.strptime( |
197 | 81 | cutoff_amount = -1 * (aml['credit'] - aml['debit'])\ | 122 | cutoff_date_str, DEFAULT_SERVER_DATE_FORMAT) |
198 | 82 | * after_cutoff_days / total_days | 123 | if aml['start_date'] > cutoff_date_str: |
199 | 124 | prepaid_days = total_days | ||
200 | 83 | else: | 125 | else: |
204 | 84 | raise orm.except_orm( | 126 | prepaid_days = (end_date - cutoff_date).days |
205 | 85 | _('Error:'), | 127 | if total_days: |
206 | 86 | "Should never happen. Total days should always be > 0") | 128 | cutoff_amount = (aml['debit'] - aml['credit'])\ |
207 | 129 | * prepaid_days / float(total_days) | ||
208 | 130 | else: | ||
209 | 131 | raise orm.except_orm( | ||
210 | 132 | _('Error:'), | ||
211 | 133 | "Should never happen. Total days should always be > 0") | ||
212 | 87 | 134 | ||
213 | 88 | # we use account mapping here | 135 | # we use account mapping here |
214 | 89 | if aml['account_id'][0] in mapping: | 136 | if aml['account_id'][0] in mapping: |
215 | @@ -104,7 +151,7 @@ | |||
216 | 104 | aml['analytic_account_id'] and aml['analytic_account_id'][0] | 151 | aml['analytic_account_id'] and aml['analytic_account_id'][0] |
217 | 105 | or False, | 152 | or False, |
218 | 106 | 'total_days': total_days, | 153 | 'total_days': total_days, |
220 | 107 | 'after_cutoff_days': after_cutoff_days, | 154 | 'prepaid_days': prepaid_days, |
221 | 108 | 'amount': aml['credit'] - aml['debit'], | 155 | 'amount': aml['credit'] - aml['debit'], |
222 | 109 | 'currency_id': cur_cutoff['company_currency_id'][0], | 156 | 'currency_id': cur_cutoff['company_currency_id'][0], |
223 | 110 | 'cutoff_amount': cutoff_amount, | 157 | 'cutoff_amount': cutoff_amount, |
224 | @@ -120,7 +167,8 @@ | |||
225 | 120 | cur_cutoff = self.read( | 167 | cur_cutoff = self.read( |
226 | 121 | cr, uid, ids[0], [ | 168 | cr, uid, ids[0], [ |
227 | 122 | 'line_ids', 'source_journal_ids', 'cutoff_date', 'company_id', | 169 | 'line_ids', 'source_journal_ids', 'cutoff_date', 'company_id', |
229 | 123 | 'type', 'company_currency_id' | 170 | 'type', 'company_currency_id', 'forecast', 'start_date', |
230 | 171 | 'end_date', | ||
231 | 124 | ], | 172 | ], |
232 | 125 | context=context) | 173 | context=context) |
233 | 126 | src_journal_ids = cur_cutoff['source_journal_ids'] | 174 | src_journal_ids = cur_cutoff['source_journal_ids'] |
234 | @@ -132,13 +180,22 @@ | |||
235 | 132 | if cur_cutoff['line_ids']: | 180 | if cur_cutoff['line_ids']: |
236 | 133 | line_obj.unlink(cr, uid, cur_cutoff['line_ids'], context=context) | 181 | line_obj.unlink(cr, uid, cur_cutoff['line_ids'], context=context) |
237 | 134 | 182 | ||
238 | 183 | if cur_cutoff['forecast']: | ||
239 | 184 | domain = [ | ||
240 | 185 | ('start_date', '<=', cur_cutoff['end_date']), | ||
241 | 186 | ('end_date', '>=', cur_cutoff['start_date']), | ||
242 | 187 | ('journal_id', 'in', src_journal_ids) | ||
243 | 188 | ] | ||
244 | 189 | else: | ||
245 | 190 | domain = [ | ||
246 | 191 | ('start_date', '!=', False), | ||
247 | 192 | ('journal_id', 'in', src_journal_ids), | ||
248 | 193 | ('end_date', '>', cutoff_date_str), | ||
249 | 194 | ('date', '<=', cutoff_date_str) | ||
250 | 195 | ] | ||
251 | 196 | |||
252 | 135 | # Search for account move lines in the source journals | 197 | # Search for account move lines in the source journals |
259 | 136 | aml_ids = aml_obj.search(cr, uid, [ | 198 | aml_ids = aml_obj.search(cr, uid, domain, context=context) |
254 | 137 | ('start_date', '!=', False), | ||
255 | 138 | ('journal_id', 'in', src_journal_ids), | ||
256 | 139 | ('end_date', '>', cutoff_date_str), | ||
257 | 140 | ('date', '<=', cutoff_date_str) | ||
258 | 141 | ], context=context) | ||
260 | 142 | # Create mapping dict | 199 | # Create mapping dict |
261 | 143 | mapping = mapping_obj._get_mapping_dict( | 200 | mapping = mapping_obj._get_mapping_dict( |
262 | 144 | cr, uid, cur_cutoff['company_id'][0], cur_cutoff['type'], | 201 | cr, uid, cur_cutoff['company_id'][0], cur_cutoff['type'], |
263 | @@ -188,6 +245,9 @@ | |||
264 | 188 | 'start_date': fields.date('Start Date', readonly=True), | 245 | 'start_date': fields.date('Start Date', readonly=True), |
265 | 189 | 'end_date': fields.date('End Date', readonly=True), | 246 | 'end_date': fields.date('End Date', readonly=True), |
266 | 190 | 'total_days': fields.integer('Total Number of Days', readonly=True), | 247 | 'total_days': fields.integer('Total Number of Days', readonly=True), |
269 | 191 | 'after_cutoff_days': fields.integer( | 248 | 'prepaid_days': fields.integer( |
270 | 192 | 'Number of Days after Cut-off Date', readonly=True), | 249 | 'Prepaid Days', readonly=True, |
271 | 250 | help="In regular mode, this is the number of days after the " | ||
272 | 251 | "cut-off date. In forecast mode, this is the number of days " | ||
273 | 252 | "between the start date and the end date."), | ||
274 | 193 | } | 253 | } |
275 | 194 | 254 | ||
276 | === modified file 'account_cutoff_prepaid/account_cutoff_view.xml' | |||
277 | --- account_cutoff_prepaid/account_cutoff_view.xml 2013-10-15 19:35:48 +0000 | |||
278 | +++ account_cutoff_prepaid/account_cutoff_view.xml 2016-05-13 13:23:12 +0000 | |||
279 | @@ -1,7 +1,7 @@ | |||
280 | 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
281 | 2 | 2 | ||
282 | 3 | <!-- | 3 | <!-- |
284 | 4 | Copyright (C) 2013 Akretion (http://www.akretion.com/) | 4 | Copyright (C) 2013-2014 Akretion (http://www.akretion.com/) |
285 | 5 | @author Alexis de Lattre <alexis.delattre@akretion.com> | 5 | @author Alexis de Lattre <alexis.delattre@akretion.com> |
286 | 6 | The licence is in the file __openerp__.py | 6 | The licence is in the file __openerp__.py |
287 | 7 | --> | 7 | --> |
288 | @@ -9,12 +9,57 @@ | |||
289 | 9 | <openerp> | 9 | <openerp> |
290 | 10 | <data> | 10 | <data> |
291 | 11 | 11 | ||
292 | 12 | <!-- Tree view --> | ||
293 | 13 | <record id="account_cutoff_tree" model="ir.ui.view"> | ||
294 | 14 | <field name="name">account.cutoff.prepaid.tree</field> | ||
295 | 15 | <field name="model">account.cutoff</field> | ||
296 | 16 | <field name="inherit_id" ref="account_cutoff_base.account_cutoff_tree"/> | ||
297 | 17 | <field name="arch" type="xml"> | ||
298 | 18 | <field name="cutoff_date" position="after"> | ||
299 | 19 | <field name="forecast" invisible="'prepaid' not in context.get('type', '-')"/> | ||
300 | 20 | <field name="start_date" invisible="'prepaid' not in context.get('type', '-')"/> | ||
301 | 21 | <field name="end_date" invisible="'prepaid' not in context.get('type', '-')"/> | ||
302 | 22 | </field> | ||
303 | 23 | </field> | ||
304 | 24 | </record> | ||
305 | 25 | |||
306 | 12 | <!-- Form view --> | 26 | <!-- Form view --> |
307 | 13 | <record id="account_cutoff_form" model="ir.ui.view"> | 27 | <record id="account_cutoff_form" model="ir.ui.view"> |
308 | 14 | <field name="name">account.cutoff.prepaid.form</field> | 28 | <field name="name">account.cutoff.prepaid.form</field> |
309 | 15 | <field name="model">account.cutoff</field> | 29 | <field name="model">account.cutoff</field> |
310 | 16 | <field name="inherit_id" ref="account_cutoff_base.account_cutoff_form"/> | 30 | <field name="inherit_id" ref="account_cutoff_base.account_cutoff_form"/> |
311 | 17 | <field name="arch" type="xml"> | 31 | <field name="arch" type="xml"> |
312 | 32 | <field name="cutoff_date" position="before"> | ||
313 | 33 | <field name="forecast" | ||
314 | 34 | invisible="'prepaid' not in context.get('type', '-')" | ||
315 | 35 | on_change="forecast_onchange(forecast, context)"/> | ||
316 | 36 | <field name="start_date" | ||
317 | 37 | attrs="{'invisible': [('forecast', '=', False)], 'required': [('forecast', '=', True)]}"/> | ||
318 | 38 | <field name="end_date" | ||
319 | 39 | attrs="{'invisible': [('forecast', '=', False)], 'required': [('forecast', '=', True)]}"/> | ||
320 | 40 | </field> | ||
321 | 41 | <field name="cutoff_date" position="attributes"> | ||
322 | 42 | <attribute name="attrs">{'invisible': [('forecast', '=', True)], 'required': [('forecast', '=', False)]}</attribute> | ||
323 | 43 | <attribute name="required">0</attribute> | ||
324 | 44 | </field> | ||
325 | 45 | <group name="accounting-params" position="attributes"> | ||
326 | 46 | <attribute name="attrs">{'invisible': [('forecast', '=', True)]}</attribute> | ||
327 | 47 | </group> | ||
328 | 48 | <field name="cutoff_journal_id" position="attributes"> | ||
329 | 49 | <attribute name="required">0</attribute> | ||
330 | 50 | <attribute name="attrs">{'required': [('forecast', '=', False)]}</attribute> | ||
331 | 51 | </field> | ||
332 | 52 | <field name="cutoff_account_id" position="attributes"> | ||
333 | 53 | <attribute name="required">0</attribute> | ||
334 | 54 | <attribute name="attrs">{'required': [('forecast', '=', False)]}</attribute> | ||
335 | 55 | </field> | ||
336 | 56 | <field name="move_label" position="attributes"> | ||
337 | 57 | <attribute name="required">0</attribute> | ||
338 | 58 | <attribute name="attrs">{'required': [('forecast', '=', False)]}</attribute> | ||
339 | 59 | </field> | ||
340 | 60 | <button name="create_move" position="attributes"> | ||
341 | 61 | <attribute name="attrs">{'invisible': ['|', '|', ('line_ids', '=', False), ('state', '=', 'done'), ('forecast', '=', True)]}</attribute> | ||
342 | 62 | </button> | ||
343 | 18 | <button name="back2draft" position="after"> | 63 | <button name="back2draft" position="after"> |
344 | 19 | <button class="oe_highlight" name="get_prepaid_lines" string="Re-Generate Lines" type="object" states="draft" invisible="'prepaid' not in context.get('type', '-')"/> | 64 | <button class="oe_highlight" name="get_prepaid_lines" string="Re-Generate Lines" type="object" states="draft" invisible="'prepaid' not in context.get('type', '-')"/> |
345 | 20 | </button> | 65 | </button> |
346 | @@ -41,7 +86,7 @@ | |||
347 | 41 | </field> | 86 | </field> |
348 | 42 | <field name="cutoff_amount" position="before"> | 87 | <field name="cutoff_amount" position="before"> |
349 | 43 | <field name="total_days" invisible="'prepaid' not in context.get('type', '-')"/> | 88 | <field name="total_days" invisible="'prepaid' not in context.get('type', '-')"/> |
351 | 44 | <field name="after_cutoff_days" invisible="'prepaid' not in context.get('type', '-')"/> | 89 | <field name="prepaid_days" invisible="'prepaid' not in context.get('type', '-')"/> |
352 | 45 | </field> | 90 | </field> |
353 | 46 | </field> | 91 | </field> |
354 | 47 | </record> | 92 | </record> |
355 | @@ -59,7 +104,7 @@ | |||
356 | 59 | <field name="start_date" invisible="'prepaid' not in context.get('type', '-')"/> | 104 | <field name="start_date" invisible="'prepaid' not in context.get('type', '-')"/> |
357 | 60 | <field name="end_date" invisible="'prepaid' not in context.get('type', '-')"/> | 105 | <field name="end_date" invisible="'prepaid' not in context.get('type', '-')"/> |
358 | 61 | <field name="total_days" string="Days Total" invisible="'prepaid' not in context.get('type', '-')"/> | 106 | <field name="total_days" string="Days Total" invisible="'prepaid' not in context.get('type', '-')"/> |
360 | 62 | <field name="after_cutoff_days" string="Days after Cut-off" invisible="'prepaid' not in context.get('type', '-')"/> | 107 | <field name="prepaid_days" string="Days after Cut-off" invisible="'prepaid' not in context.get('type', '-')"/> |
361 | 63 | </field> | 108 | </field> |
362 | 64 | </field> | 109 | </field> |
363 | 65 | </record> | 110 | </record> |
364 | 66 | 111 | ||
365 | === modified file 'account_cutoff_prepaid/account_invoice_view.xml' | |||
366 | --- account_cutoff_prepaid/account_invoice_view.xml 2013-09-09 21:28:50 +0000 | |||
367 | +++ account_cutoff_prepaid/account_invoice_view.xml 2016-05-13 13:23:12 +0000 | |||
368 | @@ -15,7 +15,10 @@ | |||
369 | 15 | <field name="model">account.invoice</field> | 15 | <field name="model">account.invoice</field> |
370 | 16 | <field name="inherit_id" ref="account.invoice_form" /> | 16 | <field name="inherit_id" ref="account.invoice_form" /> |
371 | 17 | <field name="arch" type="xml"> | 17 | <field name="arch" type="xml"> |
373 | 18 | <xpath expr="//field[@name='invoice_line']/tree/field[@name='account_analytic_id']" position="after"> | 18 | <!-- Don't attach on account_analytic_id with position="after" |
374 | 19 | to be compatible with the module sale_analytic_plans which | ||
375 | 20 | removes the field account_analytic_id from the invoice form view --> | ||
376 | 21 | <xpath expr="//field[@name='invoice_line']/tree/field[@name='quantity']" position="before"> | ||
377 | 19 | <field name="start_date" /> | 22 | <field name="start_date" /> |
378 | 20 | <field name="end_date" /> | 23 | <field name="end_date" /> |
379 | 21 | </xpath> | 24 | </xpath> |
380 | @@ -33,7 +36,7 @@ | |||
381 | 33 | <field name="model">account.invoice</field> | 36 | <field name="model">account.invoice</field> |
382 | 34 | <field name="inherit_id" ref="account.invoice_supplier_form" /> | 37 | <field name="inherit_id" ref="account.invoice_supplier_form" /> |
383 | 35 | <field name="arch" type="xml"> | 38 | <field name="arch" type="xml"> |
385 | 36 | <xpath expr="//field[@name='invoice_line']/tree/field[@name='account_analytic_id']" position="after"> | 39 | <xpath expr="//field[@name='invoice_line']/tree/field[@name='quantity']" position="before"> |
386 | 37 | <field name="start_date" /> | 40 | <field name="start_date" /> |
387 | 38 | <field name="end_date" /> | 41 | <field name="end_date" /> |
388 | 39 | </xpath> | 42 | </xpath> |
389 | 40 | 43 | ||
390 | === modified file 'account_cutoff_prepaid/i18n/account_cutoff_prepaid.pot' | |||
391 | --- account_cutoff_prepaid/i18n/account_cutoff_prepaid.pot 2013-12-24 15:31:15 +0000 | |||
392 | +++ account_cutoff_prepaid/i18n/account_cutoff_prepaid.pot 2016-05-13 13:23:12 +0000 | |||
393 | @@ -6,8 +6,8 @@ | |||
394 | 6 | msgstr "" | 6 | msgstr "" |
395 | 7 | "Project-Id-Version: OpenERP Server 7.0\n" | 7 | "Project-Id-Version: OpenERP Server 7.0\n" |
396 | 8 | "Report-Msgid-Bugs-To: \n" | 8 | "Report-Msgid-Bugs-To: \n" |
399 | 9 | "POT-Creation-Date: 2013-12-24 15:26+0000\n" | 9 | "POT-Creation-Date: 2014-03-09 00:05+0000\n" |
400 | 10 | "PO-Revision-Date: 2013-12-24 15:26+0000\n" | 10 | "PO-Revision-Date: 2014-03-09 00:05+0000\n" |
401 | 11 | "Last-Translator: <>\n" | 11 | "Last-Translator: <>\n" |
402 | 12 | "Language-Team: \n" | 12 | "Language-Team: \n" |
403 | 13 | "MIME-Version: 1.0\n" | 13 | "MIME-Version: 1.0\n" |
404 | @@ -21,6 +21,7 @@ | |||
405 | 21 | msgstr "" | 21 | msgstr "" |
406 | 22 | 22 | ||
407 | 23 | #. module: account_cutoff_prepaid | 23 | #. module: account_cutoff_prepaid |
408 | 24 | #: field:account.cutoff,end_date:0 | ||
409 | 24 | #: field:account.cutoff.line,end_date:0 | 25 | #: field:account.cutoff.line,end_date:0 |
410 | 25 | #: field:account.invoice.line,end_date:0 | 26 | #: field:account.invoice.line,end_date:0 |
411 | 26 | #: field:account.move.line,end_date:0 | 27 | #: field:account.move.line,end_date:0 |
412 | @@ -38,6 +39,16 @@ | |||
413 | 38 | msgstr "" | 39 | msgstr "" |
414 | 39 | 40 | ||
415 | 40 | #. module: account_cutoff_prepaid | 41 | #. module: account_cutoff_prepaid |
416 | 42 | #: field:account.cutoff,forecast:0 | ||
417 | 43 | msgid "Forecast" | ||
418 | 44 | msgstr "" | ||
419 | 45 | |||
420 | 46 | #. module: account_cutoff_prepaid | ||
421 | 47 | #: view:account.cutoff:0 | ||
422 | 48 | msgid "{'invisible': [('forecast', '=', True)], 'required': [('forecast', '=', False)]}" | ||
423 | 49 | msgstr "" | ||
424 | 50 | |||
425 | 51 | #. module: account_cutoff_prepaid | ||
426 | 41 | #: field:res.company,default_prepaid_expense_account_id:0 | 52 | #: field:res.company,default_prepaid_expense_account_id:0 |
427 | 42 | msgid "Default Account for Prepaid Expense" | 53 | msgid "Default Account for Prepaid Expense" |
428 | 43 | msgstr "" | 54 | msgstr "" |
429 | @@ -65,6 +76,11 @@ | |||
430 | 65 | msgstr "" | 76 | msgstr "" |
431 | 66 | 77 | ||
432 | 67 | #. module: account_cutoff_prepaid | 78 | #. module: account_cutoff_prepaid |
433 | 79 | #: view:account.cutoff:0 | ||
434 | 80 | msgid "{'invisible': [('forecast', '=', True)]}" | ||
435 | 81 | msgstr "" | ||
436 | 82 | |||
437 | 83 | #. module: account_cutoff_prepaid | ||
438 | 68 | #: field:account.cutoff.line,total_days:0 | 84 | #: field:account.cutoff.line,total_days:0 |
439 | 69 | msgid "Total Number of Days" | 85 | msgid "Total Number of Days" |
440 | 70 | msgstr "" | 86 | msgstr "" |
441 | @@ -104,6 +120,11 @@ | |||
442 | 104 | msgstr "" | 120 | msgstr "" |
443 | 105 | 121 | ||
444 | 106 | #. module: account_cutoff_prepaid | 122 | #. module: account_cutoff_prepaid |
445 | 123 | #: help:account.cutoff,forecast:0 | ||
446 | 124 | msgid "The Forecast mode allows the user to compute the prepaid revenue/expense between 2 dates in the future." | ||
447 | 125 | msgstr "" | ||
448 | 126 | |||
449 | 127 | #. module: account_cutoff_prepaid | ||
450 | 107 | #: model:ir.model,name:account_cutoff_prepaid.model_account_cutoff | 128 | #: model:ir.model,name:account_cutoff_prepaid.model_account_cutoff |
451 | 108 | msgid "Account Cut-off" | 129 | msgid "Account Cut-off" |
452 | 109 | msgstr "" | 130 | msgstr "" |
453 | @@ -119,16 +140,6 @@ | |||
454 | 119 | msgstr "" | 140 | msgstr "" |
455 | 120 | 141 | ||
456 | 121 | #. module: account_cutoff_prepaid | 142 | #. module: account_cutoff_prepaid |
457 | 122 | #: sql_constraint:account.cutoff:0 | ||
458 | 123 | msgid "A cut-off of the same type already exists with this cut-off date !" | ||
459 | 124 | msgstr "" | ||
460 | 125 | |||
461 | 126 | #. module: account_cutoff_prepaid | ||
462 | 127 | #: field:account.cutoff.line,after_cutoff_days:0 | ||
463 | 128 | msgid "Number of Days after Cut-off Date" | ||
464 | 129 | msgstr "" | ||
465 | 130 | |||
466 | 131 | #. module: account_cutoff_prepaid | ||
467 | 132 | #: model:product.template,name:account_cutoff_prepaid.product_insurance_contrat_product_template | 143 | #: model:product.template,name:account_cutoff_prepaid.product_insurance_contrat_product_template |
468 | 133 | msgid "Car Insurance" | 144 | msgid "Car Insurance" |
469 | 134 | msgstr "" | 145 | msgstr "" |
470 | @@ -141,8 +152,8 @@ | |||
471 | 141 | #: code:addons/account_cutoff_prepaid/account.py:94 | 152 | #: code:addons/account_cutoff_prepaid/account.py:94 |
472 | 142 | #: code:addons/account_cutoff_prepaid/account.py:100 | 153 | #: code:addons/account_cutoff_prepaid/account.py:100 |
473 | 143 | #: code:addons/account_cutoff_prepaid/account.py:144 | 154 | #: code:addons/account_cutoff_prepaid/account.py:144 |
476 | 144 | #: code:addons/account_cutoff_prepaid/account_cutoff.py:85 | 155 | #: code:addons/account_cutoff_prepaid/account_cutoff.py:132 |
477 | 145 | #: code:addons/account_cutoff_prepaid/account_cutoff.py:129 | 156 | #: code:addons/account_cutoff_prepaid/account_cutoff.py:177 |
478 | 146 | #, python-format | 157 | #, python-format |
479 | 147 | msgid "Error:" | 158 | msgid "Error:" |
480 | 148 | msgstr "" | 159 | msgstr "" |
481 | @@ -170,7 +181,7 @@ | |||
482 | 170 | msgstr "" | 181 | msgstr "" |
483 | 171 | 182 | ||
484 | 172 | #. module: account_cutoff_prepaid | 183 | #. module: account_cutoff_prepaid |
486 | 173 | #: code:addons/account_cutoff_prepaid/account_cutoff.py:129 | 184 | #: code:addons/account_cutoff_prepaid/account_cutoff.py:177 |
487 | 174 | #, python-format | 185 | #, python-format |
488 | 175 | msgid "You should set at least one Source Journal." | 186 | msgid "You should set at least one Source Journal." |
489 | 176 | msgstr "" | 187 | msgstr "" |
490 | @@ -182,17 +193,32 @@ | |||
491 | 182 | msgstr "" | 193 | msgstr "" |
492 | 183 | 194 | ||
493 | 184 | #. module: account_cutoff_prepaid | 195 | #. module: account_cutoff_prepaid |
494 | 196 | #: constraint:account.cutoff:0 | ||
495 | 197 | msgid "The start date is after the end date!" | ||
496 | 198 | msgstr "" | ||
497 | 199 | |||
498 | 200 | #. module: account_cutoff_prepaid | ||
499 | 185 | #: code:addons/account_cutoff_prepaid/account.py:90 | 201 | #: code:addons/account_cutoff_prepaid/account.py:90 |
500 | 186 | #, python-format | 202 | #, python-format |
501 | 187 | msgid "Missing End Date for move line with Name '%s'." | 203 | msgid "Missing End Date for move line with Name '%s'." |
502 | 188 | msgstr "" | 204 | msgstr "" |
503 | 189 | 205 | ||
504 | 190 | #. module: account_cutoff_prepaid | 206 | #. module: account_cutoff_prepaid |
505 | 207 | #: help:account.cutoff.line,prepaid_days:0 | ||
506 | 208 | msgid "In regular mode, this is the number of days after the cut-off date. In forecast mode, this is the number of days between the start date and the end date." | ||
507 | 209 | msgstr "" | ||
508 | 210 | |||
509 | 211 | #. module: account_cutoff_prepaid | ||
510 | 191 | #: model:ir.model,name:account_cutoff_prepaid.model_product_template | 212 | #: model:ir.model,name:account_cutoff_prepaid.model_product_template |
511 | 192 | msgid "Product Template" | 213 | msgid "Product Template" |
512 | 193 | msgstr "" | 214 | msgstr "" |
513 | 194 | 215 | ||
514 | 195 | #. module: account_cutoff_prepaid | 216 | #. module: account_cutoff_prepaid |
515 | 217 | #: view:account.cutoff:0 | ||
516 | 218 | msgid "{'required': [('forecast', '=', False)]}" | ||
517 | 219 | msgstr "" | ||
518 | 220 | |||
519 | 221 | #. module: account_cutoff_prepaid | ||
520 | 196 | #: model:ir.model,name:account_cutoff_prepaid.model_account_invoice_line | 222 | #: model:ir.model,name:account_cutoff_prepaid.model_account_invoice_line |
521 | 197 | msgid "Invoice Line" | 223 | msgid "Invoice Line" |
522 | 198 | msgstr "" | 224 | msgstr "" |
523 | @@ -224,6 +250,12 @@ | |||
524 | 224 | msgstr "" | 250 | msgstr "" |
525 | 225 | 251 | ||
526 | 226 | #. module: account_cutoff_prepaid | 252 | #. module: account_cutoff_prepaid |
527 | 253 | #: sql_constraint:account.cutoff:0 | ||
528 | 254 | msgid "A cut-off of the same type already exists with the same date(s) !" | ||
529 | 255 | msgstr "" | ||
530 | 256 | |||
531 | 257 | #. module: account_cutoff_prepaid | ||
532 | 258 | #: field:account.cutoff,start_date:0 | ||
533 | 227 | #: field:account.cutoff.line,start_date:0 | 259 | #: field:account.cutoff.line,start_date:0 |
534 | 228 | #: field:account.invoice.line,start_date:0 | 260 | #: field:account.invoice.line,start_date:0 |
535 | 229 | #: field:account.move.line,start_date:0 | 261 | #: field:account.move.line,start_date:0 |
536 | @@ -236,6 +268,11 @@ | |||
537 | 236 | msgstr "" | 268 | msgstr "" |
538 | 237 | 269 | ||
539 | 238 | #. module: account_cutoff_prepaid | 270 | #. module: account_cutoff_prepaid |
540 | 271 | #: field:account.cutoff.line,prepaid_days:0 | ||
541 | 272 | msgid "Prepaid Days" | ||
542 | 273 | msgstr "" | ||
543 | 274 | |||
544 | 275 | #. module: account_cutoff_prepaid | ||
545 | 239 | #: view:product.template:0 | 276 | #: view:product.template:0 |
546 | 240 | msgid "Sales Properties" | 277 | msgid "Sales Properties" |
547 | 241 | msgstr "" | 278 | msgstr "" |
548 | 242 | 279 | ||
549 | === added directory 'account_cutoff_prepaid/migrations' | |||
550 | === added directory 'account_cutoff_prepaid/migrations/7.0.0.2' | |||
551 | === added file 'account_cutoff_prepaid/migrations/7.0.0.2/pre-migration.py' | |||
552 | --- account_cutoff_prepaid/migrations/7.0.0.2/pre-migration.py 1970-01-01 00:00:00 +0000 | |||
553 | +++ account_cutoff_prepaid/migrations/7.0.0.2/pre-migration.py 2016-05-13 13:23:12 +0000 | |||
554 | @@ -0,0 +1,29 @@ | |||
555 | 1 | # -*- coding: utf-8 -*- | ||
556 | 2 | ############################################################################## | ||
557 | 3 | # | ||
558 | 4 | # Copyright (C) 2014 Akretion (http://www.akretion.com/) | ||
559 | 5 | # @author: Alexis de Lattre <alexis.delattre@akretion.com> | ||
560 | 6 | # | ||
561 | 7 | # This program is free software: you can redistribute it and/or modify | ||
562 | 8 | # it under the terms of the GNU Affero General Public License as | ||
563 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
564 | 10 | # License, or (at your option) any later version. | ||
565 | 11 | # | ||
566 | 12 | # This program is distributed in the hope that it will be useful, | ||
567 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
568 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
569 | 15 | # GNU Affero General Public License for more details. | ||
570 | 16 | # | ||
571 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
572 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
573 | 19 | # | ||
574 | 20 | ############################################################################## | ||
575 | 21 | |||
576 | 22 | |||
577 | 23 | def migrate(cr, version): | ||
578 | 24 | if not version: | ||
579 | 25 | return | ||
580 | 26 | |||
581 | 27 | cr.execute( | ||
582 | 28 | 'ALTER TABLE "account_cutoff_line" RENAME "after_cutoff_days" ' | ||
583 | 29 | 'TO "prepaid_days"') |
LDTM