| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
|
| 4 |
from odoo import fields, models, _ |
| 5 |
from odoo.exceptions import AccessError |
| 6 |
|
| 7 |
|
| 8 |
class DigestDigest(models.Model): |
| 9 |
_inherit = 'digest.digest' |
| 10 |
|
| 11 |
kpi_pos_total = fields.Boolean('POS Sales') |
| 12 |
kpi_pos_total_value = fields.Monetary(compute='_compute_kpi_pos_total_value') |
| 13 |
|
| 14 |
def _compute_kpi_pos_total_value(self): |
| 15 |
if not self.env.user.has_group('point_of_sale.group_pos_user'): |
| 16 |
raise AccessError(_("Do not have access, skip this data for user's digest email")) |
| 17 |
|
| 18 |
self._calculate_company_based_kpi( |
| 19 |
'pos.order', |
| 20 |
'kpi_pos_total_value', |
| 21 |
date_field='date_order', |
| 22 |
additional_domain=[('state', 'not in', ['draft', 'cancel']), ('account_move', '=', False)], |
| 23 |
sum_field='amount_total', |
| 24 |
) |
| 25 |
|
| 26 |
def _compute_kpis_actions(self, company, user): |
| 27 |
res = super()._compute_kpis_actions(company, user) |
| 28 |
res['kpi_pos_total'] = 'point_of_sale.action_pos_sale_graph?menu_id=%s' % self.env.ref('point_of_sale.menu_point_root').id |
| 29 |
return res |