Python Don';不允许在openerp中报价低于产品的销售价格

Python Don';不允许在openerp中报价低于产品的销售价格,python,xml,openerp-7,Python,Xml,Openerp 7,当我们向客户报价时,不允许用户报价低于产品的销售价格。我们如何才能做到这一点?请帮帮我。我正在使用v7。。提前感谢调用视图xml中的price\u unit字段的函数 <xpath expr="//field[@name='price_unit']" position="attributes"> <attribute name="on_change">check_margin(product_id,price_unit)</attribute> <

当我们向客户报价时,不允许用户报价低于产品的销售价格。我们如何才能做到这一点?请帮帮我。我正在使用v7。。提前感谢

调用视图xml中的
price\u unit
字段的函数

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

检查保证金(产品id、价格单位)
在类中,定义处理它的函数

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:
     pass
  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}}
     pass
  return {'value': res.get('value'), 'warning':warning}
def检查保证金(自身、cr、uid、id、产品id、单价、上下文=无):
res={}
警告={}
售价=无
如果产品标识为:
sale\u price=self.pool.get('product.product')。浏览(cr、uid、product\u id)。列出价格
如果单价为无:
通过
elif单价<售价:
警告={
“标题”:(“警告”),
“消息”:(“给出的单价低于所选产品的销售价格。请更改(或联系您的销售经理更改)所选产品的销售价格。”),
}
res={'value':{'price_unit':sale_price}
elif单价>=销售价格:
res={'value':{'price_unit':unit_price}
通过
返回{'value':res.get('value'),'warning':warning}

感谢您发布问题的解决方案。我们需要更多这样的东西。但是,您能否提供找到类的文件的一些详细信息以及您使用的视图的名称?很高兴为您提供帮助。。首先,我们将转到关于Openerp->激活开发人员模式。然后转到“销售”下的报价表。在那里,您可以看到什么是数据库字段、表等,以及itedit form view->external id中xml视图文件的名称提供了视图id,而view fields将提供数据库字段和表的详细信息。我建议,不要在源代码上编辑,为此创建一个单独的模块。