Merge lp:~cv.clearcorp/openobject-addons/6.1-account_asset into lp:openobject-addons/6.1

Proposed by Carlos Vásquez (ClearCorp)
Status: Needs review
Proposed branch: lp:~cv.clearcorp/openobject-addons/6.1-account_asset
Merge into: lp:openobject-addons/6.1
Diff against target: 103 lines (+10/-9)
4 files modified
account_asset/account_asset.py (+5/-5)
account_asset/account_asset_invoice.py (+2/-2)
account_asset/account_asset_view.xml (+1/-0)
account_asset/report/account_asset_report.py (+2/-2)
To merge this branch: bzr merge lp:~cv.clearcorp/openobject-addons/6.1-account_asset
Reviewer Review Type Date Requested Status
xavi (community) Approve
OpenERP Core Team Pending
Review via email: mp+112963@code.launchpad.net

Description of the change

From bug 1019932 description:

1. When the asset is created from an invoice, the asset reference is assigned as the invoice number. The correct thing to do is link the invoice to the asset, and let the invoice have it's sequential number (or custom user assigned number)

2. When the asset is created manually, the reference is filled because there is no sequence or sequence type created by default at module installation. The sequence code is there, but the user has to know to create at least one sequence with the specific code set to "account.asset.code".

3. When the move is created for a depreciation line, the date used is the purchase date (if asset is marked as prorata), or today. If the depreciation line already has a date, it must be used. Otherwise it is misleading for the user. The correct dates are already calculated when the depreciation lines are created. The move line creation must use those data.

4. The depreciation moves should use the default journal sequence for number (name), the reference (ref) can have some info about the asset and the depreciation line. The same applies for the move lines.

---------------------------

All the 4 points are corrected in this branch. We tested that it wouldn't break pre-existing assets or any functionality. But if there is something wrong please get back at us and we will be glad to fix it.

To post a comment you must log in.
Revision history for this message
xavi (xgilest) wrote :

Please, review this merge proposal, its only a minute and it is completly necessary to have the journal right. The name of the move can't be the name of the asset. It's been more than a year.

review: Approve

Unmerged revisions

6867. By Carlos Vásquez (ClearCorp)

