Domain for one2many not working Odoo
11,782
Solution 1
I also faced this problem, and the solution is put domain in .py file, in .xml domain is not working properly.
import_transaction_log_ids = fields.One2many(comodel_name = 'transaction.log','sale_order_id', string = 'Import Transaction Log',domain=[('operation_type','=','import')])
in example operation_type
field is in transaction.log
model.
Solution 2
Write domain in end_date field, like this:
<field name="record_ids" >
<tree string="records_tree">
<field name="record_id"/>
<field name="record"/>
<field name="start_date"/>
<field name="end_date" domain="[('end_date', '>', cur_date)]"/>
</tree>
</field>
i think it will help you..
Author by
javatar
Updated on June 14, 2022Comments
-
javatar almost 2 years
In my module I want to filter one2many records based on current date. This is my xml code
<field name="record_ids" domain="[('end_date', '>', cur_date)]"> <tree string="records_tree"> <field name="record_id"/> <field name="record"/> <field name="start_date"/> <field name="end_date"/> </tree> </field>
cur_date is a functional field I added to get current date.
My problem is records are not filtered in the view. Also it doesn't show any error message
-
javatar almost 9 yearsthanks. can you suggest a method to provide current date as the value?
-
Abdul wahid almost 9 yearsi dont know it works... make a date field in your model and then call that field in your domain filter as 'model rec.date_field_name'..u will get the date in that field
-
DASADIYA CHAITANYA almost 9 years@Abdulwahid they want the solution of that Query(Question) not the syntax of domain,how to apply domain in one2many fields.
-
DASADIYA CHAITANYA almost 9 yearsokey no issue but try to understand the proper question and then after you should apply for your answer
-
DASADIYA CHAITANYA almost 9 yearsIf your answer may not sure or not correct then just make comment on that question nothing else