Skip to Content
Menu
This question has been flagged
1 Reply
4582 Views

Purchase order not going to DONE state

  • Purchase Order - *Invoice Received *Invoice Paid *Shipment Received *Invoicing Control: Based on Purchase Order lines

As noted here by others: launchpad: 1097633

How do I fix this?

Avatar
Discard
Author Best Answer

class account_invoice(osv.Model): """ Override account_invoice to add Chatter messages on the related purchase orders, logging the invoice reception or payment. """ _inherit = 'account.invoice'

def invoice_validate(self, cr, uid, ids, context=None):
    res = super(account_invoice, self).invoice_validate(cr, uid, ids, context=context)
    purchase_order_obj = self.pool.get('purchase.order')
    # read access on purchase.order object is not required
    if not purchase_order_obj.check_access_rights(cr, uid, 'read', raise_exception=False):
        user_id = SUPERUSER_ID
    else:
        user_id = uid
    po_ids = purchase_order_obj.search(cr, user_id, [('invoice_ids', 'in', ids)], context=context)
    for po_id in po_ids:
        purchase_order_obj.message_post(cr, user_id, po_id, body=_("Invoice received"), context=context)
        workflow.trg_write(uid, 'purchase.order', po_id, cr)
    return res

def confirm_paid(self, cr, uid, ids, context=None):
    res = super(account_invoice, self).confirm_paid(cr, uid, ids, context=context)
    purchase_order_obj = self.pool.get('purchase.order')
    # read access on purchase.order object is not required
    if not purchase_order_obj.check_access_rights(cr, uid, 'read', raise_exception=False):
        user_id = SUPERUSER_ID
    else:
        user_id = uid
    po_ids = purchase_order_obj.search(cr, user_id, [('invoice_ids', 'in', ids)], context=context)
    for po_id in po_ids:
        purchase_order_obj.message_post(cr, user_id, po_id, body=_("Invoice paid"), context=context)
    return res

class account_invoice_line(osv.Model): """ Override account_invoice_line to add the link to the purchase order line it is related to""" _inherit = 'account.invoice.line' _columns = { 'purchase_line_id': fields.many2one('purchase.order.line', 'Purchase Order Line', ondelete='set null', select=True, readonly=True), }

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 23
1846
2
May 25
1954
1
Apr 25
846
1
Apr 25
961
3
Dec 24
5922