Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/frappe/erpnext into deve…
Browse files Browse the repository at this point in the history
…lop-ritvik-customer-ter-not-rqd
  • Loading branch information
deepeshgarg007 committed Sep 24, 2023
2 parents 6ebaa21 + c5e4e01 commit b51531d
Show file tree
Hide file tree
Showing 141 changed files with 3,650 additions and 3,762 deletions.
2 changes: 1 addition & 1 deletion .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ if [ "$TYPE" == "server" ]; then bench setup requirements --dev; fi

wait $wkpid

bench start &> bench_run_logs.txt &
bench start &>> ~/frappe-bench/bench_start.log &
CI=Yes bench build --app frappe &
bench --site test_site reinstall --yes
64 changes: 41 additions & 23 deletions .github/workflows/patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

services:
mysql:
image: mariadb:10.3
image: mariadb:10.6
env:
MARIADB_ROOT_PASSWORD: 'root'
ports:
Expand All @@ -45,9 +45,7 @@ jobs:
- name: Setup Python
uses: "actions/setup-python@v4"
with:
python-version: |
3.7
3.10
python-version: '3.10'

- name: Setup Node
uses: actions/setup-node@v2
Expand Down Expand Up @@ -102,40 +100,60 @@ jobs:
- name: Run Patch Tests
run: |
cd ~/frappe-bench/
wget https://erpnext.com/files/v10-erpnext.sql.gz
bench --site test_site --force restore ~/frappe-bench/v10-erpnext.sql.gz
bench remove-app payments --force
jq 'del(.install_apps)' ~/frappe-bench/sites/test_site/site_config.json > tmp.json
mv tmp.json ~/frappe-bench/sites/test_site/site_config.json
wget https://erpnext.com/files/v13-erpnext.sql.gz
bench --site test_site --force restore ~/frappe-bench/v13-erpnext.sql.gz
git -C "apps/frappe" remote set-url upstream https://github.com/frappe/frappe.git
git -C "apps/erpnext" remote set-url upstream https://github.com/frappe/erpnext.git
for version in $(seq 12 13)
do
echo "Updating to v$version"
branch_name="version-$version-hotfix"
git -C "apps/frappe" fetch --depth 1 upstream $branch_name:$branch_name
git -C "apps/erpnext" fetch --depth 1 upstream $branch_name:$branch_name
function update_to_version() {
version=$1
git -C "apps/frappe" checkout -q -f $branch_name
git -C "apps/erpnext" checkout -q -f $branch_name
branch_name="version-$version-hotfix"
echo "Updating to v$version"
rm -rf ~/frappe-bench/env
bench setup env --python python3.7
bench pip install -e ./apps/payments
bench pip install -e ./apps/erpnext
# Fetch and checkout branches
git -C "apps/frappe" fetch --depth 1 upstream $branch_name:$branch_name
git -C "apps/erpnext" fetch --depth 1 upstream $branch_name:$branch_name
git -C "apps/frappe" checkout -q -f $branch_name
git -C "apps/erpnext" checkout -q -f $branch_name
bench --site test_site migrate
done
# Resetup env and install apps
pgrep honcho | xargs kill
rm -rf ~/frappe-bench/env
bench -v setup env
bench pip install -e ./apps/erpnext
bench start &>> ~/frappe-bench/bench_start.log &
bench --site test_site migrate
}
update_to_version 14
echo "Updating to latest version"
git -C "apps/frappe" checkout -q -f "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}"
git -C "apps/erpnext" checkout -q -f "$GITHUB_SHA"
pgrep honcho | xargs kill
rm -rf ~/frappe-bench/env
bench -v setup env --python python3.10
bench pip install -e ./apps/payments
bench -v setup env
bench pip install -e ./apps/erpnext
bench start &>> ~/frappe-bench/bench_start.log &
bench --site test_site migrate
bench --site test_site install-app payments
- name: Show bench output
if: ${{ always() }}
run: |
cd ~/frappe-bench
cat bench_start.log || true
cd logs
for f in ./*.log*; do
echo "Printing log: $f";
cat $f
done
4 changes: 4 additions & 0 deletions .github/workflows/server-tests-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ jobs:
CI_BUILD_ID: ${{ github.run_id }}
ORCHESTRATOR_URL: http://test-orchestrator.frappe.io

- name: Show bench output
if: ${{ always() }}
run: cat ~/frappe-bench/bench_start.log || true

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
Expand Down
3 changes: 0 additions & 3 deletions erpnext/accounts/doctype/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ frappe.ui.form.on("Account", {
args: {
old: frm.doc.name,
new: data.name,
is_group: frm.doc.is_group,
root_type: frm.doc.root_type,
company: frm.doc.company,
},
callback: function (r) {
if (!r.exc) {
Expand Down
31 changes: 22 additions & 9 deletions erpnext/accounts/doctype/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class BalanceMismatchError(frappe.ValidationError):
pass


class InvalidAccountMergeError(frappe.ValidationError):
pass


class Account(NestedSet):
nsm_parent_field = "parent_account"

Expand Down Expand Up @@ -460,25 +464,34 @@ def update_account_number(name, account_name, account_number=None, from_descenda


@frappe.whitelist()
def merge_account(old, new, is_group, root_type, company):
def merge_account(old, new):
# Validate properties before merging
new_account = frappe.get_cached_doc("Account", new)
old_account = frappe.get_cached_doc("Account", old)

if not new_account:
throw(_("Account {0} does not exist").format(new))

if (new_account.is_group, new_account.root_type, new_account.company) != (
cint(is_group),
root_type,
company,
if (
cint(new_account.is_group),
new_account.root_type,
new_account.company,
cstr(new_account.account_currency),
) != (
cint(old_account.is_group),
old_account.root_type,
old_account.company,
cstr(old_account.account_currency),
):
throw(
_(
"""Merging is only possible if following properties are same in both records. Is Group, Root Type, Company"""
)
msg=_(
"""Merging is only possible if following properties are same in both records. Is Group, Root Type, Company and Account Currency"""
),
title=("Invalid Accounts"),
exc=InvalidAccountMergeError,
)

if is_group and new_account.parent_account == old:
if old_account.is_group and new_account.parent_account == old:
new_account.db_set("parent_account", frappe.get_cached_value("Account", old, "parent_account"))

frappe.rename_doc("Account", old, new, merge=1, force=1)
Expand Down
Loading

0 comments on commit b51531d

Please sign in to comment.