From 92949db7832c0a6b2717eac7ce43c515500fbab6 Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 16 May 2017 16:10:27 +0200 Subject: [PATCH] Add base for crm.lead holding_amount_currency --- HISTORY.rst | 3 +++ .../local-src/specific_crm/models/crm_lead.py | 22 +++++++++++++++++++ .../specific_crm/views/crm_lead_view.xml | 14 ++++++++++++ odoo/migration.yml | 2 ++ 4 files changed, 41 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 11eed81c58c..7031f8130ad 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -22,6 +22,9 @@ Latest (unreleased) **Features and Improvements** +* SO & crm.lead holding_amount_currency in tree view. Can be used as measure +* Add module 'sale_company_currency' + **Bugfixes** **Build** diff --git a/odoo/local-src/specific_crm/models/crm_lead.py b/odoo/local-src/specific_crm/models/crm_lead.py index 83dbbf4e75f..9c2c9e27a5d 100644 --- a/odoo/local-src/specific_crm/models/crm_lead.py +++ b/odoo/local-src/specific_crm/models/crm_lead.py @@ -53,6 +53,20 @@ class CrmLead(models.Model): index=True, track_visibility='onchange', ) + holding_currency_id = fields.Many2one( + 'res.currency', + string='Holding Currency', + required=True, + default=lambda self: self.env.ref('base.EUR'), + readonly=True, + ) + holding_currency_amount = fields.Monetary( + string='Holding Currency Amount', + compute='_compute_holding_currency_amount', + readonly=True, + currency_field='holding_currency_id', + store=True, + ) @api.model def _message_get_auto_subscribe_fields(self, updated_fields, @@ -68,6 +82,14 @@ def _message_get_auto_subscribe_fields(self, updated_fields, auto_follow_fields=list(auto_follow_fields), ) + @api.multi + @api.depends('planned_revenue', 'holding_currency_id') + def _compute_holding_currency_amount(self): + for lead in self: + lead.holding_currency_amount = lead.company_currency.with_context( + date=lead.date_action_last).compute( + lead.planned_revenue, lead.holding_currency_id) + @api.onchange('team_id') def onchange_team_id(self): if self.team_id: diff --git a/odoo/local-src/specific_crm/views/crm_lead_view.xml b/odoo/local-src/specific_crm/views/crm_lead_view.xml index 73744f50507..459c43a9354 100644 --- a/odoo/local-src/specific_crm/views/crm_lead_view.xml +++ b/odoo/local-src/specific_crm/views/crm_lead_view.xml @@ -55,4 +55,18 @@ + + + crm.lead.tree.opportunity.holding + crm.lead + 20 + + + + + + + + + diff --git a/odoo/migration.yml b/odoo/migration.yml index c96db7489c8..d1e5386e858 100644 --- a/odoo/migration.yml +++ b/odoo/migration.yml @@ -182,3 +182,5 @@ migration: addons: upgrade: - sale_company_currency + - specific_sale + - specific_crm