-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8595468
commit 8fa154b
Showing
8 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import models, fields | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = 'res.company' | ||
|
||
secondary_currency_id = fields.Many2one('res.currency') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import api, fields, models, tools | ||
from odoo.tools import float_compare, float_is_zero | ||
|
||
|
||
class StockValuationLayer(models.Model): | ||
|
||
_inherit = 'stock.valuation.layer' | ||
|
||
secondary_currency_id = fields.Many2one(related='company_id.secondary_currency_id') | ||
secondary_currency_unit_cost = fields.Monetary('Unit Value(SC)', compute='_compute_secondary_currency_amounts', currency_field='secondary_currency_id', compute_sudo=True) | ||
secondary_currency_value = fields.Monetary('Total Value (SC)', compute='_compute_secondary_currency_amounts', currency_field='secondary_currency_id', compute_sudo=True) | ||
secondary_currency_remaining_value = fields.Monetary('Remaining Value (SC)', compute='_compute_secondary_currency_amounts', currency_field='secondary_currency_id', compute_sudo=True) | ||
secondary_currency_price_diff_value = fields.Monetary('Invoice value correction with invoice currency (SC)', compute='_compute_secondary_currency_amounts', currency_field='secondary_currency_id', compute_sudo=True) | ||
|
||
@api.depends('secondary_currency_id', 'secondary_currency_unit_cost', 'secondary_currency_value', 'secondary_currency_remaining_value', 'secondary_currency_price_diff_value') | ||
def _compute_secondary_currency_amounts(self): | ||
# por performance usamos get_conversion_date en vez de convert, para pedirlo solo una vez porque la fecha es la misma | ||
with_secondary_currency = self.filtered('secondary_currency_id') | ||
(self - with_secondary_currency).secondary_currency_unit_cost = False | ||
(self - with_secondary_currency).secondary_currency_value = False | ||
(self - with_secondary_currency).secondary_currency_remaining_value = False | ||
(self - with_secondary_currency).secondary_currency_price_diff_value = False | ||
for rec in with_secondary_currency: | ||
rate = rec.currency_id._get_conversion_rate(rec.currency_id, rec.secondary_currency_id, rec.company_id, rec.create_date) | ||
rec.secondary_currency_unit_cost = rec.secondary_currency_id.round(rec.unit_cost * rate) if rec.unit_cost else 0.0 | ||
rec.secondary_currency_value = rec.secondary_currency_id.round(rec.value * rate) if rec.value else 0.0 | ||
rec.secondary_currency_remaining_value = rec.secondary_currency_id.round(rec.remaining_value * rate) if rec.remaining_value else 0.0 | ||
rec.secondary_currency_price_diff_value = rec.secondary_currency_id.round(rec.price_diff_value * rate) if rec.price_diff_value else 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<odoo> | ||
<record id="stock_valuation_layer_form" model="ir.ui.view"> | ||
<field name="name">stock.valuation.layer.form</field> | ||
<field name="model">stock.valuation.layer</field> | ||
<field name="inherit_id" ref="stock_account.stock_valuation_layer_form"/> | ||
<field name="arch" type="xml"> | ||
<notebook> | ||
<page string="Valuation" name="valuation"> | ||
<group groups="base.group_multi_currency"> | ||
<field name="secondary_currency_id" invisible="1"/> | ||
<field name="secondary_currency_unit_cost" /> | ||
<field name="secondary_currency_value" /> | ||
<field name="secondary_currency_remaining_value" /> | ||
<field name="secondary_currency_price_diff_value" /> | ||
</group> | ||
</page> | ||
</notebook> | ||
</field> | ||
</record> | ||
|
||
<record id="stock_valuation_layer_tree" model="ir.ui.view"> | ||
<field name="name">stock.valuation.layer.tree</field> | ||
<field name="model">stock.valuation.layer</field> | ||
<field name="inherit_id" ref="stock_account.stock_valuation_layer_tree"/> | ||
<field name="arch" type="xml"> | ||
<field name="unit_cost" position="after"> | ||
<field name="secondary_currency_id" invisible="1"/> | ||
<field name="secondary_currency_unit_cost" optional="hide" groups="base.group_multi_currency"/> | ||
</field> | ||
<field name="value" position="after"> | ||
<field name="secondary_currency_id" invisible="1"/> | ||
<field name="secondary_currency_value" optional="hide" groups="base.group_multi_currency"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<!-- reporting view --> | ||
<record id="stock_valuation_layer_report_tree" model="ir.ui.view"> | ||
<field name="name">stock.valuation.layer.report.tree</field> | ||
<field name="model">stock.valuation.layer</field> | ||
<field name="inherit_id" ref="stock_account.stock_valuation_layer_report_tree"/> | ||
<field name="arch" type="xml"> | ||
<field name="remaining_value" position="after"> | ||
<field name="secondary_currency_remaining_value" optional="hide" groups="base.group_multi_currency"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |