Merge lp:~pexego/openerp-spain/l10n_es_account_asset_improvements6.1 into lp:~openerp-spain-team/openerp-spain/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
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza code review Approve
Review via email: mp+142163@code.launchpad.net
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
=== modified file 'l10n_es_account_asset/account_asset.py'
--- l10n_es_account_asset/account_asset.py 2012-11-15 16:20:24 +0000
+++ l10n_es_account_asset/account_asset.py 2013-01-07 17:16:24 +0000
@@ -122,16 +122,28 @@
122 return amount122 return amount
123123
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):
125 undone_dotation_number = asset.method_number125 depreciation_lin_obj = self.pool.get('account.asset.depreciation.line')
126 posted_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_check', '=', True)])
126 if asset.method_time == 'end':127 if asset.method_time == 'end':
127 end_date = datetime.strptime(asset.method_end, '%Y-%m-%d')128 end_date = datetime.strptime(asset.method_end, '%Y-%m-%d')
128 undone_dotation_number = 0129 else:
129 while depreciation_date <= end_date:130 end_date = datetime.strptime(asset.deprec_start_date, '%Y-%m-%d')
130 depreciation_date = (datetime(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+asset.method_period))131 if asset.method_period == 12:
132 end_date = end_date + relativedelta(years=+asset.method_number)
133 else:
134 end_date = end_date + relativedelta(months=+asset.method_number)
135 last_depreciation_date = asset._get_last_depreciation_date()
136 if last_depreciation_date:
137 last_depreciation_date = datetime.strptime(last_depreciation_date[asset.id], '%Y-%m-%d')
138 undone_dotation_number = 0
139 while depreciation_date <= end_date or (depreciation_date.year == end_date.year and asset.prorata and asset.method_period == 12):
140 depreciation_date = (datetime(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+asset.method_period))
141 if last_depreciation_date:
142 if depreciation_date > last_depreciation_date:
143 undone_dotation_number += 1
144 else:
131 undone_dotation_number += 1145 undone_dotation_number += 1
132 if asset.prorata:146 return undone_dotation_number + len(posted_depreciation_line_ids)
133 undone_dotation_number += 1
134 return undone_dotation_number
135 147
136 def compute_depreciation_board(self, cr, uid, ids, context=None):148 def compute_depreciation_board(self, cr, uid, ids, context=None):
137 depreciation_lin_obj = self.pool.get('account.asset.depreciation.line')149 depreciation_lin_obj = self.pool.get('account.asset.depreciation.line')
@@ -143,15 +155,16 @@
143 if old_depreciation_line_ids:155 if old_depreciation_line_ids:
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)
145 157
146 amount_to_depr = residual_amount = asset.value_residual158 amount_to_depr = asset.purchase_value - asset.salvage_value
147159
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')
149 day = depreciation_date.day161 day = depreciation_date.day
150 month = depreciation_date.month162 month = depreciation_date.month
151 year = depreciation_date.year163 year = depreciation_date.year
152 total_days = (year % 4) and 365 or 366164 total_days = ((year % 4 == 0 and year % 100 != 0) or year % 400 == 0) and 366 or 365
153165
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)
167 residual_amount = asset.value_residual
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):
156 i = x + 1169 i = x + 1
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)
@@ -170,7 +183,7 @@
170 'sequence': i,183 'sequence': i,
171 'name': str(asset.id) +'/' + str(i),184 'name': str(asset.id) +'/' + str(i),
172 'remaining_value': residual_amount,185 'remaining_value': residual_amount,
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),
174 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'),187 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'),
175 }188 }
176 depreciation_lin_obj.create(cr, uid, vals, context=context)189 depreciation_lin_obj.create(cr, uid, vals, context=context)
@@ -191,7 +204,7 @@
191204
192 def _amount_residual(self, cr, uid, ids, name, args, context=None):205 def _amount_residual(self, cr, uid, ids, name, args, context=None):
193 cr.execute("""SELECT206 cr.execute("""SELECT
194 l.asset_id as id, round(SUM(abs(l.debit-l.credit))) AS amount207 l.asset_id as id, SUM(abs(l.debit-l.credit)) AS amount
195 FROM208 FROM
196 account_move_line l209 account_move_line l
197 WHERE210 WHERE
@@ -238,6 +251,7 @@
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'),
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),
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)]}),
254 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
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)]}),
242 }256 }
243 _defaults = {257 _defaults = {
@@ -281,6 +295,7 @@
281 'method_progress_factor': category_obj.method_progress_factor,295 'method_progress_factor': category_obj.method_progress_factor,
282 'method_end': category_obj.method_end,296 'method_end': category_obj.method_end,
283 'prorata': category_obj.prorata,297 'prorata': category_obj.prorata,
298 'account_analytic_id': category_obj.account_analytic_id and category_obj.account_analytic_id.id or False
284 }299 }
285 return res300 return res
286301
@@ -295,7 +310,7 @@
295 default = {}310 default = {}
296 if context is None:311 if context is None:
297 context = {}312 context = {}
298 default.update({'depreciation_line_ids': [], 'state': 'draft'})313 default.update({'depreciation_line_ids': [], 'state': 'draft', 'account_move_line_ids': []})
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)
300315
301 def _compute_entries(self, cr, uid, ids, period_id, context={}):316 def _compute_entries(self, cr, uid, ids, period_id, context={}):
@@ -406,7 +421,7 @@
406 'partner_id': partner_id,421 'partner_id': partner_id,
407 'currency_id': company_currency <> current_currency and current_currency or False,422 'currency_id': company_currency <> current_currency and current_currency or False,
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,
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,
410 'date': depreciation_date,425 'date': depreciation_date,
411 'asset_id': line.asset_id.id426 'asset_id': line.asset_id.id
412 })427 })
413428
=== modified file 'l10n_es_account_asset/account_asset_view.xml'
--- l10n_es_account_asset/account_asset_view.xml 2012-11-15 16:20:24 +0000
+++ l10n_es_account_asset/account_asset_view.xml 2013-01-07 17:16:24 +0000
@@ -32,11 +32,11 @@
32 <field name="prorata"/>32 <field name="prorata"/>
33 <field name="open_asset"/>33 <field name="open_asset"/>
34 </group>34 </group>
35 <group col="2" colspan="2" groups="analytic.group_analytic_accounting">35 <group col="2" colspan="2" groups="analytic.group_analytic_accounting">
36 <separator string="Analytic information" colspan="4"/>36 <separator string="Analytic information" colspan="4"/>
37 <newline/>37 <newline/>
38 <field name="account_analytic_id"/>38 <field name="account_analytic_id"/>
39 </group>39 </group>
40 <separator string="Notes" colspan="4"/>40 <separator string="Notes" colspan="4"/>
41 <field name="note" colspan="4" nolabel="1"/>41 <field name="note" colspan="4" nolabel="1"/>
42 </form>42 </form>
@@ -97,7 +97,7 @@
97 <field name="parent_id"/>97 <field name="parent_id"/>
98 <field name="partner_id"/>98 <field name="partner_id"/>
99 <field name="purchase_date"/>99 <field name="purchase_date"/>
100 <field name="deprec_start_date"/>100 <field name="deprec_start_date"/>
101 <newline/>101 <newline/>
102 <group colspan="2" col="2">102 <group colspan="2" col="2">
103 <separator string="Depreciation Dates" colspan="2"/>103 <separator string="Depreciation Dates" colspan="2"/>
@@ -113,7 +113,12 @@
113 <field name="method"/>113 <field name="method"/>
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')]}"/>
115 <field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>115 <field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>
116 <field name="compute_at_end_period"/> 116 <field name="compute_at_end_period"/>
117 </group>
118 <group col="2" colspan="2" groups="analytic.group_analytic_accounting">
119 <separator string="Analytic information" colspan="4"/>
120 <newline/>
121 <field name="account_analytic_id"/>
117 </group>122 </group>
118 <newline/>123 <newline/>
119 <separator string="" colspan="4"/>124 <separator string="" colspan="4"/>