Merge lp:~pexego/openerp-spain/l10n_es_account_asset_improvements6.1 into lp:~openerp-spain-team/openerp-spain/6.1

Proposed by Omar (Pexego) on 2013-01-07
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 2013-01-07 Approve on 2014-03-18
Review via email: mp+142163@code.launchpad.net
To post a comment you must log in.
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 return amount
6
7 def _compute_board_undone_dotation_nb(self, cr, uid, asset, depreciation_date, total_days, context=None):
8- undone_dotation_number = asset.method_number
9+ depreciation_lin_obj = self.pool.get('account.asset.depreciation.line')
10+ posted_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_check', '=', True)])
11 if asset.method_time == 'end':
12 end_date = datetime.strptime(asset.method_end, '%Y-%m-%d')
13- undone_dotation_number = 0
14- while depreciation_date <= end_date:
15- depreciation_date = (datetime(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+asset.method_period))
16+ else:
17+ end_date = datetime.strptime(asset.deprec_start_date, '%Y-%m-%d')
18+ if asset.method_period == 12:
19+ end_date = end_date + relativedelta(years=+asset.method_number)
20+ else:
21+ end_date = end_date + relativedelta(months=+asset.method_number)
22+ last_depreciation_date = asset._get_last_depreciation_date()
23+ if last_depreciation_date:
24+ last_depreciation_date = datetime.strptime(last_depreciation_date[asset.id], '%Y-%m-%d')
25+ undone_dotation_number = 0
26+ while depreciation_date <= end_date or (depreciation_date.year == end_date.year and asset.prorata and asset.method_period == 12):
27+ depreciation_date = (datetime(depreciation_date.year, depreciation_date.month, depreciation_date.day) + relativedelta(months=+asset.method_period))
28+ if last_depreciation_date:
29+ if depreciation_date > last_depreciation_date:
30+ undone_dotation_number += 1
31+ else:
32 undone_dotation_number += 1
33- if asset.prorata:
34- undone_dotation_number += 1
35- return undone_dotation_number
36+ return undone_dotation_number + len(posted_depreciation_line_ids)
37
38 def compute_depreciation_board(self, cr, uid, ids, context=None):
39 depreciation_lin_obj = self.pool.get('account.asset.depreciation.line')
40@@ -143,15 +155,16 @@
41 if old_depreciation_line_ids:
42 depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context)
43
44- amount_to_depr = residual_amount = asset.value_residual
45+ amount_to_depr = asset.purchase_value - asset.salvage_value
46
47 depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d')
48 day = depreciation_date.day
49 month = depreciation_date.month
50 year = depreciation_date.year
51- total_days = (year % 4) and 365 or 366
52+ total_days = ((year % 4 == 0 and year % 100 != 0) or year % 400 == 0) and 366 or 365
53
54 undone_dotation_number = self._compute_board_undone_dotation_nb(cr, uid, asset, depreciation_date, total_days, context=context)
55+ residual_amount = asset.value_residual
56 for x in range(len(posted_depreciation_line_ids), undone_dotation_number):
57 i = x + 1
58 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 'sequence': i,
61 'name': str(asset.id) +'/' + str(i),
62 'remaining_value': residual_amount,
63- 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount),
64+ 'depreciated_value': round((asset.purchase_value - asset.salvage_value) - (residual_amount + amount),2),
65 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'),
66 }
67 depreciation_lin_obj.create(cr, uid, vals, context=context)
68@@ -191,7 +204,7 @@
69
70 def _amount_residual(self, cr, uid, ids, name, args, context=None):
71 cr.execute("""SELECT
72- l.asset_id as id, round(SUM(abs(l.debit-l.credit))) AS amount
73+ l.asset_id as id, SUM(abs(l.debit-l.credit)) AS amount
74 FROM
75 account_move_line l
76 WHERE
77@@ -238,6 +251,7 @@
78 '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 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True),
80 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}),
81+ 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
82 '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 }
84 _defaults = {
85@@ -281,6 +295,7 @@
86 'method_progress_factor': category_obj.method_progress_factor,
87 'method_end': category_obj.method_end,
88 'prorata': category_obj.prorata,
89+ 'account_analytic_id': category_obj.account_analytic_id and category_obj.account_analytic_id.id or False
90 }
91 return res
92
93@@ -295,7 +310,7 @@
94 default = {}
95 if context is None:
96 context = {}
97- default.update({'depreciation_line_ids': [], 'state': 'draft'})
98+ default.update({'depreciation_line_ids': [], 'state': 'draft', 'account_move_line_ids': []})
99 return super(account_asset_asset, self).copy(cr, uid, id, default, context=context)
100
101 def _compute_entries(self, cr, uid, ids, period_id, context={}):
102@@ -406,7 +421,7 @@
103 'partner_id': partner_id,
104 'currency_id': company_currency <> current_currency and current_currency or False,
105 'amount_currency': company_currency <> current_currency and sign * line.amount or 0.0,
106- 'analytic_account_id': line.asset_id.category_id.account_analytic_id.id,
107+ 'analytic_account_id': line.asset_id.account_analytic_id and line.asset_id.account_analytic_id.id or False,
108 'date': depreciation_date,
109 'asset_id': line.asset_id.id
110 })
111
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 <field name="prorata"/>
117 <field name="open_asset"/>
118 </group>
119- <group col="2" colspan="2" groups="analytic.group_analytic_accounting">
120- <separator string="Analytic information" colspan="4"/>
121- <newline/>
122- <field name="account_analytic_id"/>
123- </group>
124+ <group col="2" colspan="2" groups="analytic.group_analytic_accounting">
125+ <separator string="Analytic information" colspan="4"/>
126+ <newline/>
127+ <field name="account_analytic_id"/>
128+ </group>
129 <separator string="Notes" colspan="4"/>
130 <field name="note" colspan="4" nolabel="1"/>
131 </form>
132@@ -97,7 +97,7 @@
133 <field name="parent_id"/>
134 <field name="partner_id"/>
135 <field name="purchase_date"/>
136- <field name="deprec_start_date"/>
137+ <field name="deprec_start_date"/>
138 <newline/>
139 <group colspan="2" col="2">
140 <separator string="Depreciation Dates" colspan="2"/>
141@@ -113,7 +113,12 @@
142 <field name="method"/>
143 <field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
144 <field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>
145- <field name="compute_at_end_period"/>
146+ <field name="compute_at_end_period"/>
147+ </group>
148+ <group col="2" colspan="2" groups="analytic.group_analytic_accounting">
149+ <separator string="Analytic information" colspan="4"/>
150+ <newline/>
151+ <field name="account_analytic_id"/>
152 </group>
153 <newline/>
154 <separator string="" colspan="4"/>