Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
4587 Vistas

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
Descartar
Autor Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
ene 23
1851
2
may 25
1996
1
abr 25
851
1
abr 25
972
3
dic 24
5956