diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6df6d8911d5..e591269f9c3 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -135,6 +135,15 @@ class purchase_order(osv.osv): result[line.order_id.id] = True return result.keys() + def _invoiced(self, cursor, user, ids, name, arg, context=None): + res = {} + for purchase in self.browse(cursor, user, ids, context=context): + if purchase.invoice_id.reconciled: + res[purchase.id] = purchase.invoice_id.reconciled + else: + res[purchase.id] = False + return res + _columns = { 'name': fields.char('Order Reference', size=64, required=True, select=True), 'origin': fields.char('Origin', size=64, @@ -163,7 +172,7 @@ class purchase_order(osv.osv): 'picking_ids': fields.one2many('stock.picking', 'purchase_id', 'Picking List', readonly=True, help="This is the list of picking list that have been generated for this purchase"), 'shipped':fields.boolean('Received', readonly=True, select=True), 'shipped_rate': fields.function(_shipped_rate, method=True, string='Received', type='float'), - 'invoiced':fields.boolean('Invoiced & Paid', readonly=True, select=True), + 'invoiced': fields.function(_invoiced, method=True, string='Invoiced & Paid', type='boolean'), 'invoiced_rate': fields.function(_invoiced_rate, method=True, string='Invoiced', type='float'), 'invoice_method': fields.selection([('manual','Manual'),('order','From Order'),('picking','From Picking')], 'Invoicing Control', required=True, help="From Order: a draft invoice will be pre-generated based on the purchase order. The accountant " \ diff --git a/addons/purchase/purchase_workflow.xml b/addons/purchase/purchase_workflow.xml index 2a3884739ed..26f83d5a554 100644 --- a/addons/purchase/purchase_workflow.xml +++ b/addons/purchase/purchase_workflow.xml @@ -55,7 +55,7 @@ invoice_done - write({'invoiced':1,'state':'approved'}) + write({'state':'approved'}) function diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index df74b52036a..11383b66b19 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -46,7 +46,7 @@ class stock_picking(osv.osv): _defaults = { 'purchase_id': lambda *a: False, } - + def get_currency_id(self, cursor, user, picking): if picking.purchase_id: return picking.purchase_id.pricelist_id.currency_id.id @@ -93,8 +93,7 @@ class stock_picking(osv.osv): def _invoice_hook(self, cursor, user, picking, invoice_id): purchase_obj = self.pool.get('purchase.order') if picking.purchase_id: - purchase_obj.write(cursor, user, [picking.purchase_id.id], {'invoiced':True, - 'invoice_id': invoice_id, + purchase_obj.write(cursor, user, [picking.purchase_id.id], {'invoice_id': invoice_id, }) return super(stock_picking, self)._invoice_hook(cursor, user, picking, invoice_id)