Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
12267 Представления
<record id="sale_order_seven_day_rule" model="ir.rule">
<field name="name">7 day Orders</field>
<field ref="sale.model_sale_order" name="model_id"/>
<field name="domain_force">[('create_date', '&lt;', (context_today() - datetime.timedelta(days=7)).strftime('%Y-%m-%d'))]</field>
<field name="groups" eval="[(4, ref('group_seven_day_user'))]"/>
</record>

this is not working
i want to show last 7 day records
Аватар
Отменить
Лучший ответ

Hello Usman,

Instead of creating filter you are creating record rule. Record rule is for the security purpose. 

To filter data you can simply create one search view and add filter for the model in your xml file. 

<record id="sale_order_view_search_inherit_quotation" model="ir.ui.view">

            <field name="name">sale.order.search.inherit.quotation</field>

            <field name="model">sale.order</field>

            <field name="mode">primary</field>

            <field name="inherit_id" ref="sale.view_sales_order_filter"/>

            <field name="arch" type="xml">

                <xpath expr="//filter[@name='my_quotation']" position="after">

                    <filter name="last_7_days" string="Last 7 Days" domain="[('date_order','&gt;', (context_today() - datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d') )]"/>

                </xpath>

            </field>

        </record>



Аватар
Отменить
Автор

thanks for your quick reply ...

can you tell me how i can assinge this filter to specific user group ..

i hav two group one can see all record one can see only 7 day record

how i can assinge this filter to one of group

You can not prevent users to see the records using filters, filter is just to use quick data filteration. To prevent users to showing records Record rule will be used, but make sure record rule will not allowed any user to see any other records then last 7 days who belongs to the speciific group.

In record rule, the domain is evaluated with two variables in context: user is the current user’s record and time is the time module. Check this link to perform operation

https://docs.python.org/2/library/time.html#module-time

Лучший ответ

datetime.datetime.now().strftime('%Y-%m-%d')

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
мар. 25
1369
0
нояб. 24
1552
0
июн. 24
1601
1
июн. 24
2113
0
окт. 23
2146