Skip to Content
Menu
This question has been flagged
1983 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:

purchase_view.xml


<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<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)]}"/>
</xpath>
</field>
</record>
<!-- 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}"/>
</xpath>
</field>
</record>
<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>
</xpath>
</field>
</record>
</data>
</openerp>

purchase.py

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)

product_product()

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,
}


Thanks!



Avatar
Discard