Browse Source
* feat: multi-currency * refactor: lead form * fix: test case for opportunity item * fix: removing local changes * fix: test cases * fix: test cases * fix: review changes * fix: reverting lead.json chnages * fix: toggle display for currency fields * review changes * fix: test case * fix: linter issues * fix: unused import * feat: grand total in opportunity * fix: patch * fix: sort imports * fix: reload opportunity item doctype Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>develop
Anupam Kumar
3 years ago
committed by
GitHub
7 changed files with 374 additions and 463 deletions
@ -1,469 +1,177 @@ |
|||
{ |
|||
"allow_copy": 0, |
|||
"allow_events_in_timeline": 0, |
|||
"allow_guest_to_view": 0, |
|||
"allow_import": 0, |
|||
"allow_rename": 0, |
|||
"beta": 0, |
|||
"actions": [], |
|||
"creation": "2013-02-22 01:27:51", |
|||
"custom": 0, |
|||
"docstatus": 0, |
|||
"doctype": "DocType", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"field_order": [ |
|||
"item_code", |
|||
"item_name", |
|||
"col_break1", |
|||
"uom", |
|||
"qty", |
|||
"section_break_6", |
|||
"brand", |
|||
"item_group", |
|||
"description", |
|||
"column_break_8", |
|||
"image", |
|||
"image_view", |
|||
"quantity_and_rate_section", |
|||
"base_rate", |
|||
"base_amount", |
|||
"column_break_16", |
|||
"rate", |
|||
"amount" |
|||
], |
|||
"fields": [ |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "item_code", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Item Code", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"oldfieldname": "item_code", |
|||
"oldfieldtype": "Link", |
|||
"options": "Item", |
|||
"permlevel": 0, |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"options": "Item" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "col_break1", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"fieldtype": "Column Break" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"default": "1", |
|||
"fieldname": "qty", |
|||
"fieldtype": "Float", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Qty", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"oldfieldname": "qty", |
|||
"oldfieldtype": "Currency", |
|||
"permlevel": 0, |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"oldfieldtype": "Currency" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"description": "", |
|||
"fieldname": "item_group", |
|||
"fieldtype": "Link", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Item Group", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"oldfieldname": "item_group", |
|||
"oldfieldtype": "Link", |
|||
"options": "Item Group", |
|||
"permlevel": 0, |
|||
"print_hide": 1, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"print_hide": 1 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "brand", |
|||
"fieldtype": "Link", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Brand", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"oldfieldname": "brand", |
|||
"oldfieldtype": "Link", |
|||
"options": "Brand", |
|||
"permlevel": 0, |
|||
"print_hide": 1, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"print_hide": 1 |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"collapsible": 1, |
|||
"fieldname": "section_break_6", |
|||
"fieldtype": "Section Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"label": "Description" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "uom", |
|||
"fieldtype": "Link", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "UOM", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"oldfieldname": "uom", |
|||
"oldfieldtype": "Link", |
|||
"options": "UOM", |
|||
"permlevel": 0, |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"options": "UOM" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "item_name", |
|||
"fieldtype": "Data", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 1, |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 0, |
|||
"label": "Item Name", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"oldfieldname": "item_name", |
|||
"oldfieldtype": "Data", |
|||
"permlevel": 0, |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"oldfieldtype": "Data" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "description", |
|||
"fieldtype": "Text Editor", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Description", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"oldfieldname": "description", |
|||
"oldfieldtype": "Text", |
|||
"permlevel": 0, |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"print_width": "300px", |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0, |
|||
"width": "300px" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "column_break_8", |
|||
"fieldtype": "Column Break", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"fieldtype": "Column Break" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "image", |
|||
"fieldtype": "Attach", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Image", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 0, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"label": "Image" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "image_view", |
|||
"fieldtype": "Image", |
|||
"hidden": 0, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Image View", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"options": "image", |
|||
"permlevel": 0, |
|||
"precision": "", |
|||
"print_hide": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "rate", |
|||
"fieldtype": "Currency", |
|||
"in_list_view": 1, |
|||
"label": "Rate", |
|||
"options": "currency", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "quantity_and_rate_section", |
|||
"fieldtype": "Section Break", |
|||
"label": "Quantity and Rate" |
|||
}, |
|||
{ |
|||
"fieldname": "base_amount", |
|||
"fieldtype": "Currency", |
|||
"label": "Amount (Company Currency)", |
|||
"options": "Company:company:default_currency", |
|||
"print_hide": 1, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"read_only": 1, |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "column_break_16", |
|||
"fieldtype": "Column Break" |
|||
}, |
|||
{ |
|||
"allow_bulk_edit": 0, |
|||
"allow_in_quick_entry": 0, |
|||
"allow_on_submit": 0, |
|||
"bold": 0, |
|||
"collapsible": 0, |
|||
"columns": 0, |
|||
"fieldname": "basic_rate", |
|||
"fieldname": "amount", |
|||
"fieldtype": "Currency", |
|||
"hidden": 1, |
|||
"ignore_user_permissions": 0, |
|||
"ignore_xss_filter": 0, |
|||
"in_filter": 0, |
|||
"in_global_search": 0, |
|||
"in_list_view": 0, |
|||
"in_standard_filter": 0, |
|||
"label": "Basic Rate", |
|||
"length": 0, |
|||
"no_copy": 0, |
|||
"in_list_view": 1, |
|||
"label": "Amount", |
|||
"options": "currency", |
|||
"read_only": 1, |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "base_rate", |
|||
"fieldtype": "Currency", |
|||
"label": "Rate (Company Currency)", |
|||
"oldfieldname": "basic_rate", |
|||
"oldfieldtype": "Currency", |
|||
"options": "Company:company:default_currency", |
|||
"permlevel": 0, |
|||
"print_hide": 1, |
|||
"print_hide_if_no_value": 0, |
|||
"read_only": 0, |
|||
"remember_last_selected_value": 0, |
|||
"report_hide": 0, |
|||
"reqd": 0, |
|||
"search_index": 0, |
|||
"set_only_once": 0, |
|||
"translatable": 0, |
|||
"unique": 0 |
|||
"read_only": 1, |
|||
"reqd": 1 |
|||
} |
|||
], |
|||
"has_web_view": 0, |
|||
"hide_heading": 0, |
|||
"hide_toolbar": 0, |
|||
"idx": 1, |
|||
"image_view": 0, |
|||
"in_create": 0, |
|||
"is_submittable": 0, |
|||
"issingle": 0, |
|||
"istable": 1, |
|||
"max_attachments": 0, |
|||
"modified": "2018-12-28 15:43:09.382012", |
|||
"links": [], |
|||
"modified": "2021-07-30 16:39:09.775720", |
|||
"modified_by": "Administrator", |
|||
"module": "CRM", |
|||
"name": "Opportunity Item", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"quick_entry": 0, |
|||
"read_only": 0, |
|||
"read_only_onload": 0, |
|||
"show_name_in_global_search": 0, |
|||
"track_changes": 1, |
|||
"track_seen": 0, |
|||
"track_views": 0 |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"track_changes": 1 |
|||
} |
@ -0,0 +1,36 @@ |
|||
from __future__ import unicode_literals |
|||
|
|||
import frappe |
|||
from frappe.utils import flt |
|||
|
|||
import erpnext |
|||
from erpnext.setup.utils import get_exchange_rate |
|||
|
|||
|
|||
def execute(): |
|||
frappe.reload_doc('crm', 'doctype', 'opportunity') |
|||
frappe.reload_doc('crm', 'doctype', 'opportunity_item') |
|||
|
|||
opportunities = frappe.db.get_list('Opportunity', filters={ |
|||
'opportunity_amount': ['>', 0] |
|||
}, fields=['name', 'company', 'currency', 'opportunity_amount']) |
|||
|
|||
for opportunity in opportunities: |
|||
company_currency = erpnext.get_company_currency(opportunity.company) |
|||
|
|||
# base total and total will be 0 only since item table did not have amount field earlier |
|||
if opportunity.currency != company_currency: |
|||
conversion_rate = get_exchange_rate(opportunity.currency, company_currency) |
|||
base_opportunity_amount = flt(conversion_rate) * flt(opportunity.opportunity_amount) |
|||
grand_total = flt(opportunity.opportunity_amount) |
|||
base_grand_total = flt(conversion_rate) * flt(opportunity.opportunity_amount) |
|||
else: |
|||
conversion_rate = 1 |
|||
base_opportunity_amount = grand_total = base_grand_total = flt(opportunity.opportunity_amount) |
|||
|
|||
frappe.db.set_value('Opportunity', opportunity.name, { |
|||
'conversion_rate': conversion_rate, |
|||
'base_opportunity_amount': base_opportunity_amount, |
|||
'grand_total': grand_total, |
|||
'base_grand_total': base_grand_total |
|||
}, update_modified=False) |
Loading…
Reference in new issue