Merge lp:~pexego/openerp-spain/l10n_es_account_asset_improvements6.1 into lp:~openerp-spain-team/openerp-spain/6.1
- l10n_es_account_asset_improvements6.1
- Merge into 6.1
Proposed by
Omar (Pexego)
Status: | Merged |
---|---|
Merged at revision: | 391 |
Proposed branch: | lp:~pexego/openerp-spain/l10n_es_account_asset_improvements6.1 |
Merge into: | lp:~openerp-spain-team/openerp-spain/6.1 |
Diff against target: |
154 lines (+40/-20) 2 files modified
l10n_es_account_asset/account_asset.py (+28/-13) l10n_es_account_asset/account_asset_view.xml (+12/-7) |
To merge this branch: | bzr merge lp:~pexego/openerp-spain/l10n_es_account_asset_improvements6.1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Pedro Manuel Baeza | code review | Approve | |
Review via email: mp+142163@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Omar (Pexego) (omar7r) wrote : | # |
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
No he llegado a probar los cambios, ya que no tengo ninguna instalación 6.1 con activos, pero puesto que el MP es igual al de la 6.0, proviene de alguien probado, y en la revisión de código no detecto nada raro, paso a hacer el merge para limpiar tareas pendientes.
Un saludo.
review:
Approve
(code review)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'l10n_es_account_asset/account_asset.py' | |||
2 | --- l10n_es_account_asset/account_asset.py 2012-11-15 16:20:24 +0000 | |||
3 | +++ l10n_es_account_asset/account_asset.py 2013-01-07 17:16:24 +0000 | |||
4 | @@ -122,16 +122,28 @@ | |||
5 | 122 | return amount | 122 | return amount |
6 | 123 | 123 | ||
7 | 124 | def _compute_board_undone_dotation_nb(self, cr, uid, asset, depreciation_date, total_days, context=None): | 124 | def _compute_board_undone_dotation_nb(self, cr, uid, asset, depreciation_date, total_days, context=None): |
9 | 125 | undone_dotation_number = asset.method_number | 125 | depreciation_lin_obj = self.pool.get('account.asset.depreciation.line') |
10 | 126 | posted_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_check', '=', True)]) | ||
11 | 126 | if asset.method_time == 'end': | 127 | if asset.method_time == 'end': |
12 | 127 | end_date = datetime.strptime(asset.method_end, '%Y-%m-%d') | 128 | end_date = datetime.strptime(asset.method_end, '%Y-%m-%d') |
16 | 128 | undone_dotation_number = 0 | 129 | else: |
17 | 129 | while depreciation_date <= end_date: | 130 | end_date = datetime.strptime(asset.deprec_start_date, '%Y-%m-%d') |
18 | 130 | depreciation_date = (datetime(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+asset.method_period)) | 131 | if asset.method_period == 12: |
19 | 132 | end_date = end_date + relativedelta(years=+asset.method_number) | ||
20 | 133 | else: | ||
21 | 134 | end_date = end_date + relativedelta(months=+asset.method_number) | ||
22 | 135 | last_depreciation_date = asset._get_last_depreciation_date() | ||
23 | 136 | if last_depreciation_date: | ||
24 | 137 | last_depreciation_date = datetime.strptime(last_depreciation_date[asset.id], '%Y-%m-%d') | ||
25 | 138 | undone_dotation_number = 0 | ||
26 | 139 | while depreciation_date <= end_date or (depreciation_date.year == end_date.year and asset.prorata and asset.method_period == 12): | ||
27 | 140 | depreciation_date = (datetime(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+asset.method_period)) | ||
28 | 141 | if last_depreciation_date: | ||
29 | 142 | if depreciation_date > last_depreciation_date: | ||
30 | 143 | undone_dotation_number += 1 | ||
31 | 144 | else: | ||
32 | 131 | undone_dotation_number += 1 | 145 | undone_dotation_number += 1 |
36 | 132 | if asset.prorata: | 146 | return undone_dotation_number + len(posted_depreciation_line_ids) |
34 | 133 | undone_dotation_number += 1 | ||
35 | 134 | return undone_dotation_number | ||
37 | 135 | 147 | ||
38 | 136 | def compute_depreciation_board(self, cr, uid, ids, context=None): | 148 | def compute_depreciation_board(self, cr, uid, ids, context=None): |
39 | 137 | depreciation_lin_obj = self.pool.get('account.asset.depreciation.line') | 149 | depreciation_lin_obj = self.pool.get('account.asset.depreciation.line') |
40 | @@ -143,15 +155,16 @@ | |||
41 | 143 | if old_depreciation_line_ids: | 155 | if old_depreciation_line_ids: |
42 | 144 | depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context) | 156 | depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context) |
43 | 145 | 157 | ||
45 | 146 | amount_to_depr = residual_amount = asset.value_residual | 158 | amount_to_depr = asset.purchase_value - asset.salvage_value |
46 | 147 | 159 | ||
47 | 148 | depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d') | 160 | depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d') |
48 | 149 | day = depreciation_date.day | 161 | day = depreciation_date.day |
49 | 150 | month = depreciation_date.month | 162 | month = depreciation_date.month |
50 | 151 | year = depreciation_date.year | 163 | year = depreciation_date.year |
52 | 152 | total_days = (year % 4) and 365 or 366 | 164 | total_days = ((year % 4 == 0 and year % 100 != 0) or year % 400 == 0) and 366 or 365 |
53 | 153 | 165 | ||
54 | 154 | undone_dotation_number = self._compute_board_undone_dotation_nb(cr, uid, asset, depreciation_date, total_days, context=context) | 166 | undone_dotation_number = self._compute_board_undone_dotation_nb(cr, uid, asset, depreciation_date, total_days, context=context) |
55 | 167 | residual_amount = asset.value_residual | ||
56 | 155 | for x in range(len(posted_depreciation_line_ids), undone_dotation_number): | 168 | for x in range(len(posted_depreciation_line_ids), undone_dotation_number): |
57 | 156 | i = x + 1 | 169 | i = x + 1 |
58 | 157 | amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context) | 170 | amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context) |
59 | @@ -170,7 +183,7 @@ | |||
60 | 170 | 'sequence': i, | 183 | 'sequence': i, |
61 | 171 | 'name': str(asset.id) +'/' + str(i), | 184 | 'name': str(asset.id) +'/' + str(i), |
62 | 172 | 'remaining_value': residual_amount, | 185 | 'remaining_value': residual_amount, |
64 | 173 | 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount), | 186 | 'depreciated_value': round((asset.purchase_value - asset.salvage_value) - (residual_amount + amount),2), |
65 | 174 | 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'), | 187 | 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'), |
66 | 175 | } | 188 | } |
67 | 176 | depreciation_lin_obj.create(cr, uid, vals, context=context) | 189 | depreciation_lin_obj.create(cr, uid, vals, context=context) |
68 | @@ -191,7 +204,7 @@ | |||
69 | 191 | 204 | ||
70 | 192 | def _amount_residual(self, cr, uid, ids, name, args, context=None): | 205 | def _amount_residual(self, cr, uid, ids, name, args, context=None): |
71 | 193 | cr.execute("""SELECT | 206 | cr.execute("""SELECT |
73 | 194 | l.asset_id as id, round(SUM(abs(l.debit-l.credit))) AS amount | 207 | l.asset_id as id, SUM(abs(l.debit-l.credit)) AS amount |
74 | 195 | FROM | 208 | FROM |
75 | 196 | account_move_line l | 209 | account_move_line l |
76 | 197 | WHERE | 210 | WHERE |
77 | @@ -238,6 +251,7 @@ | |||
78 | 238 | 'prorata':fields.boolean('Prorata Temporis', readonly=True, states={'draft':[('readonly',False)]}, help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first January'), | 251 | 'prorata':fields.boolean('Prorata Temporis', readonly=True, states={'draft':[('readonly',False)]}, help='Indicates that the first depreciation entry for this asset have to be done from the purchase date instead of the first January'), |
79 | 239 | 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True), | 252 | 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True), |
80 | 240 | 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}), | 253 | 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}), |
81 | 254 | 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'), | ||
82 | 241 | 'salvage_value': fields.float('Salvage Value', digits_compute=dp.get_precision('Account'), help="It is the amount you plan to have that you cannot depreciate.", readonly=True, states={'draft':[('readonly',False)]}), | 255 | 'salvage_value': fields.float('Salvage Value', digits_compute=dp.get_precision('Account'), help="It is the amount you plan to have that you cannot depreciate.", readonly=True, states={'draft':[('readonly',False)]}), |
83 | 242 | } | 256 | } |
84 | 243 | _defaults = { | 257 | _defaults = { |
85 | @@ -281,6 +295,7 @@ | |||
86 | 281 | 'method_progress_factor': category_obj.method_progress_factor, | 295 | 'method_progress_factor': category_obj.method_progress_factor, |
87 | 282 | 'method_end': category_obj.method_end, | 296 | 'method_end': category_obj.method_end, |
88 | 283 | 'prorata': category_obj.prorata, | 297 | 'prorata': category_obj.prorata, |
89 | 298 | 'account_analytic_id': category_obj.account_analytic_id and category_obj.account_analytic_id.id or False | ||
90 | 284 | } | 299 | } |
91 | 285 | return res | 300 | return res |
92 | 286 | 301 | ||
93 | @@ -295,7 +310,7 @@ | |||
94 | 295 | default = {} | 310 | default = {} |
95 | 296 | if context is None: | 311 | if context is None: |
96 | 297 | context = {} | 312 | context = {} |
98 | 298 | default.update({'depreciation_line_ids': [], 'state': 'draft'}) | 313 | default.update({'depreciation_line_ids': [], 'state': 'draft', 'account_move_line_ids': []}) |
99 | 299 | return super(account_asset_asset, self).copy(cr, uid, id, default, context=context) | 314 | return super(account_asset_asset, self).copy(cr, uid, id, default, context=context) |
100 | 300 | 315 | ||
101 | 301 | def _compute_entries(self, cr, uid, ids, period_id, context={}): | 316 | def _compute_entries(self, cr, uid, ids, period_id, context={}): |
102 | @@ -406,7 +421,7 @@ | |||
103 | 406 | 'partner_id': partner_id, | 421 | 'partner_id': partner_id, |
104 | 407 | 'currency_id': company_currency <> current_currency and current_currency or False, | 422 | 'currency_id': company_currency <> current_currency and current_currency or False, |
105 | 408 | 'amount_currency': company_currency <> current_currency and sign * line.amount or 0.0, | 423 | 'amount_currency': company_currency <> current_currency and sign * line.amount or 0.0, |
107 | 409 | 'analytic_account_id': line.asset_id.category_id.account_analytic_id.id, | 424 | 'analytic_account_id': line.asset_id.account_analytic_id and line.asset_id.account_analytic_id.id or False, |
108 | 410 | 'date': depreciation_date, | 425 | 'date': depreciation_date, |
109 | 411 | 'asset_id': line.asset_id.id | 426 | 'asset_id': line.asset_id.id |
110 | 412 | }) | 427 | }) |
111 | 413 | 428 | ||
112 | === modified file 'l10n_es_account_asset/account_asset_view.xml' | |||
113 | --- l10n_es_account_asset/account_asset_view.xml 2012-11-15 16:20:24 +0000 | |||
114 | +++ l10n_es_account_asset/account_asset_view.xml 2013-01-07 17:16:24 +0000 | |||
115 | @@ -32,11 +32,11 @@ | |||
116 | 32 | <field name="prorata"/> | 32 | <field name="prorata"/> |
117 | 33 | <field name="open_asset"/> | 33 | <field name="open_asset"/> |
118 | 34 | </group> | 34 | </group> |
124 | 35 | <group col="2" colspan="2" groups="analytic.group_analytic_accounting"> | 35 | <group col="2" colspan="2" groups="analytic.group_analytic_accounting"> |
125 | 36 | <separator string="Analytic information" colspan="4"/> | 36 | <separator string="Analytic information" colspan="4"/> |
126 | 37 | <newline/> | 37 | <newline/> |
127 | 38 | <field name="account_analytic_id"/> | 38 | <field name="account_analytic_id"/> |
128 | 39 | </group> | 39 | </group> |
129 | 40 | <separator string="Notes" colspan="4"/> | 40 | <separator string="Notes" colspan="4"/> |
130 | 41 | <field name="note" colspan="4" nolabel="1"/> | 41 | <field name="note" colspan="4" nolabel="1"/> |
131 | 42 | </form> | 42 | </form> |
132 | @@ -97,7 +97,7 @@ | |||
133 | 97 | <field name="parent_id"/> | 97 | <field name="parent_id"/> |
134 | 98 | <field name="partner_id"/> | 98 | <field name="partner_id"/> |
135 | 99 | <field name="purchase_date"/> | 99 | <field name="purchase_date"/> |
137 | 100 | <field name="deprec_start_date"/> | 100 | <field name="deprec_start_date"/> |
138 | 101 | <newline/> | 101 | <newline/> |
139 | 102 | <group colspan="2" col="2"> | 102 | <group colspan="2" col="2"> |
140 | 103 | <separator string="Depreciation Dates" colspan="2"/> | 103 | <separator string="Depreciation Dates" colspan="2"/> |
141 | @@ -113,7 +113,12 @@ | |||
142 | 113 | <field name="method"/> | 113 | <field name="method"/> |
143 | 114 | <field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/> | 114 | <field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/> |
144 | 115 | <field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/> | 115 | <field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/> |
146 | 116 | <field name="compute_at_end_period"/> | 116 | <field name="compute_at_end_period"/> |
147 | 117 | </group> | ||
148 | 118 | <group col="2" colspan="2" groups="analytic.group_analytic_accounting"> | ||
149 | 119 | <separator string="Analytic information" colspan="4"/> | ||
150 | 120 | <newline/> | ||
151 | 121 | <field name="account_analytic_id"/> | ||
152 | 117 | </group> | 122 | </group> |
153 | 118 | <newline/> | 123 | <newline/> |
154 | 119 | <separator string="" colspan="4"/> | 124 | <separator string="" colspan="4"/> |
Exactamente lo mismo que para la versión 6.0: https:/ /code.launchpad .net/~pexego/ openerp- spain/l10n_ es_account_ asset_improveme nts6.0/ +merge/ 141731