mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX]account_spread_cost_revenue: Total amount different currency
This commit is contained in:
@@ -203,6 +203,7 @@ Contributors
|
||||
* Andrea Stirpe <a.stirpe@onestein.nl>
|
||||
* Kitti U. <kittiu@ecosoft.co.th>
|
||||
* Saran Lim. <saranl@ecosoft.co.th>
|
||||
* Manuel Regidor <manuel.regidor@sygel.es>
|
||||
|
||||
Other credits
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@@ -191,7 +191,7 @@ class AccountSpread(models.Model):
|
||||
posted_amount = sum(spread_line.amount for spread_line in lines_posted)
|
||||
total_amount = spread.estimated_amount
|
||||
if spread.invoice_line_id:
|
||||
total_amount = spread.invoice_line_id.currency_id._convert(
|
||||
total_amount = spread.invoice_line_id.company_currency_id._convert(
|
||||
spread.invoice_line_id.balance,
|
||||
spread.currency_id,
|
||||
spread.company_id,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Andrea Stirpe <a.stirpe@onestein.nl>
|
||||
* Kitti U. <kittiu@ecosoft.co.th>
|
||||
* Saran Lim. <saranl@ecosoft.co.th>
|
||||
* Manuel Regidor <manuel.regidor@sygel.es>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
@@ -551,6 +550,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
<li>Andrea Stirpe <<a class="reference external" href="mailto:a.stirpe@onestein.nl">a.stirpe@onestein.nl</a>></li>
|
||||
<li>Kitti U. <<a class="reference external" href="mailto:kittiu@ecosoft.co.th">kittiu@ecosoft.co.th</a>></li>
|
||||
<li>Saran Lim. <<a class="reference external" href="mailto:saranl@ecosoft.co.th">saranl@ecosoft.co.th</a>></li>
|
||||
<li>Manuel Regidor <<a class="reference external" href="mailto:manuel.regidor@sygel.es">manuel.regidor@sygel.es</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="other-credits">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Copyright 2018-2020 Onestein (<https://www.onestein.eu>)
|
||||
# Copyright 2025 Sygel (<https://www.sygel.es>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
import datetime
|
||||
@@ -9,7 +10,9 @@ from odoo.tests import Form, common
|
||||
|
||||
|
||||
class TestAccountInvoiceSpread(common.TransactionCase):
|
||||
def create_account_invoice(self, invoice_type, quantity=1.0, price_unit=1000.0):
|
||||
def create_account_invoice(
|
||||
self, invoice_type, quantity=1.0, price_unit=1000.0, currency=False
|
||||
):
|
||||
"""Create an invoice as in a view by triggering its onchange methods"""
|
||||
|
||||
invoice_form = Form(
|
||||
@@ -18,6 +21,8 @@ class TestAccountInvoiceSpread(common.TransactionCase):
|
||||
invoice_form.partner_id = self.env["res.partner"].create(
|
||||
{"name": "Partner Name"}
|
||||
)
|
||||
if currency:
|
||||
invoice_form.currency_id = currency
|
||||
with invoice_form.invoice_line_ids.new() as line:
|
||||
line.name = "product that costs " + str(price_unit)
|
||||
line.quantity = quantity
|
||||
@@ -805,3 +810,32 @@ class TestAccountInvoiceSpread(common.TransactionCase):
|
||||
reversal = move_reversal.reverse_moves()
|
||||
refund = self.env["account.move"].browse(reversal["res_id"])
|
||||
self.assertFalse(refund.invoice_line_ids.mapped("spread_id"))
|
||||
|
||||
def test_16_wizard_different_currency(self):
|
||||
company_currency = self.env.company.currency_id
|
||||
other_currency = self.env["res.currency"].search(
|
||||
[("name", "!=", company_currency.name)], limit=1
|
||||
)
|
||||
self.env["res.currency.rate"].create(
|
||||
{
|
||||
"name": fields.Date.today(),
|
||||
"currency_id": other_currency.id,
|
||||
"company_rate": 2,
|
||||
}
|
||||
)
|
||||
vendor_bill = self.create_account_invoice("in_invoice", currency=other_currency)
|
||||
bill_line = vendor_bill["invoice_line_ids"][0]
|
||||
|
||||
Wizard = self.env["account.spread.invoice.line.link.wizard"]
|
||||
wizard1 = Wizard.with_context(
|
||||
default_invoice_line_id=bill_line.id,
|
||||
default_company_id=self.env.company.id,
|
||||
allow_spread_planning=True,
|
||||
).create({})
|
||||
self.assertEqual(wizard1.spread_action_type, "link")
|
||||
|
||||
wizard1.spread_account_id = self.account_receivable
|
||||
wizard1.spread_journal_id = self.expenses_journal
|
||||
wizard1.spread_id = self.spread
|
||||
wizard1.confirm()
|
||||
self.assertEqual(self.spread.total_amount, bill_line.balance)
|
||||
|
||||
Reference in New Issue
Block a user