简体   繁体   English

Odoo 版本 13:Email 摘要和 KPI

[英]Odoo version 13: Email digests & KPI's

I am trying to create a new KPI in the Digests model to show the number of new customers created per week.我正在尝试在 Digests model 中创建一个新的 KPI,以显示每周创建的新客户数量。 (Unfortunately, this functionality is not well documented). (不幸的是,这个功能没有很好的记录)。 As documented, I have created two fields in the digest model:如文件所述,我在摘要 model 中创建了两个字段:

x_studio_kpi_new_customers (Boolean) x_studio_kpi_new_customers_value (Integer) x_studio_kpi_new_customers (布尔) x_studio_kpi_new_customers_value (整数)

The value is值为

for record in self: 
    start, end, company = record._get_kpi_compute_parameters()
    record.x_studio_kpi_new_customers_value = sum(self.env['res.partner'].search([
            ('x_studio_when', '>=', start), 
            ('x_studio_when', '<', end)
    ]).mapped('x_studio_counter'))

x_studio_counter is just the value 1 in all records x_studio_when is the record creation date (have also tried with a datetime field) x_studio_counter 只是所有记录中的值 1 x_studio_when 是记录创建日期(也尝试过使用 datetime 字段)

I have also tried the code below:我也试过下面的代码:

for record in self:
    start, end, company = record._get_kpi_compute_parameters()
    new_customers = self.env['res.partner'].search_count([('x_studio_when', '>=', start), ('x_studio_when', '<', end)])
    record['x_studio_kpi_new_customers_value'] = new_customers

I keep getting 0.我一直得到0。

Any help will be appreciated.任何帮助将不胜感激。

In order to build your customized digest, follow these steps:为了构建您的自定义摘要,请按照下列步骤操作:

  1. You may want to add new computed fields with Odoo Studio:您可能希望使用 Odoo Studio 添加新的计算字段:

    You must create 2 fields on the digest object:您必须在摘要 object 上创建 2 个字段:

    • first create a boolean field called kpi_myfield and display it in the KPI's tab;首先创建一个名为 kpi_myfield 的 boolean 字段并将其显示在 KPI 的选项卡中;

    • then create a computed field called kpi_myfield_value that will compute your customized KPI.然后创建一个名为 kpi_myfield_value 的计算字段,它将计算您的自定义 KPI。

Create below "compute_kpis_actions" method and after that digest mail able to view count.在“compute_kpis_actions”方法下方创建,然后摘要邮件能够查看计数。

def compute_kpis_actions(self, company, user):
        res = super(Digest, self).compute_kpis_actions(company, user)
        res['x_studio_kpi_new_customers'] = 'your_module_name.your_action_name&menu_id=%s' % self.env.ref(your_module_name.your_menu_name').id
        return res

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM