Skip to content

Commit

Permalink
Merge PR OCA#2014 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by HaraldPanten
  • Loading branch information
OCA-git-bot committed Jan 20, 2025
2 parents 4547cc6 + 81de156 commit e8f646b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions account_spread_cost_revenue/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Contributors
* Andrea Stirpe <[email protected]>
* Kitti U. <[email protected]>
* Saran Lim. <[email protected]>
* Manuel Regidor <[email protected]>

Other credits
~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion account_spread_cost_revenue/models/account_spread.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _compute_amounts(self):
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,
Expand Down
1 change: 1 addition & 0 deletions account_spread_cost_revenue/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Andrea Stirpe <[email protected]>
* Kitti U. <[email protected]>
* Saran Lim. <[email protected]>
* Manuel Regidor <[email protected]>
2 changes: 1 addition & 1 deletion account_spread_cost_revenue/static/description/index.html
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -551,6 +550,7 @@ <h2><a class="toc-backref" href="#toc-entry-15">Contributors</a></h2>
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
<li>Kitti U. &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li>Manuel Regidor &lt;<a class="reference external" href="mailto:manuel.regidor&#64;sygel.es">manuel.regidor&#64;sygel.es</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
36 changes: 35 additions & 1 deletion account_spread_cost_revenue/tests/test_account_invoice_spread.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,7 +10,9 @@


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(
Expand All @@ -18,6 +21,8 @@ def create_account_invoice(self, invoice_type, quantity=1.0, price_unit=1000.0):
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
Expand Down Expand Up @@ -805,3 +810,32 @@ def test_15_invoice_refund(self):
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)

0 comments on commit e8f646b

Please sign in to comment.