Odoo Help


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.


Don't allow to quote below the sales price of a product?

on 4/29/14, 6:04 AM 880 views

While we make quotations to customers, don't allow users to quote below the sales price of products. How can we achieve this? Please help me. Am using v7.. Thanks in advance

On 5/13/14, 9:26 AM

Call the function for the field price_unit in the view xml

<xpath expr="//field[@name='price_unit']" position="attributes">
   <attribute name="on_change">check_margin(product_id,price_unit)</attribute>

and in the class, define the function to process it.

def check_margin(self, cr, uid, ids, product_id, unit_price, context=None):
  res = {}
  warning = {}
  sale_price = None
  if product_id:
     sale_price = self.pool.get('product.product').browse(cr, uid,product_id).list_price
  if unit_price is None:
  elif unit_price < sale_price:
     warning = {  
       'title': _("Warning"),  
       'message': _('Unit price given, is less than the sales price of the selected product. Please change (or contact your sales manager to change) the sales price of the selected product.'),  
     res = {'value': {'price_unit':sale_price}}
  elif unit_price >= sale_price:
     res = {'value': {'price_unit':unit_price}}
  return {'value': res.get('value'), 'warning':warning}

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

1 follower(s)


Asked: 4/29/14, 6:04 AM
Seen: 880 times
Last updated: 3/16/15, 8:10 AM