class account_invoice(osv.osv):
_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):
res = super(account_invoice, self).line_get_convert(cr, uid, x, part, date, context=context)
res['asset_id'] = x.get('asset_id', False)
_columns = {
'asset_category_id': fields.many2one('account.asset.category', 'Asset Category'),
}
-
- def move_line_get_item(self, cr, uid, line, context=None):
+ def asset_create(self, cr, uid, lines, context=None):
+ context = context or {}
asset_obj = self.pool.get('account.asset.asset')
- res = super(account_invoice_line, self).move_line_get_item(cr, uid, line, context=context)
- if line.invoice_id and line.invoice_id.type not in ('out_invoice', 'out_refund') and line.asset_category_id:
+ for line in lines:
+ if line.asset_category_id:
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,
'purchase_value': line.price_subtotal,
'period_id': line.invoice_id.period_id.id,
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
+ return True
account_invoice_line()