[IMP] crm: add prorated recurring revenue in forecast view
Purpose: In the Forecast view of the CRM module, when recurring revenues are activated, they are not shown in the progress bar of each stage of the kanban view. Only the prorated expected revenue (non-recurring) are shown. In the regular kanban view, they are shown. To display them, we extended the CrmKanban view, which already possesses this behavior, since behaviors relevant to the CrmKanban view are also relevant to the ForecastKanban view. As for the forecast kanban cards, when recurring revenues are activated, they show "regular" recurring revenues instead of "prorated" recurring revenues. Expected revenues are prorated. This is misleading for users. The goal is to show prorated recurring revenues instead of just recurring revenues. Task-2994146 Task-3006404 closes odoo/odoo#102037 Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
This commit is contained in:
@@ -154,6 +154,8 @@ class Lead(models.Model):
|
||||
compute="_compute_recurring_revenue_monthly")
|
||||
recurring_revenue_monthly_prorated = fields.Monetary('Prorated MRR', currency_field='company_currency', store=True,
|
||||
compute="_compute_recurring_revenue_monthly_prorated")
|
||||
recurring_revenue_prorated = fields.Monetary('Prorated Recurring Revenues', currency_field='company_currency',
|
||||
compute="_compute_recurring_revenue_prorated", store=True)
|
||||
company_currency = fields.Many2one("res.currency", string='Currency', compute="_compute_company_currency", compute_sudo=True)
|
||||
# Dates
|
||||
date_closed = fields.Datetime('Closed Date', readonly=True, copy=False)
|
||||
@@ -511,6 +513,11 @@ class Lead(models.Model):
|
||||
for lead in self:
|
||||
lead.recurring_revenue_monthly_prorated = (lead.recurring_revenue_monthly or 0.0) * (lead.probability or 0) / 100.0
|
||||
|
||||
@api.depends('recurring_revenue', 'probability')
|
||||
def _compute_recurring_revenue_prorated(self):
|
||||
for lead in self:
|
||||
lead.recurring_revenue_prorated = (lead.recurring_revenue or 0.0) * (lead.probability or 0) / 100.0
|
||||
|
||||
def _compute_calendar_event_count(self):
|
||||
if self.ids:
|
||||
meeting_data = self.env['calendar.event'].sudo()._read_group([
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { KanbanModel } from "@web/views/kanban/kanban_model";
|
||||
import { CrmKanbanModel, CrmKanbanGroup } from "@crm/views/crm_kanban/crm_kanban_model";
|
||||
|
||||
export class ForecastKanbanModel extends KanbanModel {
|
||||
export class ForecastKanbanModel extends CrmKanbanModel {
|
||||
setup(params, { fillTemporalService }) {
|
||||
super.setup(...arguments);
|
||||
this.fillTemporalService = fillTemporalService;
|
||||
@@ -100,5 +100,6 @@ export class ForecastKanbanDynamicGroupList extends ForecastKanbanModel.DynamicG
|
||||
}
|
||||
}
|
||||
|
||||
ForecastKanbanModel.services = [...KanbanModel.services, "fillTemporalService"];
|
||||
ForecastKanbanModel.services = [...CrmKanbanModel.services, "fillTemporalService"];
|
||||
ForecastKanbanModel.DynamicGroupList = ForecastKanbanDynamicGroupList;
|
||||
ForecastKanbanModel.group = CrmKanbanGroup;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { CrmKanbanRenderer } from "@crm/views/crm_kanban/crm_kanban_renderer";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { KanbanRenderer } from "@web/views/kanban/kanban_renderer";
|
||||
import { ForecastKanbanColumnQuickCreate } from "@crm/views/forecast_kanban/forecast_kanban_column_quick_create";
|
||||
import { INTERVAL_OPTIONS } from "@web/search/utils/dates";
|
||||
|
||||
export class ForecastKanbanRenderer extends KanbanRenderer {
|
||||
export class ForecastKanbanRenderer extends CrmKanbanRenderer {
|
||||
setup() {
|
||||
super.setup(...arguments);
|
||||
this.fillTemporalService = useService("fillTemporalService");
|
||||
@@ -51,6 +51,6 @@ export class ForecastKanbanRenderer extends KanbanRenderer {
|
||||
|
||||
ForecastKanbanRenderer.template = "crm.ForecastKanbanRenderer";
|
||||
ForecastKanbanRenderer.components = {
|
||||
...KanbanRenderer.components,
|
||||
...CrmKanbanRenderer.components,
|
||||
ForecastKanbanColumnQuickCreate,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates>
|
||||
<t t-name="crm.ForecastKanbanRenderer" t-inherit="web.KanbanRenderer" t-inherit-mode="primary" owl="1">
|
||||
<t t-name="crm.ForecastKanbanRenderer" t-inherit="crm.CrmKanbanRenderer" t-inherit-mode="primary" owl="1">
|
||||
<KanbanColumnQuickCreate position="replace">
|
||||
<t t-if="isGroupedByForecastField()">
|
||||
<ForecastKanbanColumnQuickCreate
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { CrmKanbanArchParser } from "@crm/views/crm_kanban/crm_kanban_arch_parser";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { kanbanView } from "@web/views/kanban/kanban_view";
|
||||
import { ForecastKanbanRenderer } from "@crm/views/forecast_kanban/forecast_kanban_renderer";
|
||||
@@ -8,6 +9,7 @@ import { ForecastKanbanModel } from "@crm/views/forecast_kanban/forecast_kanban_
|
||||
|
||||
export const forecastKanbanView = {
|
||||
...kanbanView,
|
||||
ArchParser: CrmKanbanArchParser,
|
||||
Model: ForecastKanbanModel,
|
||||
Renderer: ForecastKanbanRenderer,
|
||||
SearchModel: ForecastSearchModel,
|
||||
|
||||
@@ -579,7 +579,7 @@
|
||||
<span t-if="record.recurring_revenue and record.recurring_revenue.raw_value" groups="crm.group_use_recurring_revenues"> + </span>
|
||||
</t>
|
||||
<t t-if="record.recurring_revenue and record.recurring_revenue.raw_value">
|
||||
<field name="recurring_revenue" widget="monetary" options="{'currency_field': 'company_currency'}" groups="crm.group_use_recurring_revenues"/>
|
||||
<field class="me-1" name="recurring_revenue" widget="monetary" options="{'currency_field': 'company_currency'}" groups="crm.group_use_recurring_revenues"/>
|
||||
<field name="recurring_plan" groups="crm.group_use_recurring_revenues"/>
|
||||
</t>
|
||||
</div>
|
||||
@@ -625,9 +625,14 @@
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='expected_revenue']" position="replace">
|
||||
<field name="prorated_revenue"/>
|
||||
<field name="recurring_revenue"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='recurring_revenue_monthly']" position="replace">
|
||||
<field name="recurring_revenue_monthly_prorated"/>
|
||||
</xpath>
|
||||
<xpath expr="//progressbar" position="attributes">
|
||||
<attribute name="sum_field">prorated_revenue</attribute>
|
||||
<attribute name="recurring_revenue_sum_field">recurring_revenue_monthly_prorated</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//t[@t-set='lost_ribbon']" position="after">
|
||||
<t t-set="won_ribbon" t-value="record.active.raw_value and record.probability and record.probability.raw_value == 100"/>
|
||||
@@ -654,7 +659,7 @@
|
||||
<span t-if="record.recurring_revenue and record.recurring_revenue.raw_value" groups="crm.group_use_recurring_revenues"> + </span>
|
||||
</t>
|
||||
<t t-if="record.recurring_revenue and record.recurring_revenue.raw_value">
|
||||
<field name="recurring_revenue" widget="monetary" options="{'currency_field': 'company_currency'}" groups="crm.group_use_recurring_revenues"/>
|
||||
<field class="me-1" name="recurring_revenue_prorated" widget="monetary" options="{'currency_field': 'company_currency'}" groups="crm.group_use_recurring_revenues"/>
|
||||
<field name="recurring_plan" groups="crm.group_use_recurring_revenues"/>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user