[FIX] purchase: invoiced based on invoiced bool of purchase order line, instead of rate
invoiced bool of purchase order line is set to true on invoice validation, not on invoice creation bzr revid: dle@openerp.com-20140415081211-jz6if0vzgq3inzzw
This commit is contained in:
parent
6ca81553a0
commit
a701934ac7
|
@ -134,10 +134,7 @@ class purchase_order(osv.osv):
|
|||
def _invoiced(self, cursor, user, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for purchase in self.browse(cursor, user, ids, context=context):
|
||||
invoiced = False
|
||||
if purchase.invoiced_rate == 100.00:
|
||||
invoiced = True
|
||||
res[purchase.id] = invoiced
|
||||
res[purchase.id] = all(line.invoiced for line in purchase.order_line)
|
||||
return res
|
||||
|
||||
def _get_journal(self, cr, uid, context=None):
|
||||
|
@ -544,7 +541,7 @@ class purchase_order(osv.osv):
|
|||
inv_line_id = inv_line_obj.create(cr, uid, inv_line_data, context=context)
|
||||
inv_lines.append(inv_line_id)
|
||||
|
||||
po_line.write({'invoiced': True, 'invoice_lines': [(4, inv_line_id)]}, context=context)
|
||||
po_line.write({'invoice_lines': [(4, inv_line_id)]}, context=context)
|
||||
|
||||
# get invoice data and create invoice
|
||||
inv_data = {
|
||||
|
@ -1290,9 +1287,15 @@ class account_invoice(osv.Model):
|
|||
user_id = uid
|
||||
po_ids = purchase_order_obj.search(cr, user_id, [('invoice_ids', 'in', ids)], context=context)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for po_id in po_ids:
|
||||
for order in purchase_order_obj.browse(cr, uid, po_ids, context=context):
|
||||
# Signal purchase order workflow that an invoice has been validated.
|
||||
wf_service.trg_write(uid, 'purchase.order', po_id, cr)
|
||||
invoiced = []
|
||||
for po_line in order.order_line:
|
||||
if any(line.invoice_id.state not in ['draft', 'cancel'] for line in po_line.invoice_lines):
|
||||
invoiced.append(po_line.id)
|
||||
if invoiced:
|
||||
self.pool['purchase.order.line'].write(cr, uid, invoiced, {'invoiced': True})
|
||||
wf_service.trg_write(uid, 'purchase.order', order.id, cr)
|
||||
return res
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -111,7 +111,6 @@ class stock_picking(osv.osv):
|
|||
invoice_line_obj = self.pool.get('account.invoice.line')
|
||||
purchase_line_obj = self.pool.get('purchase.order.line')
|
||||
purchase_line_obj.write(cursor, user, [move_line.purchase_line_id.id], {
|
||||
'invoiced': True,
|
||||
'invoice_lines': [(4, invoice_line_id)],
|
||||
})
|
||||
return super(stock_picking, self)._invoice_line_hook(cursor, user, move_line, invoice_line_id)
|
||||
|
|
Loading…
Reference in New Issue