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
1=== modified file 'account_asset/account_asset.py'
2--- account_asset/account_asset.py 2012-01-31 13:36:57 +0000
3+++ account_asset/account_asset.py 2012-07-02 04:55:24 +0000
4@@ -163,7 +163,7 @@
5 'amount': amount,
6 'asset_id': asset.id,
7 'sequence': i,
8- 'name': str(asset.id) +'/' + str(i),
9+ 'name': (asset.code or str(asset.id)) +'/' + str(i),
10 'remaining_value': residual_amount,
11 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount),
12 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'),
13@@ -245,6 +245,7 @@
14 'history_ids': fields.one2many('account.asset.history', 'asset_id', 'History', readonly=True),
15 'depreciation_line_ids': fields.one2many('account.asset.depreciation.line', 'asset_id', 'Depreciation Lines', readonly=True, states={'draft':[('readonly',False)],'open':[('readonly',False)]}),
16 '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)]}),
17+ 'purchase_invoice_id': fields.many2one('account.invoice','Purchase Invoice'),
18 }
19 _defaults = {
20 'code': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'account.asset.code'),
21@@ -337,7 +338,7 @@
22 'amount': fields.float('Depreciation Amount', required=True),
23 'remaining_value': fields.float('Amount to Depreciate', required=True),
24 'depreciated_value': fields.float('Amount Already Depreciated', required=True),
25- 'depreciation_date': fields.char('Depreciation Date', size=64, select=1),
26+ 'depreciation_date': fields.date('Depreciation Date', required=True),
27 'move_id': fields.many2one('account.move', 'Depreciation Entry'),
28 'move_check': fields.function(_get_move_check, method=True, type='boolean', string='Posted', store=True)
29 }
30@@ -355,7 +356,7 @@
31 for line in self.browse(cr, uid, ids, context=context):
32 if currency_obj.is_zero(cr, uid, line.asset_id.currency_id, line.remaining_value):
33 can_close = True
34- depreciation_date = line.asset_id.prorata and line.asset_id.purchase_date or time.strftime('%Y-%m-%d')
35+ depreciation_date = line.depreciation_date or time.strftime('%Y-%m-%d')
36 period_ids = period_obj.find(cr, uid, depreciation_date, context=context)
37 company_currency = line.asset_id.company_id.currency_id.id
38 current_currency = line.asset_id.currency_id.id
39@@ -365,9 +366,8 @@
40 asset_name = line.asset_id.name
41 reference = line.name
42 move_vals = {
43- 'name': asset_name,
44 'date': depreciation_date,
45- 'ref': reference,
46+ 'ref': reference + ' - ' + asset_name,
47 'period_id': period_ids and period_ids[0] or False,
48 'journal_id': line.asset_id.category_id.journal_id.id,
49 }
50
51=== modified file 'account_asset/account_asset_invoice.py'
52--- account_asset/account_asset_invoice.py 2011-11-11 19:29:54 +0000
53+++ account_asset/account_asset_invoice.py 2012-07-02 04:55:24 +0000
54@@ -50,13 +50,13 @@
55 if line.asset_category_id:
56 vals = {
57 'name': line.name,
58- 'code': line.invoice_id.number or False,
59+ 'purchase_invoice_id': line.invoice_id and line.invoice_id.id or False,
60 'category_id': line.asset_category_id.id,
61 'purchase_value': line.price_subtotal,
62- 'period_id': line.invoice_id.period_id.id,
63 'partner_id': line.invoice_id.partner_id.id,
64 'company_id': line.invoice_id.company_id.id,
65 'currency_id': line.invoice_id.currency_id.id,
66+ 'purchase_date': line.invoice_id.date_invoice,
67 }
68 changed_vals = asset_obj.onchange_category_id(cr, uid, [], vals['category_id'], context=context)
69 vals.update(changed_vals['value'])
70
71=== modified file 'account_asset/account_asset_view.xml'
72--- account_asset/account_asset_view.xml 2011-12-21 22:06:36 +0000
73+++ account_asset/account_asset_view.xml 2012-07-02 04:55:24 +0000
74@@ -95,6 +95,7 @@
75 <field name="partner_id"/>
76 <field name="purchase_date"/>
77 <field name="parent_id" groups="base.group_extended"/>
78+ <field name="purchase_invoice_id"/>
79 <newline/>
80 <group colspan="2" col="2">
81 <separator string="Depreciation Dates" colspan="2"/>
82
83=== modified file 'account_asset/report/account_asset_report.py'
84--- account_asset/report/account_asset_report.py 2011-07-05 14:23:22 +0000
85+++ account_asset/report/account_asset_report.py 2012-07-02 04:55:24 +0000
86@@ -50,7 +50,7 @@
87 select
88 min(dl.id) as id,
89 dl.name as name,
90- to_date(dl.depreciation_date, 'YYYY-MM-DD') as depreciation_date,
91+ dl.depreciation_date as depreciation_date,
92 a.purchase_date as purchase_date,
93 (CASE WHEN (select min(d.id) from account_asset_depreciation_line as d
94 left join account_asset_asset as ac ON (ac.id=d.asset_id)
95@@ -77,7 +77,7 @@
96 from account_asset_depreciation_line dl
97 left join account_asset_asset a on (dl.asset_id=a.id)
98 group by
99- dl.amount,dl.asset_id,to_date(dl.depreciation_date, 'YYYY-MM-DD'),dl.name,
100+ dl.amount,dl.asset_id,dl.depreciation_date,dl.name,
101 a.purchase_date, dl.move_check, a.state, a.category_id, a.partner_id, a.company_id,
102 a.purchase_value, a.id, a.salvage_value
103 )""")