Merge pull request #26098 from rohitwaghchaure/enqueue-cancel-action-in-stock-reco
fix: timeout while cancelling stock reconciliation
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
index 2735b1c..0ff7230 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
@@ -257,9 +257,10 @@
},
{
"default": "1",
+ "description": "If enabled, ledger entries will be posted for change amount in POS transactions",
"fieldname": "post_change_gl_entries",
"fieldtype": "Check",
- "label": "Post Ledger Entries for Given Change"
+ "label": "Change Ledger Entries for Change Amount"
}
],
"icon": "icon-cog",
@@ -267,7 +268,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2021-05-25 12:34:05.858669",
+ "modified": "2021-06-16 13:14:45.739107",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Settings",
diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py
index fd86ed4..cfe28f3 100644
--- a/erpnext/accounts/doctype/c_form/c_form.py
+++ b/erpnext/accounts/doctype/c_form/c_form.py
@@ -54,7 +54,7 @@
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()
diff --git a/erpnext/accounts/doctype/coupon_code/coupon_code.py b/erpnext/accounts/doctype/coupon_code/coupon_code.py
index 7829c93..55c1193 100644
--- a/erpnext/accounts/doctype/coupon_code/coupon_code.py
+++ b/erpnext/accounts/doctype/coupon_code/coupon_code.py
@@ -14,7 +14,7 @@
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()
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index 948c513..11465b7 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -121,8 +121,7 @@
def check_pl_account(self):
if self.is_opening=='Yes' and \
- frappe.db.get_value("Account", self.account, "report_type")=="Profit and Loss" and \
- self.voucher_type not in ['Purchase Invoice', 'Sales Invoice']:
+ frappe.db.get_value("Account", self.account, "report_type")=="Profit and Loss":
frappe.throw(_("{0} {1}: 'Profit and Loss' type account {2} not allowed in Opening Entry")
.format(self.voucher_type, self.voucher_no, self.account))
diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
index 95d2ee5..b73d8bf 100644
--- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
+++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
@@ -42,7 +42,7 @@
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()
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index ed1bd28..937597b 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -196,8 +196,8 @@
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:
diff --git a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
index 88667d7..bff6422 100644
--- a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
+++ b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
@@ -21,7 +21,7 @@
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%") + \
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 939f354..d3ac3a6 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -1087,6 +1087,8 @@
initialize_taxes: function(frm) {
$.each(frm.doc["taxes"] || [], function(i, tax) {
+ frm.events.validate_taxes_and_charges(tax);
+ frm.events.validate_inclusive_tax(tax);
tax.item_wise_tax_detail = {};
let tax_fields = ["total", "tax_fraction_for_current_item",
"grand_total_fraction_for_current_item"];
@@ -1101,6 +1103,73 @@
});
},
+ validate_taxes_and_charges: function(d) {
+ let msg = "";
+
+ if (d.account_head && !d.description) {
+ // set description from account head
+ d.description = d.account_head.split(' - ').slice(0, -1).join(' - ');
+ }
+
+ if (!d.charge_type && (d.row_id || d.rate || d.tax_amount)) {
+ msg = __("Please select Charge Type first");
+ d.row_id = "";
+ d.rate = d.tax_amount = 0.0;
+ } else if ((d.charge_type == 'Actual' || d.charge_type == 'On Net Total' || d.charge_type == 'On Paid Amount') && d.row_id) {
+ msg = __("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'");
+ d.row_id = "";
+ } else if ((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) {
+ if (d.idx == 1) {
+ msg = __("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
+ d.charge_type = '';
+ } else if (!d.row_id) {
+ msg = __("Please specify a valid Row ID for row {0} in table {1}", [d.idx, __(d.doctype)]);
+ d.row_id = "";
+ } else if (d.row_id && d.row_id >= d.idx) {
+ msg = __("Cannot refer row number greater than or equal to current row number for this Charge type");
+ d.row_id = "";
+ }
+ }
+ if (msg) {
+ frappe.validated = false;
+ refresh_field("taxes");
+ frappe.throw(msg);
+ }
+
+ },
+
+ validate_inclusive_tax: function(tax) {
+ let actual_type_error = function() {
+ let msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx])
+ frappe.throw(msg);
+ };
+
+ let on_previous_row_error = function(row_range) {
+ let msg = __("For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included",
+ [tax.idx, __(tax.doctype), tax.charge_type, row_range])
+ frappe.throw(msg);
+ };
+
+ if(cint(tax.included_in_paid_amount)) {
+ if(tax.charge_type == "Actual") {
+ // inclusive tax cannot be of type Actual
+ actual_type_error();
+ } else if(tax.charge_type == "On Previous Row Amount" &&
+ !cint(this.frm.doc["taxes"][tax.row_id - 1].included_in_paid_amount)
+ ) {
+ // referred row should also be an inclusive tax
+ on_previous_row_error(tax.row_id);
+ } else if(tax.charge_type == "On Previous Row Total") {
+ let taxes_not_included = $.map(this.frm.doc["taxes"].slice(0, tax.row_id),
+ function(t) { return cint(t.included_in_paid_amount) ? null : t; });
+ if(taxes_not_included.length > 0) {
+ // all rows above this tax should be inclusive
+ on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id);
+ }
+ }
+ }
+ },
+
determine_exclusive_rate: function(frm) {
let has_inclusive_tax = false;
$.each(frm.doc["taxes"] || [], function(i, row) {
@@ -1110,8 +1179,7 @@
let cumulated_tax_fraction = 0.0;
$.each(frm.doc["taxes"] || [], function(i, tax) {
- let current_tax_fraction = frm.events.get_current_tax_fraction(frm, tax);
- tax.tax_fraction_for_current_item = current_tax_fraction[0];
+ tax.tax_fraction_for_current_item = frm.events.get_current_tax_fraction(frm, tax);
if(i==0) {
tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item;
@@ -1132,9 +1200,7 @@
if(cint(tax.included_in_paid_amount)) {
let tax_rate = tax.rate;
- if (tax.charge_type == "Actual") {
- current_tax_fraction = tax.tax_amount/(frm.doc.paid_amount_after_tax + frm.doc.tax_amount);
- } else if(tax.charge_type == "On Paid Amount") {
+ if(tax.charge_type == "On Paid Amount") {
current_tax_fraction = (tax_rate / 100.0);
} else if(tax.charge_type == "On Previous Row Amount") {
current_tax_fraction = (tax_rate / 100.0) *
@@ -1147,7 +1213,6 @@
if(tax.add_deduct_tax && tax.add_deduct_tax == "Deduct") {
current_tax_fraction *= -1;
- inclusive_tax_amount_per_qty *= -1;
}
return current_tax_fraction;
},
@@ -1207,10 +1272,8 @@
frappe.throw(
__("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
}
- if (!tax.row_id) {
- tax.row_id = tax.idx - 1;
- }
}
+
if(tax.charge_type == "Actual") {
current_tax_amount = flt(tax.tax_amount, precision("tax_amount", tax))
} else if(tax.charge_type == "On Paid Amount") {
@@ -1296,6 +1359,11 @@
included_in_paid_amount: function(frm) {
frm.events.apply_taxes(frm);
frm.events.set_unallocated_amount(frm);
+ },
+
+ charge_type: function(frm) {
+ frm.events.apply_taxes(frm);
+ frm.events.set_unallocated_amount(frm);
}
})
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index edca210..b6b2bef 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe, erpnext, json
-from frappe import _, scrub, ValidationError
+from frappe import _, scrub, ValidationError, throw
from frappe.utils import flt, comma_or, nowdate, getdate, cint
from erpnext.accounts.utils import get_outstanding_invoices, get_account_currency, get_balance_on
from erpnext.accounts.party import get_party_account
@@ -16,9 +16,10 @@
from erpnext.controllers.accounts_controller import AccountsController, get_supplier_block_status
from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import get_party_account_based_on_invoice_discounting
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details
-
from six import string_types, iteritems
+from erpnext.controllers.accounts_controller import validate_taxes_and_charges
+
class InvalidPaymentEntry(ValidationError):
pass
@@ -309,7 +310,7 @@
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")
@@ -407,20 +408,6 @@
net_total = self.paid_amount
included_in_paid_amount = 0
- if self.get('references'):
- for doc in self.get('references'):
- if doc.reference_doctype == 'Purchase Order':
- reference_doclist.append(doc.reference_name)
-
- if reference_doclist:
- order_amount = frappe.db.get_all('Purchase Order', fields=['sum(net_total)'],
- filters = {'name': ('in', reference_doclist), 'docstatus': 1,
- 'apply_tds': 1}, as_list=1)
-
- if order_amount:
- net_total = order_amount[0][0]
- included_in_paid_amount = 1
-
# Adding args as purchase invoice to get TDS amount
args = frappe._dict({
'company': self.company,
@@ -524,7 +511,7 @@
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_after_tax + total_deductions \
and self.total_allocated_amount < self.paid_amount_after_tax + (total_deductions / self.source_exchange_rate):
@@ -549,7 +536,7 @@
else:
self.difference_amount = self.base_paid_amount_after_tax - flt(self.base_received_amount_after_tax)
- 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"))
@@ -565,8 +552,8 @@
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])
@@ -719,9 +706,9 @@
if account_currency != self.company_currency:
frappe.throw(_("Currency for {0} must be {1}").format(d.account_head, self.company_currency))
- if (self.payment_type == 'Pay' and self.advance_tax_account) or self.payment_type == 'Receive':
+ if self.payment_type == 'Pay':
dr_or_cr = "debit" if d.add_deduct_tax == "Add" else "credit"
- elif (self.payment_type == 'Receive' and self.advance_tax_account) or self.payment_type == 'Pay':
+ elif self.payment_type == 'Receive':
dr_or_cr = "credit" if d.add_deduct_tax == "Add" else "debit"
payment_or_advance_account = self.get_party_account_for_taxes()
@@ -747,6 +734,8 @@
if account_currency==self.company_currency
else d.tax_amount,
"cost_center": self.cost_center,
+ "party_type": self.party_type,
+ "party": self.party
}, account_currency, item=d))
def add_deductions_gl_entries(self, gl_entries):
@@ -770,9 +759,9 @@
def get_party_account_for_taxes(self):
if self.advance_tax_account:
return self.advance_tax_account
- elif self.payment_type == 'Pay':
- return self.paid_from
elif self.payment_type == 'Receive':
+ return self.paid_from
+ elif self.payment_type == 'Pay':
return self.paid_to
def update_advance_paid(self):
@@ -823,6 +812,9 @@
def initialize_taxes(self):
for tax in self.get("taxes"):
+ validate_taxes_and_charges(tax)
+ validate_inclusive_tax(tax, self)
+
tax_fields = ["total", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]
if tax.charge_type != "Actual":
@@ -918,15 +910,11 @@
if cint(tax.included_in_paid_amount):
tax_rate = tax.rate
- if tax.charge_type == 'Actual':
- current_tax_fraction = tax.tax_amount/ (self.paid_amount_after_tax + tax.tax_amount)
- elif tax.charge_type == "On Paid Amount":
+ if tax.charge_type == "On Paid Amount":
current_tax_fraction = tax_rate / 100.0
-
elif tax.charge_type == "On Previous Row Amount":
current_tax_fraction = (tax_rate / 100.0) * \
self.get("taxes")[cint(tax.row_id) - 1].tax_fraction_for_current_item
-
elif tax.charge_type == "On Previous Row Total":
current_tax_fraction = (tax_rate / 100.0) * \
self.get("taxes")[cint(tax.row_id) - 1].grand_total_fraction_for_current_item
@@ -936,6 +924,25 @@
return current_tax_fraction
+def validate_inclusive_tax(tax, doc):
+ def _on_previous_row_error(row_range):
+ throw(_("To include tax in row {0} in Item rate, taxes in rows {1} must also be included").format(tax.idx, row_range))
+
+ if cint(getattr(tax, "included_in_paid_amount", None)):
+ if tax.charge_type == "Actual":
+ # inclusive tax cannot be of type Actual
+ throw(_("Charge of type 'Actual' in row {0} cannot be included in Item Rate or Paid Amount").format(tax.idx))
+ elif tax.charge_type == "On Previous Row Amount" and \
+ not cint(doc.get("taxes")[cint(tax.row_id) - 1].included_in_paid_amount):
+ # referred row should also be inclusive
+ _on_previous_row_error(tax.row_id)
+ elif tax.charge_type == "On Previous Row Total" and \
+ not all([cint(t.included_in_paid_amount for t in doc.get("taxes")[:cint(tax.row_id) - 1])]):
+ # all rows about the referred tax should be inclusive
+ _on_previous_row_error("1 - %d" % (cint(tax.row_id),))
+ elif tax.get("category") == "Valuation":
+ frappe.throw(_("Valuation type charges can not be marked as Inclusive"))
+
@frappe.whitelist()
def get_outstanding_reference_documents(args):
@@ -1626,6 +1633,13 @@
paid_amount = received_amount * doc.get('conversion_rate', 1)
if dt == "Employee Advance":
paid_amount = received_amount * doc.get('exchange_rate', 1)
+
+ if dt == "Purchase Order" and doc.apply_tds:
+ if party_account_currency == bank.account_currency:
+ paid_amount = received_amount = doc.base_net_total
+ else:
+ paid_amount = received_amount = doc.base_net_total * doc.get('exchange_rate', 1)
+
return paid_amount, received_amount
def apply_early_payment_discount(paid_amount, received_amount, doc):
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 4689787..438951d 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -112,7 +112,7 @@
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):
diff --git a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py
index 80e3348..39627eb 100644
--- a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py
+++ b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py
@@ -26,7 +26,7 @@
def check_duplicate_terms(self):
terms = []
for term in self.terms:
- term_info = (term.credit_days, term.credit_months, term.due_date_based_on)
+ term_info = (term.payment_term, term.credit_days, term.credit_months, term.due_date_based_on)
if term_info in terms:
frappe.msgprint(
_('The Payment Term at row {0} is possibly a duplicate.').format(term.idx),
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index d23b952..b54d0e7 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -20,9 +20,9 @@
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 @@
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 @@
# 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 @@
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 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:
@@ -589,4 +589,4 @@
elif transaction_type=='cancelled':
if coupon.used>0:
coupon.used=coupon.used-1
- coupon.save(ignore_permissions=True)
\ No newline at end of file
+ coupon.save(ignore_permissions=True)
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 723d151..503dda7 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -632,7 +632,7 @@
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):
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index 10e1c73..8a55ff8 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -272,7 +272,7 @@
"fieldname": "rate",
"fieldtype": "Currency",
"in_list_view": 1,
- "label": "Rate ",
+ "label": "Rate",
"oldfieldname": "import_rate",
"oldfieldtype": "Currency",
"options": "currency",
@@ -854,7 +854,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2021-03-30 09:02:39.256602",
+ "modified": "2021-06-16 19:57:03.101571",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json
index 9b07645..1fa68e0 100644
--- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json
+++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json
@@ -218,6 +218,7 @@
},
{
"default": "0",
+ "depends_on": "eval:['Purchase Taxes and Charges Template', 'Payment Entry'].includes(parent.doctype)",
"description": "If checked, the tax amount will be considered as already included in the Paid Amount in Payment Entry",
"fieldname": "included_in_paid_amount",
"fieldtype": "Check",
@@ -227,7 +228,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2021-06-09 11:48:25.335733",
+ "modified": "2021-06-14 01:43:50.750455",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Taxes and Charges",
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 5010fdc..114b7d2 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1937,69 +1937,53 @@
frappe.flags.country = country
def test_einvoice_json(self):
- from erpnext.regional.india.e_invoice.utils import make_einvoice
+ from erpnext.regional.india.e_invoice.utils import make_einvoice, validate_totals
- si = make_sales_invoice_for_ewaybill()
- si.naming_series = 'INV-2020-.#####'
- si.items = []
- si.append("items", {
- "item_code": "_Test Item",
- "uom": "Nos",
- "warehouse": "_Test Warehouse - _TC",
- "qty": 2000,
- "rate": 12,
- "income_account": "Sales - _TC",
- "expense_account": "Cost of Goods Sold - _TC",
- "cost_center": "_Test Cost Center - _TC",
- })
- si.append("items", {
- "item_code": "_Test Item 2",
- "uom": "Nos",
- "warehouse": "_Test Warehouse - _TC",
- "qty": 420,
- "rate": 15,
- "income_account": "Sales - _TC",
- "expense_account": "Cost of Goods Sold - _TC",
- "cost_center": "_Test Cost Center - _TC",
- })
+ si = get_sales_invoice_for_e_invoice()
si.discount_amount = 100
si.save()
einvoice = make_einvoice(si)
-
- total_item_ass_value = 0
- total_item_cgst_value = 0
- total_item_sgst_value = 0
- total_item_igst_value = 0
- total_item_value = 0
-
- for item in einvoice['ItemList']:
- total_item_ass_value += item['AssAmt']
- total_item_cgst_value += item['CgstAmt']
- total_item_sgst_value += item['SgstAmt']
- total_item_igst_value += item['IgstAmt']
- total_item_value += item['TotItemVal']
-
- self.assertTrue(item['AssAmt'], item['TotAmt'] - item['Discount'])
- self.assertTrue(item['TotItemVal'], item['AssAmt'] + item['CgstAmt'] + item['SgstAmt'] + item['IgstAmt'])
-
- value_details = einvoice['ValDtls']
-
- self.assertEqual(einvoice['Version'], '1.1')
- self.assertEqual(value_details['AssVal'], total_item_ass_value)
- self.assertEqual(value_details['CgstVal'], total_item_cgst_value)
- self.assertEqual(value_details['SgstVal'], total_item_sgst_value)
- self.assertEqual(value_details['IgstVal'], total_item_igst_value)
-
- calculated_invoice_value = \
- value_details['AssVal'] + value_details['CgstVal'] \
- + value_details['SgstVal'] + value_details['IgstVal'] \
- + value_details['OthChrg'] - value_details['Discount']
-
- self.assertTrue(value_details['TotInvVal'] - calculated_invoice_value < 0.1)
-
- self.assertEqual(value_details['TotInvVal'], si.base_grand_total)
self.assertTrue(einvoice['EwbDtls'])
+ validate_totals(einvoice)
+
+ si.apply_discount_on = 'Net Total'
+ si.save()
+ einvoice = make_einvoice(si)
+ validate_totals(einvoice)
+
+ [d.set('included_in_print_rate', 1) for d in si.taxes]
+ si.save()
+ einvoice = make_einvoice(si)
+ validate_totals(einvoice)
+
+def get_sales_invoice_for_e_invoice():
+ si = make_sales_invoice_for_ewaybill()
+ si.naming_series = 'INV-2020-.#####'
+ si.items = []
+ si.append("items", {
+ "item_code": "_Test Item",
+ "uom": "Nos",
+ "warehouse": "_Test Warehouse - _TC",
+ "qty": 2000,
+ "rate": 12,
+ "income_account": "Sales - _TC",
+ "expense_account": "Cost of Goods Sold - _TC",
+ "cost_center": "_Test Cost Center - _TC",
+ })
+
+ si.append("items", {
+ "item_code": "_Test Item 2",
+ "uom": "Nos",
+ "warehouse": "_Test Warehouse - _TC",
+ "qty": 420,
+ "rate": 15,
+ "income_account": "Sales - _TC",
+ "expense_account": "Cost of Goods Sold - _TC",
+ "cost_center": "_Test Cost Center - _TC",
+ })
+
+ return si
def test_item_tax_net_range(self):
item = create_item("T Shirt")
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
index 170d34e..1b7a0fe 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
@@ -195,6 +195,7 @@
},
{
"default": "0",
+ "depends_on": "eval:['Sales Taxes and Charges Template', 'Payment Entry'].includes(parent.doctype)",
"description": "If checked, the tax amount will be considered as already included in the Paid Amount in Payment Entry",
"fieldname": "included_in_paid_amount",
"fieldtype": "Check",
@@ -205,7 +206,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2021-06-09 11:48:04.691596",
+ "modified": "2021-06-14 01:44:36.899147",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Taxes and Charges",
diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
index 0cea761..dd26be7 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
@@ -112,7 +112,7 @@
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)
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index d4b2494..59009ae 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -143,7 +143,7 @@
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
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index e01cb6e..e025fc6 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -457,7 +457,7 @@
frappe.throw(_("{0} {1} is frozen").format(party_type, party_name), PartyFrozen)
elif party_type == "Employee":
- if frappe.db.get_value("Employee", party_name, "status") == "Left":
+ if frappe.db.get_value("Employee", party_name, "status") != "Active":
frappe.msgprint(_("{0} {1} is not active").format(party_type, party_name), alert=True)
def get_timeline_data(doctype, name):
diff --git a/erpnext/accounts/report/cash_flow/custom_cash_flow.py b/erpnext/accounts/report/cash_flow/custom_cash_flow.py
index ff87276..c11c153 100644
--- a/erpnext/accounts/report/cash_flow/custom_cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/custom_cash_flow.py
@@ -32,7 +32,7 @@
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 @@
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 @@
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)
diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
index 10b32fe..c79d740 100644
--- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
+++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
@@ -145,7 +145,7 @@
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, {})
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index d20ddbd..39ff804 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -369,7 +369,7 @@
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,
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.js b/erpnext/accounts/report/general_ledger/general_ledger.js
index 84f7868..4a551b8 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.js
+++ b/erpnext/accounts/report/general_ledger/general_ledger.js
@@ -36,16 +36,12 @@
{
"fieldname":"account",
"label": __("Account"),
- "fieldtype": "Link",
+ "fieldtype": "MultiSelectList",
"options": "Account",
- "get_query": function() {
- var company = frappe.query_report.get_filter_value('company');
- return {
- "doctype": "Account",
- "filters": {
- "company": company,
- }
- }
+ get_data: function(txt) {
+ return frappe.db.get_link_options('Account', txt, {
+ company: frappe.query_report.get_filter_value("company")
+ });
}
},
{
@@ -135,7 +131,9 @@
"label": __("Cost Center"),
"fieldtype": "MultiSelectList",
get_data: function(txt) {
- return frappe.db.get_link_options('Cost Center', txt);
+ return frappe.db.get_link_options('Cost Center', txt, {
+ company: frappe.query_report.get_filter_value("company")
+ });
}
},
{
@@ -143,7 +141,9 @@
"label": __("Project"),
"fieldtype": "MultiSelectList",
get_data: function(txt) {
- return frappe.db.get_link_options('Project', txt);
+ return frappe.db.get_link_options('Project', txt, {
+ company: frappe.query_report.get_filter_value("company")
+ });
}
},
{
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index 562df4f..03808c3 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -49,8 +49,12 @@
if not filters.get("from_date") and not filters.get("to_date"):
frappe.throw(_("{0} and {1} are mandatory").format(frappe.bold(_("From Date")), frappe.bold(_("To Date"))))
- if filters.get("account") and not account_details.get(filters.account):
- frappe.throw(_("Account {0} does not exists").format(filters.account))
+ for account in filters.account:
+ if not account_details.get(account):
+ frappe.throw(_("Account {0} does not exists").format(account))
+
+ if filters.get('account'):
+ filters.account = frappe.parse_json(filters.get('account'))
if (filters.get("account") and filters.get("group_by") == _('Group by Account')
and account_details[filters.account].is_group == 0):
@@ -87,7 +91,19 @@
account_currency = None
if filters.get("account"):
- account_currency = get_account_currency(filters.account)
+ if len(filters.get("account")) == 1:
+ account_currency = get_account_currency(filters.account[0])
+ else:
+ currency = get_account_currency(filters.account[0])
+ is_same_account_currency = True
+ for account in filters.get("account"):
+ if get_account_currency(account) != currency:
+ is_same_account_currency = False
+ break
+
+ if is_same_account_currency:
+ account_currency = currency
+
elif filters.get("party"):
gle_currency = frappe.db.get_value(
"GL Entry", {
@@ -205,10 +221,10 @@
def get_conditions(filters):
conditions = []
+
if filters.get("account") and not filters.get("include_dimensions"):
- lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"])
- conditions.append("""account in (select name from tabAccount
- where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
+ filters.account = get_accounts_with_children(filters.account)
+ conditions.append("account in %(account)s")
if filters.get("cost_center"):
filters.cost_center = get_cost_centers_with_children(filters.cost_center)
@@ -266,6 +282,20 @@
return "and {}".format(" and ".join(conditions)) if conditions else ""
+def get_accounts_with_children(accounts):
+ if not isinstance(accounts, list):
+ accounts = [d.strip() for d in accounts.strip().split(',') if d]
+
+ all_accounts = []
+ for d in accounts:
+ if frappe.db.exists("Account", d):
+ lft, rgt = frappe.db.get_value("Account", d, ["lft", "rgt"])
+ children = frappe.get_all("Account", filters={"lft": [">=", lft], "rgt": ["<=", rgt]})
+ all_accounts += [c.name for c in children]
+ else:
+ frappe.throw(_("Account: {0} does not exist").format(d))
+
+ return list(set(all_accounts))
def get_data_with_opening_closing(filters, account_details, accounting_dimensions, gl_entries):
data = []
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index cb4d9b4..685419a 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -334,7 +334,7 @@
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("""
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index 928b373..2e794da 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -23,7 +23,7 @@
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 = []
diff --git a/erpnext/accounts/report/pos_register/pos_register.py b/erpnext/accounts/report/pos_register/pos_register.py
index cfbd7fd..6a42bb4 100644
--- a/erpnext/accounts/report/pos_register/pos_register.py
+++ b/erpnext/accounts/report/pos_register/pos_register.py
@@ -77,14 +77,14 @@
), 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,
diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py
index 8ac749d..10edd41 100644
--- a/erpnext/accounts/report/purchase_register/purchase_register.py
+++ b/erpnext/accounts/report/purchase_register/purchase_register.py
@@ -26,7 +26,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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:
diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py
index c234da0..ff77468 100644
--- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py
+++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py
@@ -158,7 +158,7 @@
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_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
diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py
index cb2c98b..9099593 100644
--- a/erpnext/accounts/report/sales_register/sales_register.py
+++ b/erpnext/accounts/report/sales_register/sales_register.py
@@ -248,19 +248,19 @@
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_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 @@
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 @@
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 @@
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 @@
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:
diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
index a8280c1..e15715d 100644
--- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
+++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
@@ -78,7 +78,7 @@
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 @@
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]
diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py
index b020d0a..ba461ed 100644
--- a/erpnext/accounts/report/utils.py
+++ b/erpnext/accounts/report/utils.py
@@ -139,6 +139,6 @@
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
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 5a64e27..66a9b60 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -635,7 +635,7 @@
'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
diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py
index 3cd4b80..8845f24 100644
--- a/erpnext/assets/doctype/asset/test_asset.py
+++ b/erpnext/assets/doctype/asset/test_asset.py
@@ -470,7 +470,7 @@
})
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))
diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
index 1430827..2f6b5ee 100644
--- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
+++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
@@ -92,7 +92,7 @@
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
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 782593a..2629ba7 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -139,7 +139,7 @@
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))
@@ -326,10 +326,10 @@
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:
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index 3917196..3b9f8e9 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -359,7 +359,7 @@
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)
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index 180ba93..0127eb8 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -391,7 +391,7 @@
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")
diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
index de2ae8f..68426ab 100644
--- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
+++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
@@ -9,10 +9,10 @@
if filters.from_date >= filters.to_date:
frappe.msgprint(_("To Date must be greater than From Date"))
- data = []
columns = get_columns()
- get_data(data , filters)
- return columns, data
+ data = get_data(filters)
+
+ return columns, data or []
def get_columns():
return [
@@ -21,13 +21,12 @@
"fieldtype": "Link",
"fieldname": "purchase_order",
"options": "Purchase Order",
- "width": 150
+ "width": 200
},
{
"label": _("Date"),
"fieldtype": "Date",
"fieldname": "date",
- "hidden": 1,
"width": 150
},
{
@@ -41,97 +40,58 @@
"label": _("Item Code"),
"fieldtype": "Data",
"fieldname": "rm_item_code",
- "width": 100
+ "width": 150
},
{
"label": _("Required Quantity"),
"fieldtype": "Float",
- "fieldname": "r_qty",
- "width": 100
+ "fieldname": "reqd_qty",
+ "width": 150
},
{
"label": _("Transferred Quantity"),
"fieldtype": "Float",
- "fieldname": "t_qty",
- "width": 100
+ "fieldname": "transferred_qty",
+ "width": 200
},
{
"label": _("Pending Quantity"),
"fieldtype": "Float",
"fieldname": "p_qty",
- "width": 100
+ "width": 150
}
]
-def get_data(data, filters):
- po = get_po(filters)
- po_transferred_qty_map = frappe._dict(get_transferred_quantity([v.name for v in po]))
+def get_data(filters):
+ po_rm_item_details = get_po_items_to_supply(filters)
- sub_items = get_purchase_order_item_supplied([v.name for v in po])
+ data = []
+ for row in po_rm_item_details:
+ transferred_qty = row.get("transferred_qty") or 0
+ if transferred_qty < row.get("reqd_qty", 0):
+ pending_qty = frappe.utils.flt(row.get("reqd_qty", 0) - transferred_qty)
+ row.p_qty = pending_qty if pending_qty > 0 else 0
+ data.append(row)
- for order in po:
- for item in sub_items:
- if order.name == item.parent and order.name in po_transferred_qty_map and \
- item.required_qty != po_transferred_qty_map.get(order.name).get(item.rm_item_code):
- transferred_qty = po_transferred_qty_map.get(order.name).get(item.rm_item_code) \
- if po_transferred_qty_map.get(order.name).get(item.rm_item_code) else 0
- row ={
- 'purchase_order': item.parent,
- 'date': order.transaction_date,
- 'supplier': order.supplier,
- 'rm_item_code': item.rm_item_code,
- 'r_qty': item.required_qty,
- 't_qty':transferred_qty,
- 'p_qty':item.required_qty - transferred_qty
- }
+ return data
- data.append(row)
-
- return(data)
-
-def get_po(filters):
- record_filters = [
- ["is_subcontracted", "=", "Yes"],
- ["supplier", "=", filters.supplier],
- ["transaction_date", "<=", filters.to_date],
- ["transaction_date", ">=", filters.from_date],
- ["docstatus", "=", 1]
- ]
- return frappe.get_all("Purchase Order", filters=record_filters, fields=["name", "transaction_date", "supplier"])
-
-def get_transferred_quantity(po_name):
- stock_entries = get_stock_entry(po_name)
- stock_entries_detail = get_stock_entry_detail([v.name for v in stock_entries])
- po_transferred_qty_map = {}
-
-
- for entry in stock_entries:
- for details in stock_entries_detail:
- if details.parent == entry.name:
- details["Purchase_order"] = entry.purchase_order
- if entry.purchase_order not in po_transferred_qty_map:
- po_transferred_qty_map[entry.purchase_order] = {}
- po_transferred_qty_map[entry.purchase_order][details.item_code] = details.qty
- else:
- po_transferred_qty_map[entry.purchase_order][details.item_code] = po_transferred_qty_map[entry.purchase_order].get(details.item_code, 0) + details.qty
-
- return po_transferred_qty_map
-
-
-def get_stock_entry(po):
- return frappe.get_all("Stock Entry", filters=[
- ('purchase_order', 'IN', po),
- ('stock_entry_type', '=', 'Send to Subcontractor'),
- ('docstatus', '=', 1)
- ], fields=["name", "purchase_order"])
-
-def get_stock_entry_detail(se):
- return frappe.get_all("Stock Entry Detail", filters=[
- ["parent", "in", se]
+def get_po_items_to_supply(filters):
+ return frappe.db.get_all(
+ "Purchase Order",
+ fields=[
+ "name as purchase_order",
+ "transaction_date as date",
+ "supplier as supplier",
+ "`tabPurchase Order Item Supplied`.rm_item_code as rm_item_code",
+ "`tabPurchase Order Item Supplied`.required_qty as reqd_qty",
+ "`tabPurchase Order Item Supplied`.supplied_qty as transferred_qty"
],
- fields=["parent", "item_code", "qty"])
-
-def get_purchase_order_item_supplied(po):
- return frappe.get_all("Purchase Order Item Supplied", filters=[
- ('parent', 'IN', po)
- ], fields=['parent', 'rm_item_code', 'required_qty'])
+ filters = [
+ ["Purchase Order", "per_received", "<", "100"],
+ ["Purchase Order", "is_subcontracted", "=", "Yes"],
+ ["Purchase Order", "supplier", "=", filters.supplier],
+ ["Purchase Order", "transaction_date", "<=", filters.to_date],
+ ["Purchase Order", "transaction_date", ">=", filters.from_date],
+ ["Purchase Order", "docstatus", "=", 1]
+ ]
+ )
\ No newline at end of file
diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
index c1fc6fb..2448e17 100644
--- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
+++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
@@ -12,34 +12,80 @@
class TestSubcontractedItemToBeTransferred(unittest.TestCase):
def test_pending_and_transferred_qty(self):
- po = create_purchase_order(item_code='_Test FG Item', is_subcontracted='Yes')
+ po = create_purchase_order(item_code='_Test FG Item', is_subcontracted='Yes', supplier_warehouse="_Test Warehouse 1 - _TC")
+
+ # Material Receipt of RMs
make_stock_entry(item_code='_Test Item', target='_Test Warehouse - _TC', qty=100, basic_rate=100)
make_stock_entry(item_code='_Test Item Home Desktop 100', target='_Test Warehouse - _TC', qty=100, basic_rate=100)
- transfer_subcontracted_raw_materials(po.name)
- col, data = execute(filters=frappe._dict({'supplier': po.supplier,
- 'from_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=-10)),
- 'to_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=10))}))
- self.assertEqual(data[0]['purchase_order'], po.name)
- self.assertIn(data[0]['rm_item_code'], ['_Test Item', '_Test Item Home Desktop 100'])
- self.assertIn(data[0]['p_qty'], [9, 18])
- self.assertIn(data[0]['t_qty'], [1, 2])
- self.assertEqual(data[1]['purchase_order'], po.name)
- self.assertIn(data[1]['rm_item_code'], ['_Test Item', '_Test Item Home Desktop 100'])
- self.assertIn(data[1]['p_qty'], [9, 18])
- self.assertIn(data[1]['t_qty'], [1, 2])
+ se = transfer_subcontracted_raw_materials(po)
+ col, data = execute(filters=frappe._dict(
+ {
+ 'supplier': po.supplier,
+ 'from_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=-10)),
+ 'to_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=10))
+ }
+ ))
+ po.reload()
+
+ po_data = [row for row in data if row.get('purchase_order') == po.name]
+ # Alphabetically sort to be certain of order
+ po_data = sorted(po_data, key = lambda i: i['rm_item_code'])
+
+ self.assertEqual(len(po_data), 2)
+ self.assertEqual(po_data[0]['purchase_order'], po.name)
+
+ self.assertEqual(po_data[0]['rm_item_code'], '_Test Item')
+ self.assertEqual(po_data[0]['p_qty'], 8)
+ self.assertEqual(po_data[0]['transferred_qty'], 2)
+
+ self.assertEqual(po_data[1]['rm_item_code'], '_Test Item Home Desktop 100')
+ self.assertEqual(po_data[1]['p_qty'], 19)
+ self.assertEqual(po_data[1]['transferred_qty'], 1)
+
+ se.cancel()
+ po.cancel()
def transfer_subcontracted_raw_materials(po):
+ # Order of supplied items fetched in PO is flaky
+ transfer_qty_map = {
+ '_Test Item': 2,
+ '_Test Item Home Desktop 100': 1
+ }
+
+ item_1 = po.supplied_items[0].rm_item_code
+ item_2 = po.supplied_items[1].rm_item_code
+
rm_item = [
- {'item_code': '_Test Item', 'rm_item_code': '_Test Item', 'item_name': '_Test Item', 'qty': 1,
- 'warehouse': '_Test Warehouse - _TC', 'rate': 100, 'amount': 100, 'stock_uom': 'Nos'},
- {'item_code': '_Test Item Home Desktop 100', 'rm_item_code': '_Test Item Home Desktop 100', 'item_name': '_Test Item Home Desktop 100', 'qty': 2,
- 'warehouse': '_Test Warehouse - _TC', 'rate': 100, 'amount': 200, 'stock_uom': 'Nos'}]
+ {
+ 'name': po.supplied_items[0].name,
+ 'item_code': item_1,
+ 'rm_item_code': item_1,
+ 'item_name': item_1,
+ 'qty': transfer_qty_map[item_1],
+ 'warehouse': '_Test Warehouse - _TC',
+ 'rate': 100,
+ 'amount': 100 * transfer_qty_map[item_1],
+ 'stock_uom': 'Nos'
+ },
+ {
+ 'name': po.supplied_items[1].name,
+ 'item_code': item_2,
+ 'rm_item_code': item_2,
+ 'item_name': item_2,
+ 'qty': transfer_qty_map[item_2],
+ 'warehouse': '_Test Warehouse - _TC',
+ 'rate': 100,
+ 'amount': 100 * transfer_qty_map[item_2],
+ 'stock_uom': 'Nos'
+ }
+ ]
rm_item_string = json.dumps(rm_item)
- se = frappe.get_doc(make_rm_stock_entry(po, rm_item_string))
- se.from_warehouse = '_Test Warehouse 1 - _TC'
- se.to_warehouse = '_Test Warehouse 1 - _TC'
+ se = frappe.get_doc(make_rm_stock_entry(po.name, rm_item_string))
+ se.from_warehouse = '_Test Warehouse - _TC'
+ se.to_warehouse = '_Test Warehouse - _TC'
se.stock_entry_type = 'Send to Subcontractor'
se.save()
se.submit()
+ return se
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 53ded33..243939b 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -610,8 +610,8 @@
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)
@@ -635,8 +635,8 @@
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
@@ -1192,7 +1192,7 @@
def validate_taxes_and_charges(tax):
- if tax.charge_type in ['Actual', 'On Net Total'] and tax.row_id:
+ if tax.charge_type in ['Actual', 'On Net Total', 'On Paid Amount'] and tax.row_id:
frappe.throw(_("Can refer row only if the charge type is 'On Previous Row Amount' or 'Previous Row Total'"))
elif tax.charge_type in ['On Previous Row Amount', 'On Previous Row Total']:
if cint(tax.idx) == 1:
@@ -1209,20 +1209,19 @@
def validate_inclusive_tax(tax, doc):
def _on_previous_row_error(row_range):
- throw(_("To include tax in row {0} in Item rate, taxes in rows {1} must also be included").format(tax.idx,
- row_range))
+ throw(_("To include tax in row {0} in Item rate, taxes in rows {1} must also be included").format(tax.idx, row_range))
if cint(getattr(tax, "included_in_print_rate", None)):
if tax.charge_type == "Actual":
# inclusive tax cannot be of type Actual
- throw(_("Charge of type 'Actual' in row {0} cannot be included in Item Rate").format(tax.idx))
+ throw(_("Charge of type 'Actual' in row {0} cannot be included in Item Rate or Paid Amount").format(tax.idx))
elif tax.charge_type == "On Previous Row Amount" and \
not cint(doc.get("taxes")[cint(tax.row_id) - 1].included_in_print_rate):
# referred row should also be inclusive
_on_previous_row_error(tax.row_id)
elif tax.charge_type == "On Previous Row Total" and \
not all([cint(t.included_in_print_rate) for t in doc.get("taxes")[:cint(tax.row_id) - 1]]):
- # all rows about the reffered tax should be inclusive
+ # all rows about the referred tax should be inclusive
_on_previous_row_error("1 - %d" % (tax.row_id,))
elif tax.get("category") == "Valuation":
frappe.throw(_("Valuation type charges can not be marked as Inclusive"))
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 3f2d339..da81911 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -181,8 +181,8 @@
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 @@
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)
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 81ac234..7bd739a 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -88,7 +88,7 @@
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
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 54156f37..7f28289 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -428,7 +428,7 @@
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')]
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 83d4c33..943f7aa 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -299,8 +299,8 @@
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:
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 0da723d..6a7c9e3 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -313,7 +313,7 @@
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))),
@@ -324,8 +324,8 @@
def validate_warehouse(self):
from erpnext.stock.utils import validate_disabled_warehouse, validate_warehouse_company
- 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)]))
@@ -558,11 +558,8 @@
or_conditions = []
for warehouse, items in warehouse_items_map.items():
or_conditions.append(
- "warehouse = '{}' and item_code in ({})".format(
- warehouse,
- ", ".join(frappe.db.escape(item) for item in items)
- )
- )
+ f"""warehouse = {frappe.db.escape(warehouse)}
+ and item_code in ({', '.join(frappe.db.escape(item) for item in items)})""")
return frappe.db.sql("""
select name
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 0b4fb3a..2bb83ea 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -378,10 +378,10 @@
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"))
@@ -521,8 +521,8 @@
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"))
@@ -622,7 +622,7 @@
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
diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py
index 66459fd..7a4b2d3 100644
--- a/erpnext/controllers/tests/test_mapper.py
+++ b/erpnext/controllers/tests/test_mapper.py
@@ -26,8 +26,8 @@
# 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):
diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py
index ecf041e..7c072e4 100644
--- a/erpnext/controllers/website_list_for_contact.py
+++ b/erpnext/controllers/website_list_for_contact.py
@@ -113,7 +113,7 @@
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
diff --git a/erpnext/education/doctype/assessment_result/assessment_result.js b/erpnext/education/doctype/assessment_result/assessment_result.js
index 617a873..c35f607 100644
--- a/erpnext/education/doctype/assessment_result/assessment_result.js
+++ b/erpnext/education/doctype/assessment_result/assessment_result.js
@@ -6,7 +6,8 @@
if (!frm.doc.__islocal) {
frm.trigger('setup_chart');
}
- frm.set_df_property('details', 'read_only', 1);
+
+ frm.get_field('details').grid.cannot_add_rows = true;
frm.set_query('course', function() {
return {
diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py
index 789d452..cebcb20 100644
--- a/erpnext/healthcare/doctype/patient/patient.py
+++ b/erpnext/healthcare/doctype/patient/patient.py
@@ -33,21 +33,21 @@
self.reload() # self.notify_update()
def on_update(self):
- if self.customer:
- customer = frappe.get_doc('Customer', self.customer)
- if self.customer_group:
- customer.customer_group = self.customer_group
- if self.territory:
- customer.territory = self.territory
+ if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
+ if self.customer:
+ customer = frappe.get_doc('Customer', self.customer)
+ if self.customer_group:
+ customer.customer_group = self.customer_group
+ if self.territory:
+ customer.territory = self.territory
- customer.customer_name = self.patient_name
- customer.default_price_list = self.default_price_list
- customer.default_currency = self.default_currency
- customer.language = self.language
- customer.ignore_mandatory = True
- customer.save(ignore_permissions=True)
- else:
- if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
+ customer.customer_name = self.patient_name
+ customer.default_price_list = self.default_price_list
+ customer.default_currency = self.default_currency
+ customer.language = self.language
+ customer.ignore_mandatory = True
+ customer.save(ignore_permissions=True)
+ else:
create_customer(self)
def set_full_name(self):
diff --git a/erpnext/hr/doctype/employee/employee.json b/erpnext/hr/doctype/employee/employee.json
index 5123d6a..5442ed5 100644
--- a/erpnext/hr/doctype/employee/employee.json
+++ b/erpnext/hr/doctype/employee/employee.json
@@ -207,7 +207,7 @@
"label": "Status",
"oldfieldname": "status",
"oldfieldtype": "Select",
- "options": "Active\nLeft",
+ "options": "Active\nInactive\nLeft",
"reqd": 1,
"search_index": 1
},
@@ -813,7 +813,7 @@
"idx": 24,
"image_field": "image",
"links": [],
- "modified": "2021-01-02 16:54:33.477439",
+ "modified": "2021-06-12 11:31:37.730760",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index ed7d588..bc56942 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -37,7 +37,7 @@
def validate(self):
from erpnext.controllers.status_updater import validate_status
- validate_status(self.status, ["Active", "Temporary Leave", "Left"])
+ validate_status(self.status, ["Active", "Inactive", "Left"])
self.employee = self.name
self.set_employee_name()
@@ -478,7 +478,7 @@
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False, is_tree=False):
- filters = [['status', '!=', 'Left']]
+ filters = [['status', '=', 'Active']]
if company and company != 'All Companies':
filters.append(['company', '=', company])
diff --git a/erpnext/hr/doctype/employee/employee_list.js b/erpnext/hr/doctype/employee/employee_list.js
index 4483703..6679e31 100644
--- a/erpnext/hr/doctype/employee/employee_list.js
+++ b/erpnext/hr/doctype/employee/employee_list.js
@@ -3,7 +3,7 @@
filters: [["status","=", "Active"]],
get_indicator: function(doc) {
var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status];
- indicator[1] = {"Active": "green", "Temporary Leave": "red", "Left": "gray"}[doc.status];
+ indicator[1] = {"Active": "green", "Inactive": "red", "Left": "gray"}[doc.status];
return indicator;
}
};
diff --git a/erpnext/hr/doctype/employee_promotion/employee_promotion.py b/erpnext/hr/doctype/employee_promotion/employee_promotion.py
index 4994921..83fb235 100644
--- a/erpnext/hr/doctype/employee_promotion/employee_promotion.py
+++ b/erpnext/hr/doctype/employee_promotion/employee_promotion.py
@@ -11,12 +11,12 @@
class EmployeePromotion(Document):
def validate(self):
- if frappe.get_value("Employee", self.employee, "status") == "Left":
- frappe.throw(_("Cannot promote Employee with status Left"))
+ if frappe.get_value("Employee", self.employee, "status") != "Active":
+ frappe.throw(_("Cannot promote Employee with status Left or Inactive"))
def before_submit(self):
if getdate(self.promotion_date) > getdate():
- frappe.throw(_("Employee Promotion cannot be submitted before Promotion Date "),
+ frappe.throw(_("Employee Promotion cannot be submitted before Promotion Date"),
frappe.DocstatusTransitionError)
def on_submit(self):
diff --git a/erpnext/hr/doctype/employee_transfer/employee_transfer.py b/erpnext/hr/doctype/employee_transfer/employee_transfer.py
index 3539970..6eec9fa 100644
--- a/erpnext/hr/doctype/employee_transfer/employee_transfer.py
+++ b/erpnext/hr/doctype/employee_transfer/employee_transfer.py
@@ -11,12 +11,12 @@
class EmployeeTransfer(Document):
def validate(self):
- if frappe.get_value("Employee", self.employee, "status") == "Left":
- frappe.throw(_("Cannot transfer Employee with status Left"))
+ if frappe.get_value("Employee", self.employee, "status") != "Active":
+ frappe.throw(_("Cannot transfer Employee with status Left or Inactive"))
def before_submit(self):
if getdate(self.transfer_date) > getdate():
- frappe.throw(_("Employee Transfer cannot be submitted before Transfer Date "),
+ frappe.throw(_("Employee Transfer cannot be submitted before Transfer Date"),
frappe.DocstatusTransitionError)
def on_submit(self):
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index d764db3..cdc4518 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -317,7 +317,7 @@
'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)
diff --git a/erpnext/payroll/doctype/payroll_entry/payroll_entry.py b/erpnext/payroll/doctype/payroll_entry/payroll_entry.py
index 3953b46..7a70679 100644
--- a/erpnext/payroll/doctype/payroll_entry/payroll_entry.py
+++ b/erpnext/payroll/doctype/payroll_entry/payroll_entry.py
@@ -665,6 +665,8 @@
emp_list = remove_payrolled_employees(emp_list, filters.start_date, filters.end_date)
return emp_list
+ return []
+
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def employee_query(doctype, txt, searchfield, start, page_len, filters):
diff --git a/erpnext/payroll/doctype/retention_bonus/retention_bonus.py b/erpnext/payroll/doctype/retention_bonus/retention_bonus.py
index b8e56ae..049ea26 100644
--- a/erpnext/payroll/doctype/retention_bonus/retention_bonus.py
+++ b/erpnext/payroll/doctype/retention_bonus/retention_bonus.py
@@ -10,8 +10,8 @@
class RetentionBonus(Document):
def validate(self):
- if frappe.get_value('Employee', self.employee, 'status') == 'Left':
- frappe.throw(_('Cannot create Retention Bonus for left Employees'))
+ if frappe.get_value('Employee', self.employee, 'status') != 'Active':
+ frappe.throw(_('Cannot create Retention Bonus for Left or Inactive Employees'))
if getdate(self.bonus_payment_date) < getdate():
frappe.throw(_('Bonus Payment Date cannot be a past date'))
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index d1583f1..39a6024 100755
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -232,7 +232,7 @@
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
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index a3e4577..c8bd80f 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -87,8 +87,8 @@
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)
diff --git a/erpnext/projects/report/project_summary/project_summary.py b/erpnext/projects/report/project_summary/project_summary.py
index 2c7bb49..98dd617 100644
--- a/erpnext/projects/report/project_summary/project_summary.py
+++ b/erpnext/projects/report/project_summary/project_summary.py
@@ -122,7 +122,7 @@
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])
diff --git a/erpnext/public/scss/point-of-sale.scss b/erpnext/public/scss/point-of-sale.scss
index 9bdaa8d..c77b2ce 100644
--- a/erpnext/public/scss/point-of-sale.scss
+++ b/erpnext/public/scss/point-of-sale.scss
@@ -806,6 +806,9 @@
display: none;
float: right;
font-weight: 700;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
> .cash-shortcuts {
@@ -829,6 +832,11 @@
}
}
}
+
+ > .loyalty-card {
+ display: flex;
+ flex-direction: column;
+ }
}
}
@@ -1134,4 +1142,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py
index 0eaf790..11ebef7 100644
--- a/erpnext/regional/india/e_invoice/utils.py
+++ b/erpnext/regional/india/e_invoice/utils.py
@@ -38,7 +38,7 @@
einvoicing_eligible_from = frappe.db.get_single_value('E Invoice Settings', 'applicable_from') or '2021-04-01'
if getdate(doc.get('posting_date')) < getdate(einvoicing_eligible_from):
return False
-
+
invalid_company = not frappe.db.get_value('E Invoice User', { 'company': doc.get('company') })
invalid_supply_type = doc.get('gst_category') not in ['Registered Regular', 'SEZ', 'Overseas', 'Deemed Export']
company_transaction = doc.get('billing_address_gstin') == doc.get('company_gstin')
@@ -135,7 +135,7 @@
def get_party_details(address_name, is_shipping_address=False):
addr = frappe.get_doc('Address', address_name)
-
+
validate_address_fields(addr, is_shipping_address)
if addr.gst_state_number == 97:
@@ -188,11 +188,6 @@
item.qty = abs(item.qty)
- if invoice.apply_discount_on == 'Net Total' and invoice.discount_amount:
- item.discount_amount = abs(item.base_amount - item.base_net_amount)
- else:
- item.discount_amount = 0
-
item.unit_rate = abs((abs(item.taxable_value) - item.discount_amount)/ item.qty)
item.gross_amount = abs(item.taxable_value) + item.discount_amount
item.taxable_value = abs(item.taxable_value)
@@ -254,18 +249,8 @@
def get_invoice_value_details(invoice):
invoice_value_details = frappe._dict(dict())
-
- if invoice.apply_discount_on == 'Net Total' and invoice.discount_amount:
- # Discount already applied on net total which means on items
- invoice_value_details.base_total = abs(sum([i.taxable_value for i in invoice.get('items')]))
- invoice_value_details.invoice_discount_amt = 0
- elif invoice.apply_discount_on == 'Grand Total' and invoice.discount_amount:
- invoice_value_details.invoice_discount_amt = invoice.base_discount_amount
- invoice_value_details.base_total = abs(sum([i.taxable_value for i in invoice.get('items')]))
- else:
- invoice_value_details.base_total = abs(sum([i.taxable_value for i in invoice.get('items')]))
- # since tax already considers discount amount
- invoice_value_details.invoice_discount_amt = 0
+ invoice_value_details.base_total = abs(sum([i.taxable_value for i in invoice.get('items')]))
+ invoice_value_details.invoice_discount_amt = 0
invoice_value_details.round_off = invoice.base_rounding_adjustment
invoice_value_details.base_grand_total = abs(invoice.base_rounded_total) or abs(invoice.base_grand_total)
@@ -287,8 +272,7 @@
considered_rows = []
for t in invoice.taxes:
- tax_amount = t.base_tax_amount if (invoice.apply_discount_on == 'Grand Total' and invoice.discount_amount) \
- else t.base_tax_amount_after_discount_amount
+ tax_amount = t.base_tax_amount_after_discount_amount
if t.account_head in gst_accounts_list:
if t.account_head in gst_accounts.cess_account:
# using after discount amt since item also uses after discount amt for cess calc
@@ -995,7 +979,7 @@
self.invoice.failure_description = self.get_failure_message(errors) if errors else ""
self.update_invoice()
frappe.db.commit()
-
+
def get_failure_message(self, errors):
if isinstance(errors, list):
errors = ', '.join(errors)
@@ -1052,7 +1036,7 @@
_('{} e-invoices generated successfully').format(success),
title=_('Bulk E-Invoice Generation Complete')
)
-
+
else:
enqueue_bulk_action(schedule_bulk_generate_irn, docnames=docnames)
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index 229e0c0..3e0b9b7 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -27,6 +27,9 @@
add_print_formats()
def add_hsn_sac_codes():
+ if frappe.flags.in_test and frappe.flags.created_hsn_codes:
+ return
+
# HSN codes
with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:
hsn_codes = json.loads(f.read())
@@ -38,6 +41,9 @@
sac_codes = json.loads(f.read())
create_hsn_codes(sac_codes, code_field="sac_code")
+ if frappe.flags.in_test:
+ frappe.flags.created_hsn_codes = True
+
def create_hsn_codes(data, code_field):
for d in data:
hsn_code = frappe.new_doc('GST HSN Code')
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 075c698..a4466e7 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -817,12 +817,8 @@
considered_rows.append(prev_row_id)
for item in doc.get('items'):
- if doc.apply_discount_on == 'Grand Total' and doc.discount_amount:
- proportionate_value = item.base_amount if doc.base_total else item.qty
- total_value = doc.base_total if doc.base_total else doc.total_qty
- else:
- proportionate_value = item.base_net_amount if doc.base_net_total else item.qty
- total_value = doc.base_net_total if doc.base_net_total else doc.total_qty
+ proportionate_value = item.base_net_amount if doc.base_net_total else item.qty
+ total_value = doc.base_net_total if doc.base_net_total else doc.total_qty
applicable_charges = flt(flt(proportionate_value * (flt(additional_taxes) / flt(total_value)),
item.precision('taxable_value')))
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 51d86ff..818888c 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -75,7 +75,7 @@
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):
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 246f923..e4f8a47 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -50,7 +50,7 @@
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)
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index d9e52e1..551f715 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -151,7 +151,7 @@
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:
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index 7742f24..296c8c2 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -9,7 +9,7 @@
from erpnext.accounts.doctype.pos_invoice.pos_invoice import get_stock_availability
def search_by_term(search_term, warehouse, price_list):
- result = search_for_serial_or_batch_or_barcode_number(search_term)
+ result = search_for_serial_or_batch_or_barcode_number(search_term) or {}
item_code = result.get("item_code") or search_term
serial_no = result.get("serial_no") or ""
@@ -23,9 +23,9 @@
item_stock_qty = get_stock_availability(item_code, warehouse)
price_list_rate, currency = frappe.db.get_value('Item Price', {
- 'price_list': price_list,
- 'item_code': item_code
- }, ["price_list_rate", "currency"])
+ 'price_list': price_list,
+ 'item_code': item_code
+ }, ["price_list_rate", "currency"]) or [None, None]
item_info.update({
'serial_no': serial_no,
@@ -46,7 +46,7 @@
result = []
if search_term:
- result = search_by_term(search_term, warehouse, price_list)
+ result = search_by_term(search_term, warehouse, price_list) or []
if result:
return result
diff --git a/erpnext/selling/page/point_of_sale/pos_payment.js b/erpnext/selling/page/point_of_sale/pos_payment.js
index 156fb77..c484873 100644
--- a/erpnext/selling/page/point_of_sale/pos_payment.js
+++ b/erpnext/selling/page/point_of_sale/pos_payment.js
@@ -481,7 +481,7 @@
const amount = doc.loyalty_amount > 0 ? format_currency(doc.loyalty_amount, doc.currency) : '';
this.$payment_modes.append(
`<div class="payment-mode-wrapper">
- <div class="mode-of-payment" data-mode="loyalty-amount" data-payment-type="loyalty-amount">
+ <div class="mode-of-payment loyalty-card" data-mode="loyalty-amount" data-payment-type="loyalty-amount">
Redeem Loyalty Points
<div class="loyalty-amount-amount pay-amount">${amount}</div>
<div class="loyalty-amount-name">${loyalty_program}</div>
@@ -563,4 +563,4 @@
toggle_component(show) {
show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none');
}
-};
\ No newline at end of file
+};
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 077538d..27e023c 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -54,7 +54,7 @@
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 @@
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):
"""
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index bff806d..db31d6d 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -139,7 +139,7 @@
# 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 @@
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)
diff --git a/erpnext/setup/setup_wizard/data/country_wise_tax.json b/erpnext/setup/setup_wizard/data/country_wise_tax.json
index ec9a6d6..daaa626 100644
--- a/erpnext/setup/setup_wizard/data/country_wise_tax.json
+++ b/erpnext/setup/setup_wizard/data/country_wise_tax.json
@@ -1867,7 +1867,7 @@
"South Africa": {
"South Africa Tax": {
"account_name": "VAT",
- "tax_rate": 14.00
+ "tax_rate": 15.00
}
},
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index 8fdda56..508e17c 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -304,7 +304,7 @@
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}")
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index cce51cb..dd31965 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -264,7 +264,7 @@
"""
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"):
diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.py b/erpnext/stock/doctype/delivery_trip/delivery_trip.py
index 81e7301..9ec28d8 100644
--- a/erpnext/stock/doctype/delivery_trip/delivery_trip.py
+++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.py
@@ -68,7 +68,7 @@
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 @@
# 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
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
index 8310946..5df4d87 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py
@@ -78,7 +78,7 @@
.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 @@
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"))
diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
index 984ae46..32b08f6 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
+++ b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
@@ -311,7 +311,7 @@
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)
diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.py b/erpnext/stock/doctype/packing_slip/packing_slip.py
index 2008bff..4a843e0 100644
--- a/erpnext/stock/doctype/packing_slip/packing_slip.py
+++ b/erpnext/stock/doctype/packing_slip/packing_slip.py
@@ -88,9 +88,9 @@
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
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 5095a80..8d9b675 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -246,7 +246,7 @@
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()
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index 5ecc9f8..b236f6a 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -613,7 +613,7 @@
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 "
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 2f76bc7..560ceaa 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -465,7 +465,7 @@
"""
# 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'):
diff --git a/erpnext/stock/doctype/warehouse/test_warehouse.py b/erpnext/stock/doctype/warehouse/test_warehouse.py
index 95478f6..e3981c9 100644
--- a/erpnext/stock/doctype/warehouse/test_warehouse.py
+++ b/erpnext/stock/doctype/warehouse/test_warehouse.py
@@ -11,6 +11,7 @@
import erpnext
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account
+from erpnext.stock.doctype.item.test_item import create_item
test_records = frappe.get_test_records('Warehouse')
@@ -92,6 +93,39 @@
self.assertTrue(frappe.db.get_value("Warehouse",
filters={"account": "Test Warehouse for Merging 2 - TCP1"}))
+ def test_unlinking_warehouse_from_item_defaults(self):
+ company = "_Test Company"
+
+ warehouse_names = [f'_Test Warehouse {i} for Unlinking' for i in range(2)]
+ warehouse_ids = []
+ for warehouse in warehouse_names:
+ warehouse_id = create_warehouse(warehouse, company=company)
+ warehouse_ids.append(warehouse_id)
+
+ item_names = [f'_Test Item {i} for Unlinking' for i in range(2)]
+ for item, warehouse in zip(item_names, warehouse_ids):
+ create_item(item, warehouse=warehouse, company=company)
+
+ # Delete warehouses
+ for warehouse in warehouse_ids:
+ frappe.delete_doc("Warehouse", warehouse)
+
+ # Check Item existance
+ for item in item_names:
+ self.assertTrue(
+ bool(frappe.db.exists("Item", item)),
+ f"{item} doesn't exist"
+ )
+
+ item_doc = frappe.get_doc("Item", item)
+ for item_default in item_doc.item_defaults:
+ self.assertNotIn(
+ item_default.default_warehouse,
+ warehouse_ids,
+ f"{item} linked to {item_default.default_warehouse} in {warehouse_ids}."
+ )
+
+
def create_warehouse(warehouse_name, properties=None, company=None):
if not company:
company = "_Test Company"
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 2062bdd..3abc139 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -54,6 +54,7 @@
throw(_("Child warehouse exists for this warehouse. You can not delete this warehouse."))
self.update_nsm_model()
+ self.unlink_from_items()
def check_if_sle_exists(self):
return frappe.db.sql("""select name from `tabStock Ledger Entry`
@@ -138,6 +139,12 @@
self.save()
return 1
+ def unlink_from_items(self):
+ frappe.db.sql("""
+ update `tabItem Default`
+ set default_warehouse=NULL
+ where default_warehouse=%s""", self.name)
+
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False):
if is_root:
diff --git a/erpnext/stock/report/item_price_stock/item_price_stock.py b/erpnext/stock/report/item_price_stock/item_price_stock.py
index 5296211..db7498b 100644
--- a/erpnext/stock/report/item_price_stock/item_price_stock.py
+++ b/erpnext/stock/report/item_price_stock/item_price_stock.py
@@ -89,7 +89,7 @@
{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)
diff --git a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
index 2f70523..2e13aa0 100644
--- a/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
+++ b/erpnext/stock/report/itemwise_recommended_reorder_level/itemwise_recommended_reorder_level.py
@@ -66,7 +66,7 @@
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("""
diff --git a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py
index 276e42e..8fffbcc 100644
--- a/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py
+++ b/erpnext/stock/report/product_bundle_balance/product_bundle_balance.py
@@ -141,7 +141,7 @@
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)
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index bbd73e9..b6a8063 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -157,7 +157,7 @@
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_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 @@
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)
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index 36996e9..8909f21 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -115,7 +115,7 @@
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_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
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index b2825fc..fc82c78 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -521,7 +521,7 @@
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]
diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.py b/erpnext/support/doctype/warranty_claim/warranty_claim.py
index a3428a2..a20e7a8 100644
--- a/erpnext/support/doctype/warranty_claim/warranty_claim.py
+++ b/erpnext/support/doctype/warranty_claim/warranty_claim.py
@@ -29,7 +29,7 @@
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')
diff --git a/erpnext/utilities/product.py b/erpnext/utilities/product.py
index 66d6cd3..70b4176 100644
--- a/erpnext/utilities/product.py
+++ b/erpnext/utilities/product.py
@@ -131,6 +131,6 @@
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
diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py
index f99da58..db99726 100644
--- a/erpnext/utilities/transaction_base.py
+++ b/erpnext/utilities/transaction_base.py
@@ -147,7 +147,7 @@
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 @@
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))