Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3546 Lượt xem

Hi,


On Sales/Orders/Quotation I want to use domain to allow salepeople to:


  • See every quotation in 'draft', 'sent' and 'waiting'

  • See quotations in 'sale' or 'done' ONLY if these quotation were sold this month (date_oder = current month)


I know I have to use Domain, but I don't know how to write the code for current month.

How can I do that?



Ảnh đại diện
Huỷ bỏ

Hi,

The below answer is correct and you can replace create_date with date_order. And for your requirement to view quotations in 'sale' or 'done' in current month you can group by status.

Câu trả lời hay nhất

Hi Hugo Amaro,

Use this filter in the search view to show records created in the current month.

 <filter string="This Month" name="this_month" domain="[('create_date','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')), ('create_date','&gt;=',time.strftime('%%Y-%%m-01'))]"/>

Hope it helps,

Kiran


Ảnh đại diện
Huỷ bỏ
Tác giả

Your solution works, but I did not understand how to limit the "data filtering" only to when ('state', 'in', ( 'sale', 'done' ))

Tác giả Câu trả lời hay nhất

I've spent the past 3 hours trying to learn Polish Notation to understand Kiran Mohan's answer but I still failed to apply his solution ONLY to 'state', 'in', ( 'sale', 'done' )


Please help, I have no idea of what am I doing wrong...

<xpath expr="//filter[@name='my_sale_orders_filter']" position="replace">
<filter string="This Month"
name="this_month"
domain="[
'|',
('state', 'in', ('draft', 'sent', 'waiting')),
('state', 'in', ('sale','done')),
('create_date','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')),
('create_date','&gt;=',time.strftime('%%Y-%%m-01'))
]"
/>
</xpath>

Note: I'm altering stright from odoo and not inheriting it - http://localhost:8069/web#id=820&model=ir.ui.view&view_type=form&cids=&menu_id=4



Ảnh đại diện
Huỷ bỏ

<filter string="This Month" name="this_month" domain="[('create_date','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')), ('create_date','&gt;=',time.strftime('%%Y-%%m-01')),('state','in',('sale','done'))]"/>