Skip to content

Commit

Permalink
Merge: manage holding currency on sales and leads
Browse files Browse the repository at this point in the history
BSRTL-199
  • Loading branch information
gurneyalex committed May 17, 2017
2 parents 6bc2b6d + 92949db commit 159cf8c
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Latest (unreleased)
**Features and Improvements**

* SO change validation button visibility/process given product_category
* SO & crm.lead holding_amount_currency in tree view. Can be used as measure
* Add module 'sale_company_currency'

**Bugfixes**

Expand Down
2 changes: 1 addition & 1 deletion odoo/external-src/sale-workflow
Submodule sale-workflow updated 421 files
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>
25 changes: 25 additions & 0 deletions odoo/local-src/specific_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ class SaleOrder(models.Model):
compute='_compute_validation_required',
readonly=True,
)
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 _setup_fields(self, partial):
Expand Down Expand Up @@ -139,6 +153,17 @@ def _compute_validation_required(self):
if (cat.process_validation_required and
not so.process_validation_id):
so.process_validation_required = True
@api.multi
@api.depends('amount_total', 'holding_currency_id')
def _compute_holding_currency_amount(self):
for so in self:
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)

@api.onchange('opportunity_id')
def onchange_opportunity_id(self):
Expand Down
24 changes: 24 additions & 0 deletions odoo/local-src/specific_sale/views/sale_order_crm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@
</field>
</record>

<record model="ir.ui.view" id="view_quotation_tree_holding">
<field name="name">sale.order.tree.holding</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="after">
<field name="holding_currency_id" invisible="True"/>
<field name="holding_currency_amount" widget="monetary" sum="Total"/>
</xpath>
</field>
</record>

<record model="ir.ui.view" id="view_order_tree_holding">
<field name="name">sale.order.tree.holding</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="after">
<field name="holding_currency_id" invisible="True"/>
<field name="holding_currency_amount" widget="monetary" sum="Total"/>
</xpath>
</field>
</record>

<record model="ir.ui.view" id="sale_margin_sale_order_line">
<field name="name">sale.order.line hide cost</field>
<field name="model">sale.order</field>
Expand Down
2 changes: 2 additions & 0 deletions odoo/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,6 @@ migration:
- version: 10.0.15
addons:
upgrade:
- sale_company_currency
- specific_crm
- specific_sale
2 changes: 2 additions & 0 deletions odoo/pending-merges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 159cf8c

Please sign in to comment.