Merge lp:~matjaz-6/openerpsl/openerpsl_04_29 into lp:openerpsl/7.0

Proposed by Matjaz Kalic
Status: Merged
Merged at revision: 428
Proposed branch: lp:~matjaz-6/openerpsl/openerpsl_04_29
Merge into: lp:openerpsl/7.0
Diff against target: 188 lines (+167/-0)
4 files modified
account_asset_extensions/__init__.py (+22/-0)
account_asset_extensions/__openerp__.py (+40/-0)
account_asset_extensions/account_asset.py (+72/-0)
account_asset_extensions/account_asset_view.xml (+33/-0)
To merge this branch: bzr merge lp:~matjaz-6/openerpsl/openerpsl_04_29
Reviewer Review Type Date Requested Status
Mentis Pending
Review via email: mp+225949@code.launchpad.net

Description of the change

[ADD] account_asset_extensions

To post a comment you must log in.
428. By Dušan Laznik (Mentis)

[ADD] account_asset_extensions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_asset_extensions'
2=== added file 'account_asset_extensions/__init__.py'
3--- account_asset_extensions/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_asset_extensions/__init__.py 2014-07-08 10:45:37 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (C) 2014 Mentis d.o.o. (<http://www.mentis.si/openerp>)
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+import account_asset
28
29=== added file 'account_asset_extensions/__openerp__.py'
30--- account_asset_extensions/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ account_asset_extensions/__openerp__.py 2014-07-08 10:45:37 +0000
32@@ -0,0 +1,40 @@
33+# -*- coding: utf-8 -*-
34+##############################################################################
35+#
36+# OpenERP, Open Source Management Solution
37+# Copyright (C) 2014 Mentis d.o.o. (<http://www.mentis.si/openerp>)
38+#
39+# This program is free software: you can redistribute it and/or modify
40+# it under the terms of the GNU Affero General Public License as
41+# published by the Free Software Foundation, either version 3 of the
42+# License, or (at your option) any later version.
43+#
44+# This program is distributed in the hope that it will be useful,
45+# but WITHOUT ANY WARRANTY; without even the implied warranty of
46+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+# GNU Affero General Public License for more details.
48+#
49+# You should have received a copy of the GNU Affero General Public License
50+# along with this program. If not, see <http://www.gnu.org/licenses/>.
51+#
52+##############################################################################
53+
54+{
55+ 'name': 'Assets Extensions',
56+ 'version': '1.0',
57+ 'category': 'Account',
58+ 'description': """
59+ This Module adds following extensions to Account Asset:
60+ - analytic account can be set on asset
61+ - location can be set for asset
62+ - Deprication date can be explicitly set
63+
64+ """,
65+ 'author': 'Mentis d.o.o.',
66+ 'depends': ['account_asset'],
67+ 'data': [
68+ 'account_asset_view.xml',
69+ ],
70+ 'installable': True,
71+ 'active': False,
72+}
73
74=== added file 'account_asset_extensions/account_asset.py'
75--- account_asset_extensions/account_asset.py 1970-01-01 00:00:00 +0000
76+++ account_asset_extensions/account_asset.py 2014-07-08 10:45:37 +0000
77@@ -0,0 +1,72 @@
78+# -*- coding: utf-8 -*-
79+##############################################################################
80+#
81+# OpenERP, Open Source Management Solution
82+# Copyright (C) 2014 Mentis d.o.o. (<http://www.mentis.si/openerp>)
83+#
84+# This program is free software: you can redistribute it and/or modify
85+# it under the terms of the GNU Affero General Public License as
86+# published by the Free Software Foundation, either version 3 of the
87+# License, or (at your option) any later version.
88+#
89+# This program is distributed in the hope that it will be useful,
90+# but WITHOUT ANY WARRANTY; without even the implied warranty of
91+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
92+# GNU Affero General Public License for more details.
93+#
94+# You should have received a copy of the GNU Affero General Public License
95+# along with this program. If not, see <http://www.gnu.org/licenses/>.
96+#
97+##############################################################################
98+
99+from osv import fields, osv
100+from tools.translate import _
101+
102+class account_asset_asset(osv.osv):
103+ _inherit = 'account.asset.asset'
104+
105+ _columns = {
106+ 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
107+ 'location_id': fields.many2one('stock.location', 'Location', required=True, domain="[('usage', '=', 'internal')]"),
108+ 'purchase_date': fields.date('Depreciation Date', required=True, readonly=True, states={'draft':[('readonly',False)]}, help = _('Depreciation start date')),
109+ 'date_acquisition': fields.date('Date Acquisition', help = _('Date acquisition'))
110+ }
111+
112+ def onchange_category_id(self, cr, uid, ids, category_id, context=None):
113+ res = super(account_asset_asset, self).onchange_category_id(cr, uid, ids, category_id, context=context)
114+ if category_id:
115+ for category in self.pool.get('account.asset.category').browse(cr, uid, [category_id], context=context):
116+ if category.account_analytic_id:
117+ res['value']['account_analytic_id'] = category.account_analytic_id.id
118+ return res
119+
120+# def _get_last_depreciation_date(self, cr, uid, ids, context=None):
121+# """
122+# @param id: ids of a account.asset.asset objects
123+# @return: Returns a dictionary of the effective dates of the last depreciation entry made for given asset ids. If there isn't any, return the purchase date of this asset
124+# """
125+# cr.execute("""
126+# SELECT a.id as id, COALESCE(MAX(l.date),(DATE_TRUNC('month', a.purchase_date) + interval '1' month)::date) AS date
127+# FROM account_asset_asset a
128+# LEFT JOIN account_move_line l ON (l.asset_id = a.id)
129+# WHERE a.id IN %s
130+# GROUP BY a.id, a.purchase_date """, (tuple(ids),))
131+# return dict(cr.fetchall())
132+
133+account_asset_asset()
134+
135+class account_asset_depreciation_line(osv.osv):
136+ _inherit = 'account.asset.depreciation.line'
137+
138+ def create_move(self, cr, uid, ids, context=None):
139+ res = super(account_asset_depreciation_line, self).create_move(cr, uid, ids=ids, context=context)
140+ if res:
141+ line_ids = self.pool.get('account.move.line').search(cr, uid, [('move_id', 'in', res)])
142+ for line in self.pool.get('account.move.line').browse(cr, uid, line_ids):
143+ if line.asset_id:
144+ self.pool.get('account.move.line').write(cr, uid, [line.id], {'analytic_account_id':line.asset_id.account_analytic_id.id})
145+
146+ #raise 'stop'
147+ return res
148+
149+account_asset_depreciation_line()
150
151=== added file 'account_asset_extensions/account_asset_view.xml'
152--- account_asset_extensions/account_asset_view.xml 1970-01-01 00:00:00 +0000
153+++ account_asset_extensions/account_asset_view.xml 2014-07-08 10:45:37 +0000
154@@ -0,0 +1,33 @@
155+<?xml version="1.0" encoding="utf-8"?>
156+<openerp>
157+ <data>
158+
159+ <record id="view_account_asset_asset_form_extensions" model="ir.ui.view">
160+ <field name="name">account.asset.asset.form.extensions</field>
161+ <field name="model">account.asset.asset</field>
162+ <field name="inherit_id" ref="account_asset.view_account_asset_asset_form"/>
163+ <field name="arch" type="xml">
164+ <xpath expr="//sheet/group/group/field[@name='purchase_date']" position="after">
165+ <field name="date_acquisition"/>
166+ <field name="account_analytic_id"/>
167+ <field name="location_id"/>
168+ </xpath>
169+ </field>
170+ </record>
171+
172+ <record id="view_account_asset_search_extensions" model="ir.ui.view">
173+ <field name="name">account.asset.asset.search.extensions</field>
174+ <field name="model">account.asset.asset</field>
175+ <field name="inherit_id" ref="account_asset.view_account_asset_search"/>
176+ <field name="arch" type="xml">
177+ <filter string="Closed" position="after">
178+ <group expand="0" string="Group By...">
179+ <filter string="Analytic Account" domain="[]" context="{'group_by':'account_analytic_id'}"/>
180+ <filter string="Location" icon="terp-folder-orange" domain="[]" context="{'group_by':'location_id'}"/>
181+ </group>
182+ </filter>
183+ </field>
184+ </record>
185+
186+ </data>
187+</openerp>
188\ No newline at end of file

Subscribers

People subscribed via source and target branches