diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py
index b3e6e9bc084..6f73c931963 100644
--- a/addons/account_asset/account_asset.py
+++ b/addons/account_asset/account_asset.py
@@ -37,10 +37,22 @@ class account_asset_category(osv.osv):
'account_expense_depreciation_id': fields.many2one('account.account', 'Depr. Expense Account', required=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
+ 'method': fields.selection([('linear','Linear'),('progressif','Progressive')], 'Computation method', required=True),
+ 'method_delay': fields.integer('During (interval)'),
+ 'method_period': fields.integer('Depre. all (period)'),
+ 'method_progress_factor': fields.float('Progressif Factor'),
+ 'method_time': fields.selection([('delay','Delay'),('end','Ending Period')], 'Time Method', required=True),
+ 'prorata':fields.boolean('Prorata Temporis', help='Indicates that the accounting entries for this asset have to be done from the purchase date instead of the first January'),
+ 'open_asset': fields.boolean('Skip Draft State', help="Check this if you want to automatically confirm the assets of this category when created by invoice."),
}
_defaults = {
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.category', context=context),
+ 'method': 'linear',
+ 'method_delay': 5,
+ 'method_time': 'delay',
+ 'method_period': 12,
+ 'method_progress_factor': 0.3,
}
account_asset_category()
@@ -124,7 +136,7 @@ class account_asset_asset(osv.osv):
def validate(self, cr, uid, ids, context={}):
return self.write(cr, uid, ids, {
- 'state':'normal'
+ 'state':'open'
}, context)
def _amount_total(self, cr, uid, ids, name, args, context={}):
@@ -198,7 +210,21 @@ class account_asset_asset(osv.osv):
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'account.asset.asset',context=context),
}
-
+ def onchange_category_id(self, cr, uid, ids, category_id, context=None):
+ res = {'value':{}}
+ asset_categ_obj = self.pool.get('account.asset.category')
+ if category_id:
+ category_obj = asset_categ_obj.browse(cr, uid, category_id, context=context)
+ res['value'] = {
+ 'method': category_obj.method,
+ 'method_delay': category_obj.method_delay,
+ 'method_time': category_obj.method_time,
+ 'method_period': category_obj.method_period,
+ 'method_progress_factor': category_obj.method_progress_factor,
+ 'prorata': category_obj.prorata,
+ }
+ return res
+
def _compute_period(self, cr, uid, property, context={}):
if (len(property.entry_asset_ids or [])/2)>=property.method_delay:
return False
@@ -301,7 +327,7 @@ class account_asset_depreciation_line(osv.osv):
'depreciated_value': fields.float('Amount Already Depreciated', required=True),
'depreciation_date': fields.char('Depreciation Date', size=64, select=1),
'move_id': fields.many2one('account.move', 'Depreciation Entry'),
- 'move_check': fields.function(_get_move_check, method=True, type='boolean', string='Move Included', store=True)
+ 'move_check': fields.function(_get_move_check, method=True, type='boolean', string='Posted', store=True)
}
def create_move(self, cr, uid,ids, context=None):
diff --git a/addons/account_asset/account_asset_invoice.py b/addons/account_asset/account_asset_invoice.py
index 1bc9fbcf37c..f130bdc09cf 100755
--- a/addons/account_asset/account_asset_invoice.py
+++ b/addons/account_asset/account_asset_invoice.py
@@ -33,13 +33,20 @@ account_invoice()
class account_invoice_line(osv.osv):
_inherit = 'account.invoice.line'
_columns = {
- 'asset_id': fields.many2one('account.asset.asset', 'Asset'),
+ 'asset_category_id': fields.many2one('account.asset.category', 'Asset Category'),
}
def move_line_get_item(self, cr, uid, line, context={}):
+ asset_obj = self.pool.get('account.asset.asset')
res = super(account_invoice_line, self).move_line_get_item(cr, uid, line, context)
- res['asset_id'] = line.asset_id.id or False
- if line.asset_id.id and (line.asset_id.state=='draft'):
- self.pool.get('account.asset.asset').validate(cr, uid, [line.asset_id.id], context)
+ if line.asset_category_id:
+ vals = {
+ 'name': line.product_id and (line.name + ": " + line.product_id.name) or line.name,
+ 'category_id': line.asset_category_id.id,
+ 'purchase_value': line.price_subtotal
+ }
+ asset_id = asset_obj.create(cr, uid, vals, context=context)
+ if line.asset_category_id.open_asset:
+ asset_obj.validate(cr, uid, [asset_id], context=context)
return res
account_invoice_line()
diff --git a/addons/account_asset/account_asset_invoice_view.xml b/addons/account_asset/account_asset_invoice_view.xml
index 394d173f8ed..f694ce425c2 100755
--- a/addons/account_asset/account_asset_invoice_view.xml
+++ b/addons/account_asset/account_asset_invoice_view.xml
@@ -13,7 +13,7 @@
form
-
+
diff --git a/addons/account_asset/account_asset_view.xml b/addons/account_asset/account_asset_view.xml
index 95a6e9f2c22..4cd9572787f 100644
--- a/addons/account_asset/account_asset_view.xml
+++ b/addons/account_asset/account_asset_view.xml
@@ -15,6 +15,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -50,7 +63,7 @@