From 50063d628017b70cb10e73522e2f40826b9b701b Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 16 May 2017 08:53:46 +0200 Subject: [PATCH 1/5] Base for SO in holing_currency --- .../specific_sale/models/sale_order.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/odoo/local-src/specific_sale/models/sale_order.py b/odoo/local-src/specific_sale/models/sale_order.py index 01d25d2fbad..dd7b228c05b 100644 --- a/odoo/local-src/specific_sale/models/sale_order.py +++ b/odoo/local-src/specific_sale/models/sale_order.py @@ -54,6 +54,20 @@ class SaleOrder(models.Model): 'cancel': [('required', False)]} ) sales_condition_filename = fields.Char() + 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, + store=True, + currency_field='holding_currency_id' + ) @api.model def _setup_fields(self, partial): @@ -104,6 +118,24 @@ def _create_analytic_account(self, prefix=None): 'project_market_id': order.project_market_id.id} ) + @api.multi + @api.depends('amount_total', 'pricelist_id.currency_id', + 'holding_currency_id') + def _compute_holding_currency_amount(self): + for so in self: + print so.holding_currency_id.name + if so.state in ('sale', 'done'): + so_date = so.confirmation_date + else: + so_date = so.date_order + so.holding_currency_amount = so.currency_id.with_context( + date=so_date).compute( + so.amount_total, so.holding_currency_id) + ## ---> Set BreakPoint + import pdb; + pdb.set_trace() + print so.holding_currency_amount + @api.onchange('opportunity_id') def onchange_opportunity_id(self): if self.opportunity_id: From cc42440a3965940bb74527a41e103b8b150bf257 Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 16 May 2017 13:52:40 +0200 Subject: [PATCH 2/5] Add & install OCA 'sale_company_currency' --- odoo/external-src/sale-workflow | 2 +- odoo/migration.yml | 4 ++++ odoo/pending-merges.yaml | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/odoo/external-src/sale-workflow b/odoo/external-src/sale-workflow index 14391cb3932..6865da6239d 160000 --- a/odoo/external-src/sale-workflow +++ b/odoo/external-src/sale-workflow @@ -1 +1 @@ -Subproject commit 14391cb3932efc8d8295c37dc19200950918c271 +Subproject commit 6865da6239d8cf54cecbaaac54cf76cba9fdc1bd diff --git a/odoo/migration.yml b/odoo/migration.yml index b3bd1b2f117..c96db7489c8 100644 --- a/odoo/migration.yml +++ b/odoo/migration.yml @@ -178,3 +178,7 @@ migration: operations: post: - anthem songs.upgrade.10_0_14.intercompany::main + - version: 10.0.15 + addons: + upgrade: + - sale_company_currency diff --git a/odoo/pending-merges.yaml b/odoo/pending-merges.yaml index 996e5c4ba5b..38ef74e5bd8 100644 --- a/odoo/pending-merges.yaml +++ b/odoo/pending-merges.yaml @@ -23,6 +23,8 @@ - oca refs/pull/440/head # # port of account_statement_base_import # - oca refs/pull/137/head + # new module sale_company_currency + - oca refs/pull/425/head target: *default_target ./external-src/hr: remotes: From 1f8a7143652aa00e63e677cb15b9fd16ce8b41dc Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 16 May 2017 13:59:31 +0200 Subject: [PATCH 3/5] fix lambda currency --- odoo/local-src/specific_sale/models/sale_order.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/odoo/local-src/specific_sale/models/sale_order.py b/odoo/local-src/specific_sale/models/sale_order.py index dd7b228c05b..cecf0a3ef51 100644 --- a/odoo/local-src/specific_sale/models/sale_order.py +++ b/odoo/local-src/specific_sale/models/sale_order.py @@ -58,7 +58,7 @@ class SaleOrder(models.Model): 'res.currency', string='Holding Currency', required=True, - default=lambda self: self.env.ref['base.EUR'], + default=lambda self: self.env.ref('base.EUR'), readonly=True, ) holding_currency_amount = fields.Monetary( @@ -131,10 +131,6 @@ def _compute_holding_currency_amount(self): so.holding_currency_amount = so.currency_id.with_context( date=so_date).compute( so.amount_total, so.holding_currency_id) - ## ---> Set BreakPoint - import pdb; - pdb.set_trace() - print so.holding_currency_amount @api.onchange('opportunity_id') def onchange_opportunity_id(self): From c0573a62b71e4459a95d94f9d8e402736bfb52f5 Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 16 May 2017 14:46:31 +0200 Subject: [PATCH 4/5] base for SO holding_amount --- .../specific_sale/models/sale_order.py | 6 ++--- .../specific_sale/views/sale_order_crm.xml | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/odoo/local-src/specific_sale/models/sale_order.py b/odoo/local-src/specific_sale/models/sale_order.py index cecf0a3ef51..6a45cc2bb17 100644 --- a/odoo/local-src/specific_sale/models/sale_order.py +++ b/odoo/local-src/specific_sale/models/sale_order.py @@ -65,8 +65,8 @@ class SaleOrder(models.Model): string='Holding Currency Amount', compute='_compute_holding_currency_amount', readonly=True, + currency_field='holding_currency_id', store=True, - currency_field='holding_currency_id' ) @api.model @@ -119,11 +119,9 @@ def _create_analytic_account(self, prefix=None): ) @api.multi - @api.depends('amount_total', 'pricelist_id.currency_id', - 'holding_currency_id') + @api.depends('amount_total', 'holding_currency_id') def _compute_holding_currency_amount(self): for so in self: - print so.holding_currency_id.name if so.state in ('sale', 'done'): so_date = so.confirmation_date else: diff --git a/odoo/local-src/specific_sale/views/sale_order_crm.xml b/odoo/local-src/specific_sale/views/sale_order_crm.xml index 557ab14e337..5a890f03190 100644 --- a/odoo/local-src/specific_sale/views/sale_order_crm.xml +++ b/odoo/local-src/specific_sale/views/sale_order_crm.xml @@ -90,6 +90,30 @@ + + sale.order.tree.holding + sale.order + + + + + + + + + + + sale.order.tree.holding + sale.order + + + + + + + + + sale.order.line hide cost sale.order From 92949db7832c0a6b2717eac7ce43c515500fbab6 Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 16 May 2017 16:10:27 +0200 Subject: [PATCH 5/5] 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