-
+
+
-
+
-
+
-
+
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 @@
-
-
+
+
-
+
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index ed7a2835425..9ba6c43a588 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -201,6 +201,7 @@ class sale_order(osv.osv):
help="""This field controls how invoice and delivery operations are synchronized.
- With 'Before Delivery', a draft invoice is created, and it must be paid before delivery."""),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="Pricelist for current sales order."),
+ 'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", readonly=True, required=True),
'project_id': fields.many2one('account.analytic.account', 'Contract/Analytic Account', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="The analytic account related to a sales order."),
'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
@@ -264,13 +265,18 @@ class sale_order(osv.osv):
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None):
- if (not pricelist_id) or (not order_lines):
+ if not pricelist_id:
return {}
+ value = {
+ 'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id
+ }
+ if not order_lines:
+ return {'value': value}
warning = {
'title': _('Pricelist Warning!'),
'message' : _('If you change the pricelist of this order (and eventually the currency), prices of existing order lines will not be updated.')
}
- return {'warning': warning}
+ return {'warning': warning, 'value': value}
def onchange_partner_id(self, cr, uid, ids, part):
if not part:
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index a9ebca876a9..8b89e8047cb 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -184,6 +184,7 @@
+
@@ -261,14 +262,14 @@
-
-
+
+
-
+
diff --git a/addons/sale_margin/sale_margin_view.xml b/addons/sale_margin/sale_margin_view.xml
index 69f49bd48ea..6aa34bae26c 100644
--- a/addons/sale_margin/sale_margin_view.xml
+++ b/addons/sale_margin/sale_margin_view.xml
@@ -11,7 +11,7 @@