From 155680a15871af3f06abaa461c7e531c1f2adc8d Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 10 Oct 2012 13:20:13 +0200 Subject: [PATCH] [IMP] purchase: added monetary widget on purchase order form view bzr revid: qdp-launchpad@openerp.com-20121010112013-d6z1iq6hpjgdle63 --- addons/purchase/purchase.py | 6 ++++++ addons/purchase/purchase_view.xml | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index d654078a055..c0516d09de3 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -166,6 +166,7 @@ class purchase_order(osv.osv): 'warehouse_id': fields.many2one('stock.warehouse', 'Destination Warehouse', states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}), 'location_id': fields.many2one('stock.location', 'Destination', required=True, domain=[('usage','<>','view')]), 'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, help="The pricelist sets the currency used for this purchase order. It also computes the supplier price for the selected products/quantities."), + 'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", readonly=True, required=True), 'state': fields.selection(STATE_SELECTION, 'Status', readonly=True, help="The state of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' state. Then the order has to be confirmed by the user, the state switch to 'Confirmed'. Then the supplier must confirm the order to change the state to 'Approved'. When the purchase order is paid and received, the state becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the state becomes in exception.", select=True), 'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines', states={'approved':[('readonly',True)],'done':[('readonly',True)]}), 'validator' : fields.many2one('res.users', 'Validated by', readonly=True), @@ -246,6 +247,11 @@ class purchase_order(osv.osv): def button_dummy(self, cr, uid, ids, context=None): return True + def onchange_pricelist(self, cr, uid, ids, pricelist_id, context=None): + if not pricelist_id: + return {} + return {'value': {'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id}} + def onchange_dest_address_id(self, cr, uid, ids, address_id): if not address_id: return {} diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index bfff06f5eaf..446c17578cb 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -223,7 +223,8 @@ - + + @@ -249,14 +250,14 @@ - - + + - +