Como envio un email automaticamente a varios usuarios de las ventas diarias u otro reporte ??
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
1
Responder
673
Vistas
Hi,
By using the automated scheduled action, we can send the email at a particular interval of time. To achieve this, refer to the following
* https://www.cybrosys.com/blog/how-to-configure-automated-actions-in-odoo-18
* https://www.cybrosys.com/blog/how-to-configure-scheduled-actions-in-odoo-18
Try the following.
today = fields.Date.today()
start = datetime.combine(today, datetime.min.time())
end = datetime.combine(today, datetime.max.time())
# Get today's confirmed sales
orders = env['sale.order'].search([
('date_order', '>=', start),
('date_order', '<=', end),
('state', 'in', ['sale', 'done'])
])
total_sales = sum(orders.mapped('amount_total'))
order_count = len(orders)
# Prepare email content
subject = f"Daily Sales Report: {today.strftime('%Y-%m-%d')}"
body = f"""
Dear Team,<br/><br/>
Here is the sales summary for {today.strftime('%Y-%m-%d')}:<br/>
- Total Orders: {order_count}<br/>
- Total Sales: ${total_sales:.2f}<br/><br/>
Regards,<br/>
Odoo
"""
# Target recipients: user emails
user_emails = env['res.users'].search([('groups_id.name', '=', 'Sales')]).mapped('partner_id.email')
# Send emails
mail = env['mail.mail']
for email in user_emails:
if email:
mail.create({
'subject': subject,
'email_to': email,
'body_html': body,
}).send()
Hope it helps
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
1
ago 25
|
212 | ||
|
1
jul 25
|
675 | ||
|
2
jul 25
|
847 | ||
|
1
jul 25
|
701 | ||
|
2
jul 25
|
721 |