Skip to content

Commit

Permalink
Merge pull request #31 from rlizana/v8_l10n_es_account_asset
Browse files Browse the repository at this point in the history
[MIG] l10n_es_account_asset: Movido de __unported__ y PEP8
  • Loading branch information
pedrobaeza committed Jul 22, 2014
2 parents 78c42a9 + fdcc4e8 commit 839a7af
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011-2012 Wariasc.
#
Expand All @@ -15,10 +15,9 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import account_asset
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@
##############################################################################

{
"name" : "Gestión de activos fijos para España",
"version" : "1.0",
"depends" : ["account_asset"],
"author" : "Serv. Tecnol. Avanzados - Pedro M. Baeza",
"name": "Gestión de activos fijos para España",
"version": "1.0",
"depends": ["account_asset"],
"author": "Serv. Tecnol. Avanzados - Pedro M. Baeza",
"description": """
Gestión de activos fijos española
=================================
Cambia la gestión estándar de activos fijos de OpenERP para acomodarla a las
Cambia la gestión estándar de activos fijos de OpenERP para acomodarla a las
regulaciones españolas:
* Cambia el método de cálculo para el prorrateo temporal.
* Añade un nuevo método de cálculo para porcentaje fijo por periodo.
* Añade la opción de trasladar la depreciación al final del periodo.
""",
"website" : "http://www.serviciosbaeza.com",
"category" : "Accounting & Finance",
"data" : [
"website": "http://www.serviciosbaeza.com",
"category": "Accounting & Finance",
"data": [
"account_asset_view.xml",
],
"active": False,
"installable": True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from openerp.osv import orm, fields
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DSDF


class account_asset_category(orm.Model):
_inherit = 'account.asset.category'

Expand All @@ -41,7 +42,7 @@ class account_asset_category(orm.Model):
" * Fixed percentage: Choose the time between 2 "
"depreciations and the percentage to depreciate."),
'method_percentage': fields.float('Depreciation percentage',
digits=(3,2)),
digits=(3, 2)),
}

_defaults = {
Expand All @@ -57,8 +58,9 @@ class account_asset_category(orm.Model):

def onchange_ext_method_time(self, cr, uid, ids, ext_method_time,
context=None):
res = {'value':{}}
res['value']['method_time'] = 'end' if ext_method_time == 'end' else 'number'
res = {'value': {}}
res['value']['method_time'] = ('end' if ext_method_time == 'end'
else 'number')
return res


Expand All @@ -67,16 +69,18 @@ class account_asset_asset(orm.Model):

_columns = {
'move_end_period': fields.boolean("At the end of the period",
help='Move the depreciation entry at the end of the period. If '
'the period are 12 months, it is put on 31st of December, '
'and in the end of the month in other case.'),
help='Move the depreciation entry at'
' the end of the period. If the '
'period are 12 months, it is put on '
'31st of December, and in the end of'
' the month in other case.'),
# Hay que definir un nuevo campo y jugar con los valores del antiguo
# (method_time) para pasar el constraint _check_prorata y no tener que
# modificar mucho código base
'ext_method_time': fields.selection(
[('number', 'Number of Depreciations'),
('end','Ending Date'),
('percentage','Fixed percentage')], 'Time Method', required=True,
('end', 'Ending Date'),
('percentage', 'Fixed percentage')], 'Time Method', required=True,
help="Choose the method to use to compute the dates and number of "
"depreciation lines.\n"
" * Number of Depreciations: Fix the number of depreciation "
Expand All @@ -86,11 +90,12 @@ class account_asset_asset(orm.Model):
" * Fixed percentage: Choose the time between 2 "
"depreciations and the percentage to depreciate."),
'method_percentage': fields.float('Depreciation percentage',
digits=(3,2)),
digits=(3, 2)),
}

_defaults = {
'method_percentage': 100.0,
'ext_method_time': 'percentage',
'move_end_period': True,
}

Expand All @@ -102,14 +107,16 @@ class account_asset_asset(orm.Model):

def onchange_ext_method_time(self, cr, uid, ids, ext_method_time,
context=None):
res = {'value':{}}
res['value']['method_time'] = ('end' if ext_method_time == 'end'
res = {'value': {}}
res['value']['method_time'] = ('end' if ext_method_time == 'end'
else 'number')
return res

def onchange_category_id(self, cr, uid, ids, category_id, context=None):
res = super(account_asset_asset, self).onchange_category_id(cr, uid,
ids, category_id, context=context)
res = super(account_asset_asset, self).onchange_category_id(
cr, uid, ids,
category_id, context=context)

if category_id:
category_obj = self.pool.get('account.asset.category')
category = category_obj.browse(cr, uid, category_id,
Expand All @@ -119,7 +126,8 @@ def onchange_category_id(self, cr, uid, ids, category_id, context=None):
return res

def _compute_board_undone_dotation_nb(self, cr, uid, asset,
depreciation_date, total_days, context=None):
depreciation_date, total_days,
context=None):
if asset.ext_method_time == 'percentage':
number = 0
percentage = 100.0
Expand All @@ -139,7 +147,7 @@ def _compute_board_undone_dotation_nb(self, cr, uid, asset,
total_days, context=context)
if depreciation_date.day == 1 and depreciation_date.month == 1:
# Quitar una depreciación del nº total si el activo se compró
# el 1 de enero, ya que ese año sería completo
# el 1 de enero, ya que ese año sería completo
val -= 1
return val

Expand Down Expand Up @@ -169,35 +177,41 @@ def _compute_board_amount(self, cr, uid, asset, i, residual_amount,
amount *= days / total_days
return amount
else:
return super(account_asset_asset, 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)
return super(account_asset_asset, 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)

def compute_depreciation_board(self, cr, uid, ids, context=None):
super(account_asset_asset, self).compute_depreciation_board(cr, uid,
ids, context=context)
super(account_asset_asset, self).compute_depreciation_board(
cr, uid,
ids, context=context)

for asset in self.browse(cr, uid, ids, context=context):
if asset.move_end_period:
# Reescribir la fecha de la depreciación
depr_lin_obj = self.pool.get('account.asset.depreciation.line')
new_depr_line_ids = depr_lin_obj.search(cr, uid,
[('asset_id', '=', asset.id),
('move_id', '=', False)])
new_depr_line_ids = depr_lin_obj.search(
cr, uid,
[('asset_id', '=', asset.id), ('move_id', '=', False)])

for depr_line in depr_lin_obj.browse(cr, uid,
new_depr_line_ids):
depr_date = datetime.strptime(
depr_line.depreciation_date, DSDF)
depr_line.depreciation_date,
DSDF)

if asset.method_period == 12:
depr_date = depr_date.replace(depr_date.year, 12, 31)
else:
last_month_day = calendar.monthrange(depr_date.year,
depr_date.month)[1]
last_month_day = calendar.monthrange(
depr_date.year, depr_date.month)[1]
depr_date = depr_date.replace(depr_date.year,
depr_date.month,
last_month_day)
depr_lin_obj.write(cr, uid, depr_line.id,
{'depreciation_date': depr_date.strftime(DSDF)})
depr_lin_obj.write(
cr, uid, depr_line.id,
{'depreciation_date': depr_date.strftime(DSDF)})
return True

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 839a7af

Please sign in to comment.