Odoo Help


Issues With purchase_control_supplier Module (v7)

Alex Gallien
on 6/25/15, 5:29 PM 384 views

Hi All,

I had previously tested the purchase_control_supplier module in my test environment, and it seemed to work well, but now it does not appear to working in my new production environment. My production environment is on 7.0-20140804-231303, while my test environment is on 7.0-20131113-002526 - were there significant changes between those builds?

One thing I noticed is that the boolean field 'Control Supplier Search' wasn't showing up in the customer screen. Looking at the code I realized that the xpath //field[@name='customer'] pointed to an invisible 'customer' field in the new build that wasn't present in the old build. Switching that to //group/field[@name='customer'] fixed that issue. I am wondering if there is a problem with the search function now? The original xpath is:

<xpath expr="//field[@name='order_line']/tree/field['product_id']" position="replace"> 

Which did not appear to be loading. I changed that to

<xpath expr="//field['product_id']" position="replace">

And now I am getting an error "Error: Unknown field state in domain [["state","not in",["draft","sent"]]]". I don't see anything in the module referring to that domain though. I am really mystified here - does anyone know what is going on? I could really use the help. The full code of the module (unmodified) is:


<?xml version="1.0" encoding="UTF-8"?>
<record id="view_partner_form_joomla1" model="ir.ui.view">
<field name="name">res.partner.form.FC</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='customer']" position="after">
<field name="supplier_product_limit" attrs="{'invisible':[('supplier','!=',True)]}"/>
<!-- Purchase Order -->
<record id="purchase_order_form_fc" model="ir.ui.view">
<field name="name">purchase.order.form_FC</field>
<field name="model">purchase.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree/field['product_id']" position="replace">
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)" context="{'supplier_id': parent.partner_id}"/>
<record id="purchase_order_line_form_fc" model="ir.ui.view">
<field name="name">purchase.order.line.form_FC</field>
<field name="model">purchase.order.line</field>
<field name="inherit_id" ref="purchase.purchase_order_line_form"/>
<field name="arch" type="xml">
<xpath expr="//field['product_id']" position="attributes">
<attribute name="context">{'supplier_id': parent.partner_id}</attribute>


from osv import osv, fields
class product_product(osv.osv):
_name = "product.product"
_inherit = "product.product"

def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context and context.get('supplier_id', False):
product_limit = self.pool.get('res.partner').read(cr,uid,context['supplier_id'],['supplier_product_limit'])['supplier_product_limit']
if product_limit:
# ids = []
cr.execute("SELECT distinct(product_id) FROM product_supplierinfo where name = %s" % (context.get('supplier_id')))
ids = [x[0] for x in cr.fetchall()]
args.append(('id', 'in', ids))
order = 'default_code'
return super(product_product, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)


class res_partner(osv.osv):
_name = 'res.partner'
_inherit = 'res.partner'
_columns = {
'supplier_product_limit':fields.boolean("Control Supplier Search", help="""If checked, allows you to search only the product in this supplier )"""),
_defaults = {
'supplier_product_limit': True,


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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/25/15, 5:29 PM
Seen: 384 times
Last updated: 6/25/15, 5:29 PM