perf(minor): remove unnecessary comprehensions (port #25645)
This commit is contained in:
parent
a424c0c023
commit
9891780f5a
@ -54,7 +54,7 @@ class CForm(Document):
|
||||
frappe.throw(_("Please enter atleast 1 invoice in the table"))
|
||||
|
||||
def set_total_invoiced_amount(self):
|
||||
total = sum([flt(d.grand_total) for d in self.get('invoices')])
|
||||
total = sum(flt(d.grand_total) for d in self.get('invoices'))
|
||||
frappe.db.set(self, 'total_invoiced_amount', total)
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -14,7 +14,7 @@ class CouponCode(Document):
|
||||
|
||||
if not self.coupon_code:
|
||||
if self.coupon_type == "Promotional":
|
||||
self.coupon_code =''.join([i for i in self.coupon_name if not i.isdigit()])[0:8].upper()
|
||||
self.coupon_code =''.join(i for i in self.coupon_name if not i.isdigit())[0:8].upper()
|
||||
elif self.coupon_type == "Gift Card":
|
||||
self.coupon_code = frappe.generate_hash()[:10].upper()
|
||||
|
||||
|
@ -42,7 +42,7 @@ class InvoiceDiscounting(AccountsController):
|
||||
record.idx, frappe.bold(actual_outstanding), frappe.bold(record.sales_invoice)))
|
||||
|
||||
def calculate_total_amount(self):
|
||||
self.total_amount = sum([flt(d.outstanding_amount) for d in self.invoices])
|
||||
self.total_amount = sum(flt(d.outstanding_amount) for d in self.invoices)
|
||||
|
||||
def on_submit(self):
|
||||
self.update_sales_invoice()
|
||||
|
@ -196,8 +196,8 @@ class JournalEntry(AccountsController):
|
||||
frappe.throw(_("Row {0}: Party Type and Party is required for Receivable / Payable account {1}").format(d.idx, d.account))
|
||||
|
||||
def check_credit_limit(self):
|
||||
customers = list(set([d.party for d in self.get("accounts")
|
||||
if d.party_type=="Customer" and d.party and flt(d.debit) > 0]))
|
||||
customers = list(set(d.party for d in self.get("accounts")
|
||||
if d.party_type=="Customer" and d.party and flt(d.debit) > 0))
|
||||
if customers:
|
||||
from erpnext.selling.doctype.customer.customer import check_credit_limit
|
||||
for customer in customers:
|
||||
|
@ -21,7 +21,7 @@ class MonthlyDistribution(Document):
|
||||
idx += 1
|
||||
|
||||
def validate(self):
|
||||
total = sum([flt(d.percentage_allocation) for d in self.get("percentages")])
|
||||
total = sum(flt(d.percentage_allocation) for d in self.get("percentages"))
|
||||
|
||||
if flt(total, 2) != 100.0:
|
||||
frappe.throw(_("Percentage Allocation should be equal to 100%") + \
|
||||
|
@ -303,7 +303,7 @@ class PaymentEntry(AccountsController):
|
||||
for k, v in no_oustanding_refs.items():
|
||||
frappe.msgprint(
|
||||
_("{} - {} now have {} as they had no outstanding amount left before submitting the Payment Entry.")
|
||||
.format(k, frappe.bold(", ".join([d.reference_name for d in v])), frappe.bold("negative outstanding amount"))
|
||||
.format(k, frappe.bold(", ".join(d.reference_name for d in v)), frappe.bold("negative outstanding amount"))
|
||||
+ "<br><br>" + _("If this is undesirable please cancel the corresponding Payment Entry."),
|
||||
title=_("Warning"), indicator="orange")
|
||||
|
||||
@ -419,7 +419,7 @@ class PaymentEntry(AccountsController):
|
||||
def set_unallocated_amount(self):
|
||||
self.unallocated_amount = 0
|
||||
if self.party:
|
||||
total_deductions = sum([flt(d.amount) for d in self.get("deductions")])
|
||||
total_deductions = sum(flt(d.amount) for d in self.get("deductions"))
|
||||
if self.payment_type == "Receive" \
|
||||
and self.base_total_allocated_amount < self.base_received_amount + total_deductions \
|
||||
and self.total_allocated_amount < self.paid_amount + (total_deductions / self.source_exchange_rate):
|
||||
@ -444,7 +444,7 @@ class PaymentEntry(AccountsController):
|
||||
else:
|
||||
self.difference_amount = self.base_paid_amount - flt(self.base_received_amount)
|
||||
|
||||
total_deductions = sum([flt(d.amount) for d in self.get("deductions")])
|
||||
total_deductions = sum(flt(d.amount) for d in self.get("deductions"))
|
||||
|
||||
self.difference_amount = flt(self.difference_amount - total_deductions,
|
||||
self.precision("difference_amount"))
|
||||
@ -460,8 +460,8 @@ class PaymentEntry(AccountsController):
|
||||
if ((self.payment_type=="Pay" and self.party_type=="Customer")
|
||||
or (self.payment_type=="Receive" and self.party_type=="Supplier")):
|
||||
|
||||
total_negative_outstanding = sum([abs(flt(d.outstanding_amount))
|
||||
for d in self.get("references") if flt(d.outstanding_amount) < 0])
|
||||
total_negative_outstanding = sum(abs(flt(d.outstanding_amount))
|
||||
for d in self.get("references") if flt(d.outstanding_amount) < 0)
|
||||
|
||||
paid_amount = self.paid_amount if self.payment_type=="Receive" else self.received_amount
|
||||
additional_charges = sum([flt(d.amount) for d in self.deductions])
|
||||
|
@ -112,7 +112,7 @@ class PaymentRequest(Document):
|
||||
if not data_of_completed_requests:
|
||||
return self.grand_total
|
||||
|
||||
request_amounts = sum([json.loads(d).get('request_amount') for d in data_of_completed_requests])
|
||||
request_amounts = sum(json.loads(d).get('request_amount') for d in data_of_completed_requests)
|
||||
return request_amounts
|
||||
|
||||
def on_cancel(self):
|
||||
|
@ -20,9 +20,9 @@ from frappe.utils import cint, flt, get_link_to_form, getdate, today, fmt_money
|
||||
class MultiplePricingRuleConflict(frappe.ValidationError): pass
|
||||
|
||||
apply_on_table = {
|
||||
'Item Code': 'items',
|
||||
'Item Group': 'item_groups',
|
||||
'Brand': 'brands'
|
||||
'Item Code': 'items',
|
||||
'Item Group': 'item_groups',
|
||||
'Brand': 'brands'
|
||||
}
|
||||
|
||||
def get_pricing_rules(args, doc=None):
|
||||
@ -183,7 +183,7 @@ def _get_tree_conditions(args, parenttype, table, allow_blank=True):
|
||||
condition = "ifnull({table}.{field}, '') in ({parent_groups})".format(
|
||||
table=table,
|
||||
field=field,
|
||||
parent_groups=", ".join([frappe.db.escape(d) for d in parent_groups])
|
||||
parent_groups=", ".join(frappe.db.escape(d) for d in parent_groups)
|
||||
)
|
||||
|
||||
frappe.flags.tree_conditions[key] = condition
|
||||
@ -264,7 +264,7 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
|
||||
|
||||
# find pricing rule with highest priority
|
||||
if pricing_rules:
|
||||
max_priority = max([cint(p.priority) for p in pricing_rules])
|
||||
max_priority = max(cint(p.priority) for p in pricing_rules)
|
||||
if max_priority:
|
||||
pricing_rules = list(filter(lambda x: cint(x.priority)==max_priority, pricing_rules))
|
||||
|
||||
@ -272,14 +272,14 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
|
||||
pricing_rules = list(pricing_rules)
|
||||
|
||||
if len(pricing_rules) > 1:
|
||||
rate_or_discount = list(set([d.rate_or_discount for d in pricing_rules]))
|
||||
rate_or_discount = list(set(d.rate_or_discount for d in pricing_rules))
|
||||
if len(rate_or_discount) == 1 and rate_or_discount[0] == "Discount Percentage":
|
||||
pricing_rules = list(filter(lambda x: x.for_price_list==args.price_list, pricing_rules)) \
|
||||
or pricing_rules
|
||||
|
||||
if len(pricing_rules) > 1 and not args.for_shopping_cart:
|
||||
frappe.throw(_("Multiple Price Rules exists with same criteria, please resolve conflict by assigning priority. Price Rules: {0}")
|
||||
.format("\n".join([d.name for d in pricing_rules])), MultiplePricingRuleConflict)
|
||||
.format("\n".join(d.name for d in pricing_rules)), MultiplePricingRuleConflict)
|
||||
elif pricing_rules:
|
||||
return pricing_rules[0]
|
||||
|
||||
@ -541,7 +541,7 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
|
||||
|
||||
def apply_pricing_rule_for_free_items(doc, pricing_rule_args, set_missing_values=False):
|
||||
if pricing_rule_args:
|
||||
items = tuple([(d.item_code, d.pricing_rules) for d in doc.items if d.is_free_item])
|
||||
items = tuple((d.item_code, d.pricing_rules) for d in doc.items if d.is_free_item)
|
||||
|
||||
for args in pricing_rule_args:
|
||||
if not items or (args.get('item_code'), args.get('pricing_rules')) not in items:
|
||||
|
@ -631,7 +631,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
|
||||
self.assertEqual(len(pi.get("supplied_items")), 2)
|
||||
|
||||
rm_supp_cost = sum([d.amount for d in pi.get("supplied_items")])
|
||||
rm_supp_cost = sum(d.amount for d in pi.get("supplied_items"))
|
||||
self.assertEqual(flt(pi.get("items")[0].rm_supp_cost, 2), flt(rm_supp_cost, 2))
|
||||
|
||||
def test_rejected_serial_no(self):
|
||||
|
@ -112,7 +112,7 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
||||
si = create_sales_invoice(customer = "Test TCS Customer", rate=5000)
|
||||
si.submit()
|
||||
|
||||
tcs_charged = sum([d.base_tax_amount for d in si.taxes if d.account_head == 'TCS - _TC'])
|
||||
tcs_charged = sum(d.base_tax_amount for d in si.taxes if d.account_head == 'TCS - _TC')
|
||||
self.assertEqual(tcs_charged, 500)
|
||||
invoices.append(si)
|
||||
|
||||
|
@ -143,7 +143,7 @@ def make_entry(args, adv_adj, update_outstanding, from_repost=False):
|
||||
validate_expense_against_budget(args)
|
||||
|
||||
def validate_cwip_accounts(gl_map):
|
||||
cwip_enabled = any([cint(ac.enable_cwip_accounting) for ac in frappe.db.get_all("Asset Category","enable_cwip_accounting")])
|
||||
cwip_enabled = any(cint(ac.enable_cwip_accounting) for ac in frappe.db.get_all("Asset Category","enable_cwip_accounting"))
|
||||
|
||||
if cwip_enabled and gl_map[0].voucher_type == "Journal Entry":
|
||||
cwip_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
|
||||
|
@ -32,7 +32,7 @@ def get_accounts_in_mappers(mapping_names):
|
||||
join `tabCash Flow Mapping` cfm on cfma.parent=cfm.name
|
||||
where cfma.parent in (%s)
|
||||
order by cfm.is_working_capital
|
||||
''', (', '.join(['"%s"' % d for d in mapping_names])))
|
||||
''', (', '.join('"%s"' % d for d in mapping_names)))
|
||||
|
||||
|
||||
def setup_mappers(mappers):
|
||||
@ -83,8 +83,8 @@ def setup_mappers(mappers):
|
||||
|
||||
account_types_labels = sorted(
|
||||
set(
|
||||
[(d['label'], d['is_working_capital'], d['is_income_tax_liability'], d['is_income_tax_expense'])
|
||||
for d in account_types]
|
||||
(d['label'], d['is_working_capital'], d['is_income_tax_liability'], d['is_income_tax_expense'])
|
||||
for d in account_types
|
||||
),
|
||||
key=lambda x: x[1]
|
||||
)
|
||||
@ -375,7 +375,7 @@ def _get_account_type_based_data(filters, account_names, period_list, accumulate
|
||||
total = 0
|
||||
for period in period_list:
|
||||
start_date = get_start_date(period, accumulated_values, company)
|
||||
accounts = ', '.join(['"%s"' % d for d in account_names])
|
||||
accounts = ', '.join('"%s"' % d for d in account_names)
|
||||
|
||||
if opening_balances:
|
||||
date_info = dict(date=start_date)
|
||||
|
@ -145,7 +145,7 @@ class PartyLedgerSummaryReport(object):
|
||||
out = []
|
||||
for party, row in iteritems(self.party_data):
|
||||
if row.opening_balance or row.invoiced_amount or row.paid_amount or row.return_amount or row.closing_amount:
|
||||
total_party_adjustment = sum([amount for amount in itervalues(self.party_adjustment_details.get(party, {}))])
|
||||
total_party_adjustment = sum(amount for amount in itervalues(self.party_adjustment_details.get(party, {})))
|
||||
row.paid_amount -= total_party_adjustment
|
||||
|
||||
adjustments = self.party_adjustment_details.get(party, {})
|
||||
|
@ -369,7 +369,7 @@ def set_gl_entries_by_account(
|
||||
|
||||
if accounts:
|
||||
additional_conditions += " and account in ({})"\
|
||||
.format(", ".join([frappe.db.escape(d) for d in accounts]))
|
||||
.format(", ".join(frappe.db.escape(d) for d in accounts))
|
||||
|
||||
gl_filters = {
|
||||
"company": company,
|
||||
|
@ -334,7 +334,7 @@ def get_aii_accounts():
|
||||
|
||||
def get_purchase_receipts_against_purchase_order(item_list):
|
||||
po_pr_map = frappe._dict()
|
||||
po_item_rows = list(set([d.po_detail for d in item_list]))
|
||||
po_item_rows = list(set(d.po_detail for d in item_list))
|
||||
|
||||
if po_item_rows:
|
||||
purchase_receipts = frappe.db.sql("""
|
||||
|
@ -23,7 +23,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
|
||||
if item_list:
|
||||
itemised_tax, tax_columns = get_tax_accounts(item_list, columns, company_currency)
|
||||
|
||||
mode_of_payments = get_mode_of_payments(set([d.parent for d in item_list]))
|
||||
mode_of_payments = get_mode_of_payments(set(d.parent for d in item_list))
|
||||
so_dn_map = get_delivery_notes_against_sales_order(item_list)
|
||||
|
||||
data = []
|
||||
|
@ -77,14 +77,14 @@ def get_pos_entries(filters, group_by_field):
|
||||
), filters, as_dict=1)
|
||||
|
||||
def concat_mode_of_payments(pos_entries):
|
||||
mode_of_payments = get_mode_of_payments(set([d.pos_invoice for d in pos_entries]))
|
||||
mode_of_payments = get_mode_of_payments(set(d.pos_invoice for d in pos_entries))
|
||||
for entry in pos_entries:
|
||||
if mode_of_payments.get(entry.pos_invoice):
|
||||
entry.mode_of_payment = ", ".join(mode_of_payments.get(entry.pos_invoice, []))
|
||||
|
||||
def add_subtotal_row(data, group_invoices, group_by_field, group_by_value):
|
||||
grand_total = sum([d.grand_total for d in group_invoices])
|
||||
paid_amount = sum([d.paid_amount for d in group_invoices])
|
||||
grand_total = sum(d.grand_total for d in group_invoices)
|
||||
paid_amount = sum(d.paid_amount for d in group_invoices)
|
||||
data.append({
|
||||
group_by_field: group_by_value,
|
||||
"grand_total": grand_total,
|
||||
|
@ -26,7 +26,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
|
||||
invoice_expense_map, invoice_tax_map = get_invoice_tax_map(invoice_list,
|
||||
invoice_expense_map, expense_accounts)
|
||||
invoice_po_pr_map = get_invoice_po_pr_map(invoice_list)
|
||||
suppliers = list(set([d.supplier for d in invoice_list]))
|
||||
suppliers = list(set(d.supplier for d in invoice_list))
|
||||
supplier_details = get_supplier_details(suppliers)
|
||||
|
||||
company_currency = frappe.get_cached_value('Company', filters.company, "default_currency")
|
||||
@ -120,13 +120,13 @@ def get_columns(invoice_list, additional_table_columns):
|
||||
and docstatus = 1 and (account_head is not null and account_head != '')
|
||||
and category in ('Total', 'Valuation and Total')
|
||||
and parent in (%s) order by account_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
|
||||
|
||||
unrealized_profit_loss_accounts = frappe.db.sql_list("""SELECT distinct unrealized_profit_loss_account
|
||||
from `tabPurchase Invoice` where docstatus = 1 and name in (%s)
|
||||
and ifnull(unrealized_profit_loss_account, '') != ''
|
||||
order by unrealized_profit_loss_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
|
||||
|
||||
expense_columns = [(account + ":Currency/currency:120") for account in expense_accounts]
|
||||
unrealized_profit_loss_account_columns = [(account + ":Currency/currency:120") for account in unrealized_profit_loss_accounts]
|
||||
@ -208,7 +208,7 @@ def get_invoice_expense_map(invoice_list):
|
||||
from `tabPurchase Invoice Item`
|
||||
where parent in (%s)
|
||||
group by parent, expense_account
|
||||
""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
""" % ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
invoice_expense_map = {}
|
||||
for d in expense_details:
|
||||
@ -221,7 +221,7 @@ def get_internal_invoice_map(invoice_list):
|
||||
unrealized_amount_details = frappe.db.sql("""SELECT name, unrealized_profit_loss_account,
|
||||
base_net_total as amount from `tabPurchase Invoice` where name in (%s)
|
||||
and is_internal_supplier = 1 and company = represents_company""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
internal_invoice_map = {}
|
||||
for d in unrealized_amount_details:
|
||||
@ -238,7 +238,7 @@ def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
||||
where parent in (%s) and category in ('Total', 'Valuation and Total')
|
||||
and base_tax_amount_after_discount_amount != 0
|
||||
group by parent, account_head, add_deduct_tax
|
||||
""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
""" % ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
invoice_tax_map = {}
|
||||
for d in tax_details:
|
||||
@ -258,7 +258,7 @@ def get_invoice_po_pr_map(invoice_list):
|
||||
select parent, purchase_order, purchase_receipt, po_detail, project
|
||||
from `tabPurchase Invoice Item`
|
||||
where parent in (%s)
|
||||
""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
""" % ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
invoice_po_pr_map = {}
|
||||
for d in pi_items:
|
||||
|
@ -158,7 +158,7 @@ def get_sales_invoice_data(filters):
|
||||
def get_mode_of_payments(filters):
|
||||
mode_of_payments = {}
|
||||
invoice_list = get_invoices(filters)
|
||||
invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list])
|
||||
invoice_list_names = ",".join('"' + invoice['name'] + '"' for invoice in invoice_list)
|
||||
if invoice_list:
|
||||
inv_mop = frappe.db.sql("""select a.owner,a.posting_date, ifnull(b.mode_of_payment, '') as mode_of_payment
|
||||
from `tabSales Invoice` a, `tabSales Invoice Payment` b
|
||||
@ -197,7 +197,7 @@ def get_invoices(filters):
|
||||
def get_mode_of_payment_details(filters):
|
||||
mode_of_payment_details = {}
|
||||
invoice_list = get_invoices(filters)
|
||||
invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list])
|
||||
invoice_list_names = ",".join('"' + invoice['name'] + '"' for invoice in invoice_list)
|
||||
if invoice_list:
|
||||
inv_mop_detail = frappe.db.sql("""select a.owner, a.posting_date,
|
||||
ifnull(b.mode_of_payment, '') as mode_of_payment, sum(b.base_amount) as paid_amount
|
||||
|
@ -248,19 +248,19 @@ def get_columns(invoice_list, additional_table_columns):
|
||||
income_accounts = frappe.db.sql_list("""select distinct income_account
|
||||
from `tabSales Invoice Item` where docstatus = 1 and parent in (%s)
|
||||
order by income_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
|
||||
|
||||
tax_accounts = frappe.db.sql_list("""select distinct account_head
|
||||
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||
and docstatus = 1 and base_tax_amount_after_discount_amount != 0
|
||||
and parent in (%s) order by account_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
|
||||
|
||||
unrealized_profit_loss_accounts = frappe.db.sql_list("""SELECT distinct unrealized_profit_loss_account
|
||||
from `tabSales Invoice` where docstatus = 1 and name in (%s)
|
||||
and ifnull(unrealized_profit_loss_account, '') != ''
|
||||
order by unrealized_profit_loss_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
|
||||
|
||||
for account in income_accounts:
|
||||
income_columns.append({
|
||||
@ -406,7 +406,7 @@ def get_invoices(filters, additional_query_columns):
|
||||
def get_invoice_income_map(invoice_list):
|
||||
income_details = frappe.db.sql("""select parent, income_account, sum(base_net_amount) as amount
|
||||
from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
invoice_income_map = {}
|
||||
for d in income_details:
|
||||
@ -419,7 +419,7 @@ def get_internal_invoice_map(invoice_list):
|
||||
unrealized_amount_details = frappe.db.sql("""SELECT name, unrealized_profit_loss_account,
|
||||
base_net_total as amount from `tabSales Invoice` where name in (%s)
|
||||
and is_internal_customer = 1 and company = represents_company""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
internal_invoice_map = {}
|
||||
for d in unrealized_amount_details:
|
||||
@ -432,7 +432,7 @@ def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
|
||||
tax_details = frappe.db.sql("""select parent, account_head,
|
||||
sum(base_tax_amount_after_discount_amount) as tax_amount
|
||||
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
invoice_tax_map = {}
|
||||
for d in tax_details:
|
||||
@ -451,7 +451,7 @@ def get_invoice_so_dn_map(invoice_list):
|
||||
si_items = frappe.db.sql("""select parent, sales_order, delivery_note, so_detail
|
||||
from `tabSales Invoice Item` where parent in (%s)
|
||||
and (ifnull(sales_order, '') != '' or ifnull(delivery_note, '') != '')""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
invoice_so_dn_map = {}
|
||||
for d in si_items:
|
||||
@ -475,7 +475,7 @@ def get_invoice_cc_wh_map(invoice_list):
|
||||
si_items = frappe.db.sql("""select parent, cost_center, warehouse
|
||||
from `tabSales Invoice Item` where parent in (%s)
|
||||
and (ifnull(cost_center, '') != '' or ifnull(warehouse, '') != '')""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
|
||||
|
||||
invoice_cc_wh_map = {}
|
||||
for d in si_items:
|
||||
|
@ -78,7 +78,7 @@ def get_invoice_and_tds_amount(supplier, account, company, from_date, to_date, f
|
||||
and company=%s and posting_date between %s and %s
|
||||
""", (supplier, company, from_date, to_date), as_dict=1)
|
||||
|
||||
supplier_credit_amount = flt(sum([d.credit for d in entries]))
|
||||
supplier_credit_amount = flt(sum(d.credit for d in entries))
|
||||
|
||||
vouchers = [d.voucher_no for d in entries]
|
||||
vouchers += get_advance_vouchers([supplier], company=company,
|
||||
@ -91,7 +91,7 @@ def get_invoice_and_tds_amount(supplier, account, company, from_date, to_date, f
|
||||
from `tabGL Entry`
|
||||
where account=%s and posting_date between %s and %s
|
||||
and company=%s and credit > 0 and voucher_no in ({0})
|
||||
""".format(', '.join(["'%s'" % d for d in vouchers])),
|
||||
""".format(', '.join("'%s'" % d for d in vouchers)),
|
||||
(account, from_date, to_date, company))[0][0])
|
||||
|
||||
date_range_filter = [fiscal_year, from_date, to_date]
|
||||
|
@ -139,6 +139,6 @@ def get_invoiced_item_gross_margin(sales_invoice=None, item_code=None, company=N
|
||||
gross_profit_data = GrossProfitGenerator(filters)
|
||||
result = gross_profit_data.grouped_data
|
||||
if not with_item_data:
|
||||
result = sum([d.gross_profit for d in result])
|
||||
result = sum(d.gross_profit for d in result)
|
||||
|
||||
return result
|
||||
|
@ -635,7 +635,7 @@ def get_held_invoices(party_type, party):
|
||||
'select name from `tabPurchase Invoice` where release_date IS NOT NULL and release_date > CURDATE()',
|
||||
as_dict=1
|
||||
)
|
||||
held_invoices = set([d['name'] for d in held_invoices])
|
||||
held_invoices = set(d['name'] for d in held_invoices)
|
||||
|
||||
return held_invoices
|
||||
|
||||
|
@ -470,7 +470,7 @@ class TestAsset(unittest.TestCase):
|
||||
})
|
||||
asset.insert()
|
||||
accumulated_depreciation_after_full_schedule = \
|
||||
max([d.accumulated_depreciation_amount for d in asset.get("schedules")])
|
||||
max(d.accumulated_depreciation_amount for d in asset.get("schedules"))
|
||||
|
||||
asset_value_after_full_schedule = (flt(asset.gross_purchase_amount) -
|
||||
flt(accumulated_depreciation_after_full_schedule))
|
||||
|
@ -92,7 +92,7 @@ class AssetValueAdjustment(Document):
|
||||
d.value_after_depreciation = asset_value
|
||||
|
||||
if d.depreciation_method in ("Straight Line", "Manual"):
|
||||
end_date = max([s.schedule_date for s in asset.schedules if cint(s.finance_book_id) == d.idx])
|
||||
end_date = max(s.schedule_date for s in asset.schedules if cint(s.finance_book_id) == d.idx)
|
||||
total_days = date_diff(end_date, self.date)
|
||||
rate_per_day = flt(d.value_after_depreciation) / flt(total_days)
|
||||
from_date = self.date
|
||||
|
@ -104,7 +104,7 @@ class PurchaseOrder(BuyingController):
|
||||
|
||||
def validate_minimum_order_qty(self):
|
||||
if not self.get("items"): return
|
||||
items = list(set([d.item_code for d in self.get("items")]))
|
||||
items = list(set(d.item_code for d in self.get("items")))
|
||||
|
||||
itemwise_min_order_qty = frappe._dict(frappe.db.sql("""select name, min_order_qty
|
||||
from tabItem where name in ({0})""".format(", ".join(["%s"] * len(items))), items))
|
||||
@ -291,10 +291,10 @@ class PurchaseOrder(BuyingController):
|
||||
so.notify_update()
|
||||
|
||||
def has_drop_ship_item(self):
|
||||
return any([d.delivered_by_supplier for d in self.items])
|
||||
return any(d.delivered_by_supplier for d in self.items)
|
||||
|
||||
def is_against_so(self):
|
||||
return any([d.sales_order for d in self.items if d.sales_order])
|
||||
return any(d.sales_order for d in self.items if d.sales_order)
|
||||
|
||||
def set_received_qty_for_drop_ship_items(self):
|
||||
for item in self.items:
|
||||
|
@ -359,7 +359,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
update_child_qty_rate('Purchase Order', trans_item, po.name)
|
||||
po.reload()
|
||||
|
||||
total_reqd_qty_after_change = sum([d.get("required_qty") for d in po.as_dict().get("supplied_items")])
|
||||
total_reqd_qty_after_change = sum(d.get("required_qty") for d in po.as_dict().get("supplied_items"))
|
||||
|
||||
self.assertEqual(total_reqd_qty_after_change, 2 * total_reqd_qty)
|
||||
|
||||
|
@ -391,7 +391,7 @@ def get_item_from_material_requests_based_on_supplier(source_name, target_doc =
|
||||
def get_supplier_tag():
|
||||
if not frappe.cache().hget("Supplier", "Tags"):
|
||||
filters = {"document_type": "Supplier"}
|
||||
tags = list(set([tag.tag for tag in frappe.get_all("Tag Link", filters=filters, fields=["tag"]) if tag]))
|
||||
tags = list(set(tag.tag for tag in frappe.get_all("Tag Link", filters=filters, fields=["tag"]) if tag))
|
||||
frappe.cache().hset("Supplier", "Tags", tags)
|
||||
|
||||
return frappe.cache().hget("Supplier", "Tags")
|
||||
|
@ -608,8 +608,8 @@ class AccountsController(TransactionBase):
|
||||
order_field = "purchase_order"
|
||||
order_doctype = "Purchase Order"
|
||||
|
||||
order_list = list(set([d.get(order_field)
|
||||
for d in self.get("items") if d.get(order_field)]))
|
||||
order_list = list(set(d.get(order_field)
|
||||
for d in self.get("items") if d.get(order_field)))
|
||||
|
||||
journal_entries = get_advance_journal_entries(party_type, party, party_account,
|
||||
amount_field, order_doctype, order_list, include_unallocated)
|
||||
@ -633,8 +633,8 @@ class AccountsController(TransactionBase):
|
||||
|
||||
def validate_advance_entries(self):
|
||||
order_field = "sales_order" if self.doctype == "Sales Invoice" else "purchase_order"
|
||||
order_list = list(set([d.get(order_field)
|
||||
for d in self.get("items") if d.get(order_field)]))
|
||||
order_list = list(set(d.get(order_field)
|
||||
for d in self.get("items") if d.get(order_field)))
|
||||
|
||||
if not order_list: return
|
||||
|
||||
|
@ -181,8 +181,8 @@ class BuyingController(StockController):
|
||||
stock_and_asset_items_amount += flt(d.base_net_amount)
|
||||
last_item_idx = d.idx
|
||||
|
||||
total_valuation_amount = sum([flt(d.base_tax_amount_after_discount_amount) for d in self.get("taxes")
|
||||
if d.category in ["Valuation", "Valuation and Total"]])
|
||||
total_valuation_amount = sum(flt(d.base_tax_amount_after_discount_amount) for d in self.get("taxes")
|
||||
if d.category in ["Valuation", "Valuation and Total"])
|
||||
|
||||
valuation_amount_adjustment = total_valuation_amount
|
||||
for i, item in enumerate(self.get("items")):
|
||||
@ -325,7 +325,7 @@ class BuyingController(StockController):
|
||||
def update_raw_materials_supplied_based_on_stock_entries(self):
|
||||
self.set('supplied_items', [])
|
||||
|
||||
purchase_orders = set([d.purchase_order for d in self.items])
|
||||
purchase_orders = set(d.purchase_order for d in self.items)
|
||||
|
||||
# qty of raw materials backflushed (for each item per purchase order)
|
||||
backflushed_raw_materials_map = get_backflushed_subcontracted_raw_materials(purchase_orders)
|
||||
|
@ -88,7 +88,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
|
||||
fields = get_fields("Customer", fields)
|
||||
|
||||
searchfields = frappe.get_meta("Customer").get_search_fields()
|
||||
searchfields = " or ".join([field + " like %(txt)s" for field in searchfields])
|
||||
searchfields = " or ".join(field + " like %(txt)s" for field in searchfields)
|
||||
|
||||
return frappe.db.sql("""select {fields} from `tabCustomer`
|
||||
where docstatus < 2
|
||||
|
@ -428,7 +428,7 @@ class SellingController(StockController):
|
||||
self.po_no = ', '.join(list(set(x.strip() for x in ','.join(po_nos).split(','))))
|
||||
|
||||
def get_po_nos(self, ref_doctype, ref_fieldname, po_nos):
|
||||
doc_list = list(set([d.get(ref_fieldname) for d in self.items if d.get(ref_fieldname)]))
|
||||
doc_list = list(set(d.get(ref_fieldname) for d in self.items if d.get(ref_fieldname)))
|
||||
if doc_list:
|
||||
po_nos += [d.po_no for d in frappe.get_all(ref_doctype, 'po_no', filters = {'name': ('in', doc_list)}) if d.get('po_no')]
|
||||
|
||||
|
@ -299,8 +299,8 @@ class StatusUpdater(Document):
|
||||
args['name'] = self.get(args['percent_join_field_parent'])
|
||||
self._update_percent_field(args, update_modified)
|
||||
else:
|
||||
distinct_transactions = set([d.get(args['percent_join_field'])
|
||||
for d in self.get_all_children(args['source_dt'])])
|
||||
distinct_transactions = set(d.get(args['percent_join_field'])
|
||||
for d in self.get_all_children(args['source_dt']))
|
||||
|
||||
for name in distinct_transactions:
|
||||
if name:
|
||||
|
@ -310,7 +310,7 @@ class StockController(AccountsController):
|
||||
|
||||
def get_serialized_items(self):
|
||||
serialized_items = []
|
||||
item_codes = list(set([d.item_code for d in self.get("items")]))
|
||||
item_codes = list(set(d.item_code for d in self.get("items")))
|
||||
if item_codes:
|
||||
serialized_items = frappe.db.sql_list("""select name from `tabItem`
|
||||
where has_serial_no=1 and name in ({})""".format(", ".join(["%s"]*len(item_codes))),
|
||||
@ -321,8 +321,8 @@ class StockController(AccountsController):
|
||||
def validate_warehouse(self):
|
||||
from erpnext.stock.utils import validate_warehouse_company, validate_disabled_warehouse
|
||||
|
||||
warehouses = list(set([d.warehouse for d in
|
||||
self.get("items") if getattr(d, "warehouse", None)]))
|
||||
warehouses = list(set(d.warehouse for d in
|
||||
self.get("items") if getattr(d, "warehouse", None)))
|
||||
|
||||
target_warehouses = list(set([d.target_warehouse for d in
|
||||
self.get("items") if getattr(d, "target_warehouse", None)]))
|
||||
|
@ -375,10 +375,10 @@ class calculate_taxes_and_totals(object):
|
||||
|
||||
def manipulate_grand_total_for_inclusive_tax(self):
|
||||
# if fully inclusive taxes and diff
|
||||
if self.doc.get("taxes") and any([cint(t.included_in_print_rate) for t in self.doc.get("taxes")]):
|
||||
if self.doc.get("taxes") and any(cint(t.included_in_print_rate) for t in self.doc.get("taxes")):
|
||||
last_tax = self.doc.get("taxes")[-1]
|
||||
non_inclusive_tax_amount = sum([flt(d.tax_amount_after_discount_amount)
|
||||
for d in self.doc.get("taxes") if not d.included_in_print_rate])
|
||||
non_inclusive_tax_amount = sum(flt(d.tax_amount_after_discount_amount)
|
||||
for d in self.doc.get("taxes") if not d.included_in_print_rate)
|
||||
|
||||
diff = self.doc.total + non_inclusive_tax_amount \
|
||||
- flt(last_tax.total, last_tax.precision("total"))
|
||||
@ -518,8 +518,8 @@ class calculate_taxes_and_totals(object):
|
||||
|
||||
def calculate_total_advance(self):
|
||||
if self.doc.docstatus < 2:
|
||||
total_allocated_amount = sum([flt(adv.allocated_amount, adv.precision("allocated_amount"))
|
||||
for adv in self.doc.get("advances")])
|
||||
total_allocated_amount = sum(flt(adv.allocated_amount, adv.precision("allocated_amount"))
|
||||
for adv in self.doc.get("advances"))
|
||||
|
||||
self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))
|
||||
|
||||
@ -619,7 +619,7 @@ class calculate_taxes_and_totals(object):
|
||||
|
||||
if self.doc.doctype == "Sales Invoice" \
|
||||
and self.doc.paid_amount > self.doc.grand_total and not self.doc.is_return \
|
||||
and any([d.type == "Cash" for d in self.doc.payments]):
|
||||
and any(d.type == "Cash" for d in self.doc.payments):
|
||||
grand_total = self.doc.rounded_total or self.doc.grand_total
|
||||
base_grand_total = self.doc.base_rounded_total or self.doc.base_grand_total
|
||||
|
||||
|
@ -26,8 +26,8 @@ class TestMapper(unittest.TestCase):
|
||||
|
||||
# Assert that all inserted items are present in updated sales order
|
||||
src_items = item_list_1 + item_list_2 + item_list_3
|
||||
self.assertEqual(set([d for d in src_items]),
|
||||
set([d.item_code for d in updated_so.items]))
|
||||
self.assertEqual(set(d for d in src_items),
|
||||
set(d.item_code for d in updated_so.items))
|
||||
|
||||
|
||||
def make_quotation(self, item_list, customer):
|
||||
|
@ -113,7 +113,7 @@ def post_process(doctype, data):
|
||||
doc.set_indicator()
|
||||
|
||||
doc.status_display = ", ".join(doc.status_display)
|
||||
doc.items_preview = ", ".join([d.item_name for d in doc.items if d.item_name])
|
||||
doc.items_preview = ", ".join(d.item_name for d in doc.items if d.item_name)
|
||||
result.append(doc)
|
||||
|
||||
return result
|
||||
|
@ -317,7 +317,7 @@ class JobCard(Document):
|
||||
'docstatus': ('!=', 2)}, fields = 'sum(transferred_qty) as qty', group_by='operation_id')
|
||||
|
||||
if job_cards:
|
||||
qty = min([d.qty for d in job_cards])
|
||||
qty = min(d.qty for d in job_cards)
|
||||
|
||||
doc.db_set('material_transferred_for_manufacturing', qty)
|
||||
|
||||
|
@ -232,7 +232,7 @@ def get_project(doctype, txt, searchfield, start, page_len, filters):
|
||||
meta = frappe.get_meta(doctype)
|
||||
searchfields = meta.get_search_fields()
|
||||
search_columns = ", " + ", ".join(searchfields) if searchfields else ''
|
||||
search_cond = " or " + " or ".join([field + " like %(txt)s" for field in searchfields])
|
||||
search_cond = " or " + " or ".join(field + " like %(txt)s" for field in searchfields)
|
||||
|
||||
return frappe.db.sql(""" select name {search_columns} from `tabProject`
|
||||
where %(key)s like %(txt)s
|
||||
|
@ -87,8 +87,8 @@ class Timesheet(Document):
|
||||
|
||||
def set_dates(self):
|
||||
if self.docstatus < 2 and self.time_logs:
|
||||
start_date = min([getdate(d.from_time) for d in self.time_logs])
|
||||
end_date = max([getdate(d.to_time) for d in self.time_logs])
|
||||
start_date = min(getdate(d.from_time) for d in self.time_logs)
|
||||
end_date = max(getdate(d.to_time) for d in self.time_logs)
|
||||
|
||||
if start_date and end_date:
|
||||
self.start_date = getdate(start_date)
|
||||
|
@ -122,7 +122,7 @@ def get_report_summary(data):
|
||||
if not data:
|
||||
return None
|
||||
|
||||
avg_completion = sum([project.percent_complete for project in data]) / len(data)
|
||||
avg_completion = sum(project.percent_complete for project in data) / len(data)
|
||||
total = sum([project.total_tasks for project in data])
|
||||
total_overdue = sum([project.overdue_tasks for project in data])
|
||||
completed = sum([project.completed_tasks for project in data])
|
||||
|
@ -75,7 +75,7 @@ class Customer(TransactionBase):
|
||||
self.loyalty_program_tier = customer.loyalty_program_tier
|
||||
|
||||
if self.sales_team:
|
||||
if sum([member.allocated_percentage or 0 for member in self.sales_team]) != 100:
|
||||
if sum(member.allocated_percentage or 0 for member in self.sales_team) != 100:
|
||||
frappe.throw(_("Total contribution percentage should be equal to 100"))
|
||||
|
||||
def check_customer_group_change(self):
|
||||
|
@ -50,7 +50,7 @@ class Quotation(SellingController):
|
||||
self.customer_name = company_name or lead_name
|
||||
|
||||
def update_opportunity(self, status):
|
||||
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
|
||||
for opportunity in set(d.prevdoc_docname for d in self.get("items")):
|
||||
if opportunity:
|
||||
self.update_opportunity_status(status, opportunity)
|
||||
|
||||
|
@ -151,7 +151,7 @@ class SalesOrder(SellingController):
|
||||
frappe.db.sql("update `tabOpportunity` set status = %s where name=%s",(flag,enq[0][0]))
|
||||
|
||||
def update_prevdoc_status(self, flag=None):
|
||||
for quotation in list(set([d.prevdoc_docname for d in self.get("items")])):
|
||||
for quotation in set(d.prevdoc_docname for d in self.get("items")):
|
||||
if quotation:
|
||||
doc = frappe.get_doc("Quotation", quotation)
|
||||
if doc.docstatus==2:
|
||||
|
@ -54,7 +54,7 @@ class Company(NestedSet):
|
||||
|
||||
def validate_abbr(self):
|
||||
if not self.abbr:
|
||||
self.abbr = ''.join([c[0] for c in self.company_name.split()]).upper()
|
||||
self.abbr = ''.join(c[0] for c in self.company_name.split()).upper()
|
||||
|
||||
self.abbr = self.abbr.strip()
|
||||
|
||||
@ -335,7 +335,7 @@ class Company(NestedSet):
|
||||
clear_defaults_cache()
|
||||
|
||||
def abbreviate(self):
|
||||
self.abbr = ''.join([c[0].upper() for c in self.company_name.split()])
|
||||
self.abbr = ''.join(c[0].upper() for c in self.company_name.split())
|
||||
|
||||
def on_trash(self):
|
||||
"""
|
||||
|
@ -139,7 +139,7 @@ def get_product_list_for_group(product_group=None, start=0, limit=10, search=Non
|
||||
# return child item groups if the type is of "Is Group"
|
||||
return get_child_groups_for_list_in_html(item_group, start, limit, search)
|
||||
|
||||
child_groups = ", ".join([frappe.db.escape(i[0]) for i in get_child_groups(product_group)])
|
||||
child_groups = ", ".join(frappe.db.escape(i[0]) for i in get_child_groups(product_group))
|
||||
|
||||
# base query
|
||||
query = """select I.name, I.item_name, I.item_code, I.route, I.image, I.website_image, I.thumbnail, I.item_group,
|
||||
@ -239,7 +239,7 @@ def get_item_for_list_in_html(context):
|
||||
return frappe.get_template(products_template).render(context)
|
||||
|
||||
def get_group_item_count(item_group):
|
||||
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
|
||||
child_groups = ", ".join('"' + i[0] + '"' for i in get_child_groups(item_group))
|
||||
return frappe.db.sql("""select count(*) from `tabItem`
|
||||
where docstatus = 0 and show_in_website = 1
|
||||
and (item_group in (%s)
|
||||
|
@ -304,7 +304,7 @@ def validate_serial_no_with_batch(serial_nos, item_code):
|
||||
frappe.throw(_("The serial no {0} does not belong to item {1}")
|
||||
.format(get_link_to_form("Serial No", serial_nos[0]), get_link_to_form("Item", item_code)))
|
||||
|
||||
serial_no_link = ','.join([get_link_to_form("Serial No", sn) for sn in serial_nos])
|
||||
serial_no_link = ','.join(get_link_to_form("Serial No", sn) for sn in serial_nos)
|
||||
|
||||
message = "Serial Nos" if len(serial_nos) > 1 else "Serial No"
|
||||
frappe.throw(_("There is no batch found against the {0}: {1}")
|
||||
|
@ -264,7 +264,7 @@ class DeliveryNote(SellingController):
|
||||
"""
|
||||
Validate that if packed qty exists, it should be equal to qty
|
||||
"""
|
||||
if not any([flt(d.get('packed_qty')) for d in self.get("items")]):
|
||||
if not any(flt(d.get('packed_qty')) for d in self.get("items")):
|
||||
return
|
||||
has_error = False
|
||||
for d in self.get("items"):
|
||||
|
@ -68,7 +68,7 @@ class DeliveryTrip(Document):
|
||||
delete (bool, optional): Defaults to `False`. `True` if driver details need to be emptied, else `False`.
|
||||
"""
|
||||
|
||||
delivery_notes = list(set([stop.delivery_note for stop in self.delivery_stops if stop.delivery_note]))
|
||||
delivery_notes = list(set(stop.delivery_note for stop in self.delivery_stops if stop.delivery_note))
|
||||
|
||||
update_fields = {
|
||||
"driver": self.driver,
|
||||
@ -136,8 +136,8 @@ class DeliveryTrip(Document):
|
||||
|
||||
# Include last leg in the final distance calculation
|
||||
self.uom = self.default_distance_uom
|
||||
total_distance = sum([leg.get("distance", {}).get("value", 0.0)
|
||||
for leg in directions.get("legs")]) # in meters
|
||||
total_distance = sum(leg.get("distance", {}).get("value", 0.0)
|
||||
for leg in directions.get("legs")) # in meters
|
||||
self.total_distance = total_distance * self.uom_conversion_factor
|
||||
else:
|
||||
idx += len(route) - 1
|
||||
|
@ -78,7 +78,7 @@ class LandedCostVoucher(Document):
|
||||
.format(item.idx, item.item_code))
|
||||
|
||||
def set_total_taxes_and_charges(self):
|
||||
self.total_taxes_and_charges = sum([flt(d.base_amount) for d in self.get("taxes")])
|
||||
self.total_taxes_and_charges = sum(flt(d.base_amount) for d in self.get("taxes"))
|
||||
|
||||
def set_applicable_charges_on_item(self):
|
||||
if self.get('taxes') and self.distribute_charges_based_on != 'Distribute Manually':
|
||||
@ -104,15 +104,15 @@ class LandedCostVoucher(Document):
|
||||
based_on = self.distribute_charges_based_on.lower()
|
||||
|
||||
if based_on != 'distribute manually':
|
||||
total = sum([flt(d.get(based_on)) for d in self.get("items")])
|
||||
total = sum(flt(d.get(based_on)) for d in self.get("items"))
|
||||
else:
|
||||
# consider for proportion while distributing manually
|
||||
total = sum([flt(d.get('applicable_charges')) for d in self.get("items")])
|
||||
total = sum(flt(d.get('applicable_charges')) for d in self.get("items"))
|
||||
|
||||
if not total:
|
||||
frappe.throw(_("Total {0} for all items is zero, may be you should change 'Distribute Charges Based On'").format(based_on))
|
||||
|
||||
total_applicable_charges = sum([flt(d.applicable_charges) for d in self.get("items")])
|
||||
total_applicable_charges = sum(flt(d.applicable_charges) for d in self.get("items"))
|
||||
|
||||
precision = get_field_precision(frappe.get_meta("Landed Cost Item").get_field("applicable_charges"),
|
||||
currency=frappe.get_cached_value('Company', self.company, "default_currency"))
|
||||
|
@ -311,7 +311,7 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company,
|
||||
|
||||
def distribute_landed_cost_on_items(lcv):
|
||||
based_on = lcv.distribute_charges_based_on.lower()
|
||||
total = sum([flt(d.get(based_on)) for d in lcv.get("items")])
|
||||
total = sum(flt(d.get(based_on)) for d in lcv.get("items"))
|
||||
|
||||
for item in lcv.get("items"):
|
||||
item.applicable_charges = flt(item.get(based_on)) * flt(lcv.total_taxes_and_charges) / flt(total)
|
||||
|
@ -88,9 +88,9 @@ class PackingSlip(Document):
|
||||
rows = [d.item_code for d in self.get("items")]
|
||||
|
||||
# also pick custom fields from delivery note
|
||||
custom_fields = ', '.join(['dni.`{0}`'.format(d.fieldname)
|
||||
custom_fields = ', '.join('dni.`{0}`'.format(d.fieldname)
|
||||
for d in frappe.get_meta("Delivery Note Item").get_custom_fields()
|
||||
if d.fieldtype not in no_value_fields])
|
||||
if d.fieldtype not in no_value_fields)
|
||||
|
||||
if custom_fields:
|
||||
custom_fields = ', ' + custom_fields
|
||||
|
@ -246,7 +246,7 @@ class TestPurchaseReceipt(unittest.TestCase):
|
||||
pr = make_purchase_receipt(item_code="_Test FG Item", qty=10, rate=500, is_subcontracted="Yes")
|
||||
self.assertEqual(len(pr.get("supplied_items")), 2)
|
||||
|
||||
rm_supp_cost = sum([d.amount for d in pr.get("supplied_items")])
|
||||
rm_supp_cost = sum(d.amount for d in pr.get("supplied_items"))
|
||||
self.assertEqual(pr.get("items")[0].rm_supp_cost, flt(rm_supp_cost, 2))
|
||||
|
||||
pr.cancel()
|
||||
|
@ -613,7 +613,7 @@ def fetch_serial_numbers(filters, qty, do_not_include=[]):
|
||||
batch_nos = filters.get("batch_no")
|
||||
expiry_date = filters.get("expiry_date")
|
||||
if batch_nos:
|
||||
batch_no_condition = """and sr.batch_no in ({}) """.format(', '.join(["'%s'" % d for d in batch_nos]))
|
||||
batch_no_condition = """and sr.batch_no in ({}) """.format(', '.join("'%s'" % d for d in batch_nos))
|
||||
|
||||
if expiry_date:
|
||||
batch_join_selection = "LEFT JOIN `tabBatch` batch on sr.batch_no = batch.name "
|
||||
|
@ -465,7 +465,7 @@ class StockEntry(StockController):
|
||||
"""
|
||||
# Set rate for outgoing items
|
||||
outgoing_items_cost = self.set_rate_for_outgoing_items(reset_outgoing_rate, raise_error_if_no_rate)
|
||||
finished_item_qty = sum([d.transfer_qty for d in self.items if d.is_finished_item])
|
||||
finished_item_qty = sum(d.transfer_qty for d in self.items if d.is_finished_item)
|
||||
|
||||
# Set basic rate for incoming items
|
||||
for d in self.get('items'):
|
||||
|
@ -89,7 +89,7 @@ def get_item_price_qty_data(filters):
|
||||
{conditions}"""
|
||||
.format(conditions=conditions), filters, as_dict=1)
|
||||
|
||||
price_list_names = list(set([item.price_list_name for item in item_results]))
|
||||
price_list_names = list(set(item.price_list_name for item in item_results))
|
||||
|
||||
buying_price_map = get_price_map(price_list_names, buying=1)
|
||||
selling_price_map = get_price_map(price_list_names, selling=1)
|
||||
|
@ -66,7 +66,7 @@ def get_consumed_items(condition):
|
||||
purpose is NULL
|
||||
or purpose not in ({})
|
||||
)
|
||||
""".format(', '.join([f"'{p}'" for p in purpose_to_exclude]))
|
||||
""".format(', '.join(f"'{p}'" for p in purpose_to_exclude))
|
||||
condition = condition.replace("posting_date", "sle.posting_date")
|
||||
|
||||
consumed_items = frappe.db.sql("""
|
||||
|
@ -141,7 +141,7 @@ def get_stock_ledger_entries(filters, items):
|
||||
return []
|
||||
|
||||
item_conditions_sql = ' and sle.item_code in ({})' \
|
||||
.format(', '.join([frappe.db.escape(i) for i in items]))
|
||||
.format(', '.join(frappe.db.escape(i) for i in items))
|
||||
|
||||
conditions = get_sle_conditions(filters)
|
||||
|
||||
|
@ -157,7 +157,7 @@ def get_stock_ledger_entries(filters, items):
|
||||
item_conditions_sql = ''
|
||||
if items:
|
||||
item_conditions_sql = ' and sle.item_code in ({})'\
|
||||
.format(', '.join([frappe.db.escape(i, percent=False) for i in items]))
|
||||
.format(', '.join(frappe.db.escape(i, percent=False) for i in items))
|
||||
|
||||
conditions = get_conditions(filters)
|
||||
|
||||
@ -253,7 +253,7 @@ def get_items(filters):
|
||||
def get_item_details(items, sle, filters):
|
||||
item_details = {}
|
||||
if not items:
|
||||
items = list(set([d.item_code for d in sle]))
|
||||
items = list(set(d.item_code for d in sle))
|
||||
|
||||
if not items:
|
||||
return item_details
|
||||
@ -291,7 +291,7 @@ def get_item_reorder_details(items):
|
||||
select parent, warehouse, warehouse_reorder_qty, warehouse_reorder_level
|
||||
from `tabItem Reorder`
|
||||
where parent in ({0})
|
||||
""".format(', '.join([frappe.db.escape(i, percent=False) for i in items])), as_dict=1)
|
||||
""".format(', '.join(frappe.db.escape(i, percent=False) for i in items)), as_dict=1)
|
||||
|
||||
return dict((d.parent + d.warehouse, d) for d in item_reorder_details)
|
||||
|
||||
|
@ -115,7 +115,7 @@ def get_stock_ledger_entries(filters, items):
|
||||
item_conditions_sql = ''
|
||||
if items:
|
||||
item_conditions_sql = 'and sle.item_code in ({})'\
|
||||
.format(', '.join([frappe.db.escape(i) for i in items]))
|
||||
.format(', '.join(frappe.db.escape(i) for i in items))
|
||||
|
||||
sl_entries = frappe.db.sql("""
|
||||
SELECT
|
||||
@ -169,7 +169,7 @@ def get_items(filters):
|
||||
def get_item_details(items, sl_entries, include_uom):
|
||||
item_details = {}
|
||||
if not items:
|
||||
items = list(set([d.item_code for d in sl_entries]))
|
||||
items = list(set(d.item_code for d in sl_entries))
|
||||
|
||||
if not items:
|
||||
return item_details
|
||||
|
@ -521,7 +521,7 @@ class update_entries_after(object):
|
||||
fields=["purchase_rate", "name", "company"],
|
||||
filters = {'name': ('in', serial_nos)})
|
||||
|
||||
incoming_values = sum([flt(d.purchase_rate) for d in all_serial_nos if d.company==sle.company])
|
||||
incoming_values = sum(flt(d.purchase_rate) for d in all_serial_nos if d.company==sle.company)
|
||||
|
||||
# Get rate for serial nos which has been transferred to other company
|
||||
invalid_serial_nos = [d.name for d in all_serial_nos if d.company!=sle.company]
|
||||
|
@ -29,7 +29,7 @@ class WarrantyClaim(TransactionBase):
|
||||
where t2.parent = t1.name and t2.prevdoc_docname = %s and t1.docstatus!=2""",
|
||||
(self.name))
|
||||
if lst:
|
||||
lst1 = ','.join([x[0] for x in lst])
|
||||
lst1 = ','.join(x[0] for x in lst)
|
||||
frappe.throw(_("Cancel Material Visit {0} before cancelling this Warranty Claim").format(lst1))
|
||||
else:
|
||||
frappe.db.set(self, 'status', 'Cancelled')
|
||||
|
@ -131,6 +131,6 @@ def get_non_stock_item_status(item_code, item_warehouse_field):
|
||||
if frappe.db.exists("Product Bundle", item_code):
|
||||
items = frappe.get_doc("Product Bundle", item_code).get_all_children()
|
||||
bundle_warehouse = frappe.db.get_value('Item', item_code, item_warehouse_field)
|
||||
return all([ get_qty_in_stock(d.item_code, item_warehouse_field, bundle_warehouse).in_stock for d in items ])
|
||||
return all(get_qty_in_stock(d.item_code, item_warehouse_field, bundle_warehouse).in_stock for d in items)
|
||||
else:
|
||||
return 1
|
||||
|
@ -147,7 +147,7 @@ class TransactionBase(StatusUpdater):
|
||||
if hasattr(self, "prev_link_mapper") and self.prev_link_mapper.get(for_doctype):
|
||||
fieldname = self.prev_link_mapper[for_doctype]["fieldname"]
|
||||
|
||||
values = filter(None, tuple([item.as_dict()[fieldname] for item in self.items]))
|
||||
values = filter(None, tuple(item.as_dict()[fieldname] for item in self.items))
|
||||
|
||||
if values:
|
||||
ret = {
|
||||
@ -180,7 +180,7 @@ def validate_uom_is_integer(doc, uom_field, qty_fields, child_dt=None):
|
||||
if isinstance(qty_fields, string_types):
|
||||
qty_fields = [qty_fields]
|
||||
|
||||
distinct_uoms = list(set([d.get(uom_field) for d in doc.get_all_children()]))
|
||||
distinct_uoms = list(set(d.get(uom_field) for d in doc.get_all_children()))
|
||||
integer_uoms = list(filter(lambda uom: frappe.db.get_value("UOM", uom,
|
||||
"must_be_whole_number", cache=True) or None, distinct_uoms))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user