Skip to content

Commit

Permalink
Merge PR OCA#364 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Feb 22, 2024
2 parents dca107c + ca210dc commit e3d28e7
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions sale_financial_risk/tests/test_partner_sale_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def setUpClass(cls):
)
cls.main_currency = cls.env.company.currency_id
cls.EUR = cls.env.ref("base.EUR")
cls.other_company = cls.env["res.company"].create(
{"name": "Company 2", "currency_id": cls.EUR.id}
)
cls.USD = cls.env.ref("base.USD")
cls.sale_order = cls.create_sale_order(cls.main_currency, cls.env.company)
cls.env.user.lang = "en_US"

Expand Down Expand Up @@ -193,7 +191,12 @@ def test_open_risk_pivot_info(self):
self.assertTrue(action["domain"])

def test_manual_currency_risk_not_exceeded(self):
self.product_pricelist.currency_id = self.EUR
if self.env.company.currency_id == self.EUR:
self.product_pricelist.currency_id = self.USD
currency = self.USD
else:
self.product_pricelist.currency_id = self.EUR
currency = self.EUR
self.partner.write(
{
"risk_sale_order_limit": 99,
Expand All @@ -208,19 +211,22 @@ def test_manual_currency_risk_not_exceeded(self):
"currency_id": self.main_currency.id,
"name": fields.Date.today(),
"rate": 0.5,
"company_id": self.other_company.id,
"company_id": self.env.company.id,
}
)
sale_order = self.create_sale_order(
currency=self.EUR, company=self.other_company
)
sale_order = self.create_sale_order(currency=currency, company=self.env.company)
result = sale_order.action_confirm()

# Limit not exceeded
self.assertEqual(result, True)

def test_manual_currency_risk_exceeded(self):
self.product_pricelist.currency_id = self.EUR
if self.env.company.currency_id == self.EUR:
self.product_pricelist.currency_id = self.USD
currency = self.USD
else:
self.product_pricelist.currency_id = self.EUR
currency = self.EUR
self.partner.write(
{
"risk_sale_order_limit": 99,
Expand All @@ -230,18 +236,15 @@ def test_manual_currency_risk_exceeded(self):
"manual_credit_currency_id": self.main_currency.id,
}
)
self.product_pricelist.currency_id = self.EUR
self.env["res.currency.rate"].create(
{
"currency_id": self.main_currency.id,
"name": fields.Date.today(),
"rate": 1.5,
"company_id": self.other_company.id,
"rate": 2.0,
"company_id": self.env.company.id,
}
)
sale_order = self.create_sale_order(
currency=self.EUR, company=self.other_company
)
sale_order = self.create_sale_order(currency=currency, company=self.env.company)
result = sale_order.action_confirm()

# Limit exceeded
Expand Down

0 comments on commit e3d28e7

Please sign in to comment.