0
votes

In product template, I have defined this structure to be able of searching by model and range of application years.

In this example, using the search box,typing SENTRA as model paramater AND 1998 as year of application, should not bring any record, but it does.

It seems like my search is done fetching all my one2many field and not only the first row.

application data odoo

Here is the code:

<field string="Modelo" name="application_data_product_template_ids" filter_domain="[('application_data_product_template_ids.model', 'ilike',self)]"/>
<field name="date_search" />

def _search_year(self, cr, uid, obj, name, args, context):
    x = [('application_data_product_template_ids.date_beg', '<=', args[0][2]), ('application_data_product_template_ids.dateend', '>=', args[0][2])]
    res = self.search(cr, uid, x, context=context)
    return [('id', 'in', res)]

Is there a way to do this search correctly?

1

1 Answers

0
votes

Put a separator between search fields, otherwise it ORs them:

<field string="Modelo" name="application_data_product_template_ids" .../>
<separator/>
<field name="date_search" />