[FIX] asset creation from invoice now links the invoice and uses the correct sequence for code
[FIX] module installation creates sequence and sequence type ready for use
[FIX] asset depreciation move creation now uses the correct date and period
[FIX] asset depreciation move and move lines now use more standard info for number and reference.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_asset/account_asset.py'
--- account_asset/account_asset.py 2012-01-31 13:36:57 +0000
+++ account_asset/account_asset.py 2012-07-02 04:55:24 +0000
@@ -163,7 +163,7 @@
163 'amount': amount,163 'amount': amount,
164 'asset_id': asset.id,164 'asset_id': asset.id,
165 'sequence': i,165 'sequence': i,
166 'name': str(asset.id) +'/' + str(i),166 'name': (asset.code or str(asset.id)) +'/' + str(i),
167 'remaining_value': residual_amount,167 'remaining_value': residual_amount,
168 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount),168 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount),
169 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'),169 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'),
@@ -245,6 +245,7 @@
245 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True),245 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True),
246 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}),246 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}),
247 '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)]}),247 '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)]}),
248 'purchase_invoice_id': fields.many2one('account.invoice','Purchase Invoice'),
248 }249 }
249 _defaults = {250 _defaults = {
250 'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'),251 'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'),
@@ -337,7 +338,7 @@
337 'amount': fields.float('Depreciation Amount', required=True),338 'amount': fields.float('Depreciation Amount', required=True),
338 'remaining_value': fields.float('Amount to Depreciate', required=True),339 'remaining_value': fields.float('Amount to Depreciate', required=True),
339 'depreciated_value': fields.float('Amount Already Depreciated', required=True),340 'depreciated_value': fields.float('Amount Already Depreciated', required=True),
340 'depreciation_date': fields.char('Depreciation Date', size=64, select=1),341 'depreciation_date': fields.date('Depreciation Date', required=True),
341 'move_id': fields.many2one('account.move', 'Depreciation Entry'),342 'move_id': fields.many2one('account.move', 'Depreciation Entry'),
342 'move_check': fields.function(_get_move_check, method=True, type='boolean', string='Posted', store=True)343 'move_check': fields.function(_get_move_check, method=True, type='boolean', string='Posted', store=True)
343 }344 }
@@ -355,7 +356,7 @@
355 for line in self.browse(cr, uid, ids, context=context):356 for line in self.browse(cr, uid, ids, context=context):
356 if currency_obj.is_zero(cr, uid, line.asset_id.currency_id, line.remaining_value):357 if currency_obj.is_zero(cr, uid, line.asset_id.currency_id, line.remaining_value):
357 can_close = True358 can_close = True
358 depreciation_date = line.asset_id.prorata and line.asset_id.purchase_date or time.strftime('%Y-%m-%d')359 depreciation_date = line.depreciation_date or time.strftime('%Y-%m-%d')
359 period_ids = period_obj.find(cr, uid, depreciation_date, context=context)360 period_ids = period_obj.find(cr, uid, depreciation_date, context=context)
360 company_currency = line.asset_id.company_id.currency_id.id361 company_currency = line.asset_id.company_id.currency_id.id
361 current_currency = line.asset_id.currency_id.id362 current_currency = line.asset_id.currency_id.id
@@ -365,9 +366,8 @@
365 asset_name = line.asset_id.name366 asset_name = line.asset_id.name
366 reference = line.name367 reference = line.name
367 move_vals = {368 move_vals = {
368 'name': asset_name,
369 'date': depreciation_date,369 'date': depreciation_date,
370 'ref': reference,370 'ref': reference + ' - ' + asset_name,
371 'period_id': period_ids and period_ids[0] or False,371 'period_id': period_ids and period_ids[0] or False,
372 'journal_id': line.asset_id.category_id.journal_id.id,372 'journal_id': line.asset_id.category_id.journal_id.id,
373 }373 }
374374
=== modified file 'account_asset/account_asset_invoice.py'
--- account_asset/account_asset_invoice.py 2011-11-11 19:29:54 +0000
+++ account_asset/account_asset_invoice.py 2012-07-02 04:55:24 +0000
@@ -50,13 +50,13 @@
50 if line.asset_category_id:50 if line.asset_category_id:
51 vals = {51 vals = {
52 'name': line.name,52 'name': line.name,
53 'code': line.invoice_id.number or False,53 'purchase_invoice_id': line.invoice_id and line.invoice_id.id or False,
54 'category_id': line.asset_category_id.id,54 'category_id': line.asset_category_id.id,
55 'purchase_value': line.price_subtotal,55 'purchase_value': line.price_subtotal,
56 'period_id': line.invoice_id.period_id.id,
57 'partner_id': line.invoice_id.partner_id.id,56 'partner_id': line.invoice_id.partner_id.id,
58 'company_id': line.invoice_id.company_id.id,57 'company_id': line.invoice_id.company_id.id,
59 'currency_id': line.invoice_id.currency_id.id,58 'currency_id': line.invoice_id.currency_id.id,
59 'purchase_date': line.invoice_id.date_invoice,
60 }60 }
61 changed_vals = asset_obj.onchange_category_id(cr, uid, [], vals['category_id'], context=context)61 changed_vals = asset_obj.onchange_category_id(cr, uid, [], vals['category_id'], context=context)
62 vals.update(changed_vals['value'])62 vals.update(changed_vals['value'])
6363
=== modified file 'account_asset/account_asset_view.xml'
--- account_asset/account_asset_view.xml 2011-12-21 22:06:36 +0000
+++ account_asset/account_asset_view.xml 2012-07-02 04:55:24 +0000
@@ -95,6 +95,7 @@
95 <field name="partner_id"/>95 <field name="partner_id"/>
96 <field name="purchase_date"/>96 <field name="purchase_date"/>
97 <field name="parent_id" groups="base.group_extended"/>97 <field name="parent_id" groups="base.group_extended"/>
98 <field name="purchase_invoice_id"/>
98 <newline/>99 <newline/>
99 <group colspan="2" col="2">100 <group colspan="2" col="2">
100 <separator string="Depreciation Dates" colspan="2"/>101 <separator string="Depreciation Dates" colspan="2"/>
101102
=== modified file 'account_asset/report/account_asset_report.py'
--- account_asset/report/account_asset_report.py 2011-07-05 14:23:22 +0000
+++ account_asset/report/account_asset_report.py 2012-07-02 04:55:24 +0000
@@ -50,7 +50,7 @@
50 select 50 select
51 min(dl.id) as id,51 min(dl.id) as id,
52 dl.name as name,52 dl.name as name,
53 to_date(dl.depreciation_date, 'YYYY-MM-DD') as depreciation_date,53 dl.depreciation_date as depreciation_date,
54 a.purchase_date as purchase_date,54 a.purchase_date as purchase_date,
55 (CASE WHEN (select min(d.id) from account_asset_depreciation_line as d55 (CASE WHEN (select min(d.id) from account_asset_depreciation_line as d
56 left join account_asset_asset as ac ON (ac.id=d.asset_id)56 left join account_asset_asset as ac ON (ac.id=d.asset_id)
@@ -77,7 +77,7 @@
77 from account_asset_depreciation_line dl77 from account_asset_depreciation_line dl
78 left join account_asset_asset a on (dl.asset_id=a.id)78 left join account_asset_asset a on (dl.asset_id=a.id)
79 group by 79 group by
80 dl.amount,dl.asset_id,to_date(dl.depreciation_date, 'YYYY-MM-DD'),dl.name,80 dl.amount,dl.asset_id,dl.depreciation_date,dl.name,
81 a.purchase_date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id,81 a.purchase_date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id,
82 a.purchase_value, a.id, a.salvage_value82 a.purchase_value, a.id, a.salvage_value
83 )""")83 )""")