تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1452 أدوات العرض

I need to add filters here dynamically based on a Many2one field. Whenever a new record is created on the linked model. It should be automatically added to the filters list. 

This couldn't be achieved by inheriting the search view for the model. As We are not allowed to iterate through all possible values for the many2one field dropdown.


I have found this function that loads the filters to the view. Now I need to save the filter to the db whenever the search view is loaded and use it.

patch(SearchBarMenu.prototype, {

    setup() {

        super.setup(...arguments);

        this.orm = useService("orm");

        this.state = useState({

            teams: {},

        });

        onWillStart(async () => {

            await this.orm.call('maintenance.team', 'get_teams').then((result) => {

                this.state.teams = result;

            }

            );

        });

    },

    

    // Filter Panel

    get filterItems() {

        return this.env.searchModel.getSearchItems((searchItem) =>

            ["filter", "dateFilter"].includes(searchItem.type)

        );

    },


############here in this function I need to return the new filter based on the records created on the many2one field.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
مارس 25
2664
2
أكتوبر 16
7623
2
يوليو 25
304
1
يناير 25
1222
1
سبتمبر 23
5645