Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport diamoerp-staging] Auto asignación de Vendedor #864

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,21 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=

# sales team
if party_type=="Customer":
party_details["sales_team"] = [{
"sales_person": d.sales_person,
"allocated_percentage": d.allocated_percentage or None
} for d in party.get("sales_team")]
sales_persons = []
party_details["sales_team"] = []
for d in party.get("sales_team"):
sales_persons.append(d.sales_person)
party_details["sales_team"].append({
"sales_person": d.sales_person,
"allocated_percentage": d.allocated_percentage or None
})

for d in frappe.get_all("Sales Person", {"user": frappe.session.user}, pluck="name"):
if d not in sales_persons:
party_details["sales_team"].append({
"sales_person":d,
"allocated_percentage": 100
})

# supplier tax withholding category
if party_type == "Supplier" and party:
Expand Down
9 changes: 9 additions & 0 deletions erpnext/setup/doctype/sales_person/sales_person.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ frappe.ui.form.on('Sales Person', {
}
};

frm.set_query("user", function(doc) {
return {
filters: {
"enabled": 1,
"user_type": "System User"
}
};
});

frm.make_methods = {
'Sales Order': () => frappe.new_doc("Sales Order")
.then(() => frm.add_child("sales_team", {"sales_person": frm.doc.name}))
Expand Down
10 changes: 9 additions & 1 deletion erpnext/setup/doctype/sales_person/sales_person.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"enabled",
"cb0",
"employee",
"user",
"department",
"lft",
"rgt",
Expand Down Expand Up @@ -139,13 +140,20 @@
"oldfieldname": "target_details",
"oldfieldtype": "Table",
"options": "Target Detail"
},
{
"description": "Esto autoasignar\u00e1 al vendedor en las transacci\u00f3nes",
"fieldname": "user",
"fieldtype": "Link",
"label": "User",
"options": "User"
}
],
"icon": "icon-user",
"idx": 1,
"is_tree": 1,
"links": [],
"modified": "2021-05-13 21:02:44.461588",
"modified": "2024-08-16 10:34:56.363159",
"modified_by": "Administrator",
"module": "Setup",
"name": "Sales Person",
Expand Down