[FIX] clening of assets
bzr revid: fp@tinyerp.com-20111111192954-2lasevx3lvqa2z1k
This commit is contained in:
commit
27845291b8
|
@ -201,7 +201,7 @@ class account_asset_asset(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'account_move_line_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
|
'account_move_line_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
'name': fields.char('Asset', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'name': fields.char('Asset', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
'code': fields.char('Reference ', size=16, readonly=True, states={'draft':[('readonly',False)]}),
|
'code': fields.char('Reference', size=32, readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
'purchase_value': fields.float('Gross value ', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'purchase_value': fields.float('Gross value ', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
'currency_id': fields.many2one('res.currency','Currency',required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'currency_id': fields.many2one('res.currency','Currency',required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
|
|
|
@ -24,6 +24,12 @@ from osv import osv, fields
|
||||||
class account_invoice(osv.osv):
|
class account_invoice(osv.osv):
|
||||||
|
|
||||||
_inherit = 'account.invoice'
|
_inherit = 'account.invoice'
|
||||||
|
def action_number(self, cr, uid, ids, *args):
|
||||||
|
result = super(account_invoice, self).action_number(cr, uid, ids, *args)
|
||||||
|
for inv in self.browse(cr, uid, ids):
|
||||||
|
self.pool.get('account.invoice.line').asset_create(cr, uid, inv.invoice_line)
|
||||||
|
return result
|
||||||
|
|
||||||
def line_get_convert(self, cr, uid, x, part, date, context=None):
|
def line_get_convert(self, cr, uid, x, part, date, context=None):
|
||||||
res = super(account_invoice, self).line_get_convert(cr, uid, x, part, date, context=context)
|
res = super(account_invoice, self).line_get_convert(cr, uid, x, part, date, context=context)
|
||||||
res['asset_id'] = x.get('asset_id', False)
|
res['asset_id'] = x.get('asset_id', False)
|
||||||
|
@ -37,13 +43,14 @@ class account_invoice_line(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'asset_category_id': fields.many2one('account.asset.category', 'Asset Category'),
|
'asset_category_id': fields.many2one('account.asset.category', 'Asset Category'),
|
||||||
}
|
}
|
||||||
|
def asset_create(self, cr, uid, lines, context=None):
|
||||||
def move_line_get_item(self, cr, uid, line, context=None):
|
context = context or {}
|
||||||
asset_obj = self.pool.get('account.asset.asset')
|
asset_obj = self.pool.get('account.asset.asset')
|
||||||
res = super(account_invoice_line, self).move_line_get_item(cr, uid, line, context=context)
|
for line in lines:
|
||||||
if line.invoice_id and line.invoice_id.type not in ('out_invoice', 'out_refund') and line.asset_category_id:
|
if line.asset_category_id:
|
||||||
vals = {
|
vals = {
|
||||||
'name': line.product_id and (line.name + ": " + line.product_id.name) or line.name,
|
'name': line.name,
|
||||||
|
'code': line.invoice_id.number or False,
|
||||||
'category_id': line.asset_category_id.id,
|
'category_id': line.asset_category_id.id,
|
||||||
'purchase_value': line.price_subtotal,
|
'purchase_value': line.price_subtotal,
|
||||||
'period_id': line.invoice_id.period_id.id,
|
'period_id': line.invoice_id.period_id.id,
|
||||||
|
@ -51,10 +58,12 @@ class account_invoice_line(osv.osv):
|
||||||
'company_id': line.invoice_id.company_id.id,
|
'company_id': line.invoice_id.company_id.id,
|
||||||
'currency_id': line.invoice_id.currency_id.id,
|
'currency_id': line.invoice_id.currency_id.id,
|
||||||
}
|
}
|
||||||
|
changed_vals = asset_obj.onchange_category_id(cr, uid, [], vals['category_id'], context=context)
|
||||||
|
vals.update(changed_vals['value'])
|
||||||
asset_id = asset_obj.create(cr, uid, vals, context=context)
|
asset_id = asset_obj.create(cr, uid, vals, context=context)
|
||||||
if line.asset_category_id.open_asset:
|
if line.asset_category_id.open_asset:
|
||||||
asset_obj.validate(cr, uid, [asset_id], context=context)
|
asset_obj.validate(cr, uid, [asset_id], context=context)
|
||||||
return res
|
return True
|
||||||
|
|
||||||
account_invoice_line()
|
account_invoice_line()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue