Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
5075 Представления

I want to receive a cron email with filtered customers meeting certain criteria in Odoo 13. 

Specifically as an example, if I go to res.partner in a list view I will see all the customers in the database, then I can filter a field (say the state) and see all the records meeting the criteria. I want to send that filtered list in a regular basis by email. 

My idea is to create a Template (everything through Odoo UI not Python coding), then set a scheduled job to send the email template in a regular basis.

My main challenge is to create the template in order to email the list view, a data export or whatever other option to receive that filtered info in a daily basis in my mailbox (regardless of the format, as text in the message body, as an attachment like PDF, CSV or XLS).

I am not a developer so I don't want to use Pycharm, etc but use Odoo UI and paste the code there.

So far I have been able to create a Qweb report with the filtered data but only works as long as I manually select (tick) all the records (ids) at the Res.partner tree view and after that click on "Print" and then select the report. It works the way I need it except for the need to manually have all the records ticked (active_ids). I believe t-foreach="docs" is only considering the active_ids and not all the database partners.

My question is: How can I have the report look at all the partners in the database without having to select them myself so that when I visit http://<serveraddress>/report/html/res_partner.report_imprerespartner the report is not blank?

The Qweb view that currently works (given the manual pre-selection of all the records) is:  <?xml version="1.0"?>   <t t-name="report_imprerespartner">     <t t-call="web.html_container">       <t t-call="web.external_layout">         <t t-foreach="docs" t-as="o">                       <span t-if=“o.x_campo == 'pedido'">                         <p>Notes: <span t-esc="o.comment" /></p>                       </span>             </t>         </t>     </t> </t>   

Аватар
Отменить
Лучший ответ

Hi Eduardo:

You can customize the report view and add the following before the <t t-foreach="docs" t-as="o"> line.

<t t-set="docs" t-value="env['res.partner'].search([])"/>

This will select all the partners every time the report is run irrespective of whether records are selected or not.

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

@Paresh Thank you, Spent lots of time trying to find a way to do it and your suggestion works perfect!!. Appreciate it so much. Already upvoted.

Related Posts Ответы Просмотры Активность
1
авг. 23
1140
3
сент. 19
5163
1
янв. 20
5484
5
сент. 19
4479
2
дек. 21
4949