[FIX] account_move_line.invoice_id is not needed, there is already account_move_line.invoice, it's a function field which does the same thing

This commit is contained in:
Guewen Baconnier
2013-09-04 14:37:34 +02:00
parent fbee4d8217
commit bc2847acd3
2 changed files with 1 additions and 23 deletions

View File

@@ -64,21 +64,6 @@ class AccountInvoice(orm.Model):
readonly=True),
}
def action_move_create(self, cr, uid, ids, context=None):
""" Write the id of the invoice in the generated moves. """
if context is None:
context = {}
# add from_parent_object to the conxtext to let the line.write
# call pass through account_constraints
ctxt = context.copy()
ctxt['from_parent_object'] = True
res = super(AccountInvoice, self).action_move_create(cr, uid, ids, context=ctxt)
for inv in self.browse(cr, uid, ids, context=ctxt):
if inv.move_id:
for line in inv.move_id.line_id:
line.write({'invoice_id': inv.id}, context=ctxt)
return res
def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
@@ -88,10 +73,3 @@ class AccountInvoice(orm.Model):
default['credit_control_line_ids'] = False
return super(AccountInvoice, self).copy_data(
cr, uid, id, default=default, context=context)
class AccountMoveLine(orm.Model):
_inherit = "account.move.line"
_columns = {'invoice_id': fields.many2one('account.invoice', 'Invoice')}

View File

@@ -130,7 +130,7 @@ class CreditControlLine(orm.Model):
data['date_due'] = move_line.date_maturity
data['state'] = 'draft'
data['channel'] = level.channel
data['invoice_id'] = move_line.invoice_id.id if move_line.invoice_id else False
data['invoice_id'] = move_line.invoice.id if move_line.invoice else False
data['partner_id'] = move_line.partner_id.id
data['amount_due'] = (move_line.amount_currency or move_line.debit or
move_line.credit)