Merge pull request #31982 from FHenry/dev_enhance_upgrade_process
fix: upgrade process to version-14 when currency opportunity was not set
This commit is contained in:
commit
3c055f94e1
@ -1,3 +1,4 @@
|
|||||||
|
import click
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
@ -16,6 +17,19 @@ def execute():
|
|||||||
for opportunity in opportunities:
|
for opportunity in opportunities:
|
||||||
company_currency = erpnext.get_company_currency(opportunity.company)
|
company_currency = erpnext.get_company_currency(opportunity.company)
|
||||||
|
|
||||||
|
if opportunity.currency is None or opportunity.currency == "":
|
||||||
|
opportunity.currency = company_currency
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Opportunity",
|
||||||
|
opportunity.name,
|
||||||
|
{"currency": opportunity.currency},
|
||||||
|
update_modified=False,
|
||||||
|
)
|
||||||
|
click.secho(
|
||||||
|
f' Opportunity `{opportunity.name}` has no currency set. Setting it to company currency as default: `{opportunity.currency}`"\n',
|
||||||
|
fg="yellow",
|
||||||
|
)
|
||||||
|
|
||||||
# base total and total will be 0 only since item table did not have amount field earlier
|
# base total and total will be 0 only since item table did not have amount field earlier
|
||||||
if opportunity.currency != company_currency:
|
if opportunity.currency != company_currency:
|
||||||
conversion_rate = get_exchange_rate(opportunity.currency, company_currency)
|
conversion_rate = get_exchange_rate(opportunity.currency, company_currency)
|
||||||
|
Loading…
Reference in New Issue
Block a user