Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

<BUG> Purchase Order not going to DONE state?

By
Damian Phang
on 1/27/14, 10:34 AM 1,300 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?

0
Damian Phang
On 2/3/14, 1:42 PM

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), }

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 1/27/14, 10:34 AM
Seen: 1300 times
Last updated: 3/16/15, 8:10 AM