Community mailing list archives

community@mail.odoo.com

Re: Domain on one2many field doesn't work

by
Khaled Hamed
- 09/19/2016 11:24:17
As material_id would be a list , we can try to use operator 'in' instead of '=' 

material_lines = fields.One2many('mrp.bom.line','estimate_product','Components Required',domain="[(bom_id, 'in', material_id)]")

On Mon, Sep 19, 2016 at 5:18 PM, Mustafa Hamad <mustafajava@gmail.com> wrote:

Hello,

Well for a start I think you have an issue with quotes. Check product_tmpl_id and product_id.

All the best


On Sep 19, 2016 5:12 PM, "Albin John" <albinjohn54@gmail.com> wrote:

When add a domain on a one2many field this error happen 


Odoo Server Error
Traceback (most recent call last):
  File "/opt/odoo9c/odoo9c-server/openerp/http.py", line 646, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo9c/odoo9c-server/openerp/http.py", line 683, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo9c/odoo9c-server/openerp/http.py", line 319, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/http.py", line 312, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo9c/odoo9c-server/openerp/http.py", line 962, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo9c/odoo9c-server/openerp/http.py", line 512, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo9c/odoo9c-server/addons/web/controllers/main.py", line 837, in search_read
    return self.do_search_read(model, fields, offset, limit, domain, sort)
  File "/opt/odoo9c/odoo9c-server/addons/web/controllers/main.py", line 858, in do_search_read
    request.context)
  File "/opt/odoo9c/odoo9c-server/openerp/http.py", line 1067, in proxy
    result = meth(cr, request.uid, *args, **kw)
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/models.py", line 5276, in search_read
    result = self.read(cr, uid, record_ids, fields, context=read_ctx)
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/models.py", line 3193, in read
    result = BaseModel.read(records, fields, load=load)
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/models.py", line 3239, in read
    values[name] = field.convert_to_read(record[name], use_name_get)
  File "/opt/odoo9c/odoo9c-server/openerp/models.py", line 5740, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/opt/odoo9c/odoo9c-server/openerp/fields.py", line 829, in __get__
    self.determine_value(record)
  File "/opt/odoo9c/odoo9c-server/openerp/fields.py", line 936, in determine_value
    self.compute_value(recs)
  File "/opt/odoo9c/odoo9c-server/openerp/fields.py", line 891, in compute_value
    self._compute_value(records)
  File "/opt/odoo9c/odoo9c-server/openerp/fields.py", line 881, in _compute_value
    getattr(records, self.compute)()
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 425, in new_api
    result = [method(rec, *args, **kwargs) for rec in self]
  File "/home/albin/odoo9c/custom/addons/estimate_ construction_ project/models/project_estimation.py", line 32, in onchange_required_products_lines
    for material in line.material_lines:
  File "/opt/odoo9c/odoo9c-server/openerp/fields.py", line 829, in __get__
    self.determine_value(record)
  File "/opt/odoo9c/odoo9c-server/openerp/fields.py", line 927, in determine_value
    record._prefetch_field(self)
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/models.py", line 3298, in _prefetch_field
    result = records.read([f.name for f in fs], load='_classic_write')
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/models.py", line 3228, in read
    self._read_from_database(stored, inherited)
  File "/opt/odoo9c/odoo9c-server/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo9c/odoo9c-server/openerp/models.py", line 3419, in _read_from_database
    res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
  File "/opt/odoo9c/odoo9c-server/openerp/osv/fields.py", line 801, in get
    domain = domain + [(inverse, 'in', ids)]
TypeError: cannot concatenate 'str' and 'list' objects

My field is 
material_id = fields.Many2one('mrp.bom','Material',domain="[('product_tmpl_id', '=', product_id)]")
	
material_lines = fields.One2many('mrp.bom.line','estimate_product','Components Required',domain="[(bom_id, '=', material_id)]")

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Best regards...

Khaled Hamed Mostafa


http://www.grandtk.com