Skip to content

Commit

Permalink
Add base for crm.lead holding_amount_currency
Browse files Browse the repository at this point in the history
  • Loading branch information
leemannd committed May 16, 2017
1 parent c0573a6 commit 92949db
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
22 changes: 22 additions & 0 deletions odoo/local-src/specific_crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions odoo/local-src/specific_crm/views/crm_lead_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@

</field>
</record>

<record id="crm_case_tree_view_oppor_roctool" model="ir.ui.view">
<field name="name">crm.lead.tree.opportunity.holding</field>
<field name="model">crm.lead</field>
<field name="priority">20</field>
<field name="inherit_id" ref="crm.crm_case_tree_view_oppor"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='planned_revenue']" position="after">
<field name="holding_currency_id" invisible="True"/>
<field name="holding_currency_amount" widget="monetary" sum="Total"/>
</xpath>
</field>
</record>

</odoo>
2 changes: 2 additions & 0 deletions odoo/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,5 @@ migration:
addons:
upgrade:
- sale_company_currency
- specific_sale
- specific_crm

0 comments on commit 92949db

Please sign in to comment.