fixed merge-conflicts

This commit is contained in:
Saurabh 2017-11-28 11:02:28 +05:30
commit b750b304dd
22 changed files with 292 additions and 268 deletions

View File

@ -4,7 +4,7 @@ import inspect
import frappe
from erpnext.hooks import regional_overrides
__version__ = '9.2.16'
__version__ = '9.2.17'
def get_default_company(user=None):
'''Get default company for user'''

View File

@ -19,7 +19,7 @@ class POSProfile(Document):
def check_for_duplicate(self):
res = frappe.db.sql("""select name, user from `tabPOS Profile`
where ifnull(user, '') = %s and name != %s and company = %s""",
where ifnull(user, '') = %s and name != %s and company = %s and ifnull(disabled, 0) != 1""",
(self.user, self.name, self.company))
if res:
if res[0][1]:

View File

@ -51,6 +51,7 @@ class PurchaseOrder(BuyingController):
self.validate_with_previous_doc()
self.validate_for_subcontracting()
self.validate_minimum_order_qty()
self.validate_bom_for_subcontracting_items()
self.create_raw_materials_supplied("supplied_items")
self.set_received_qty_for_drop_ship_items()
@ -95,6 +96,13 @@ class PurchaseOrder(BuyingController):
frappe.throw(_("Item {0}: Ordered qty {1} cannot be less than minimum order qty {2} (defined in Item).").format(item_code,
qty, itemwise_min_order_qty.get(item_code)))
def validate_bom_for_subcontracting_items(self):
if self.is_subcontracted == "Yes":
for item in self.items:
if not item.bom:
frappe.throw(_("BOM is not specified for subcontracting item {0} at row {1}"\
.format(item.item_code, item.idx)))
def get_schedule_dates(self):
for d in self.get('items'):
if d.material_request_item and not d.schedule_date:

View File

@ -5,6 +5,7 @@ def get_data():
'fieldname': 'prevdoc_docname',
'non_standard_fieldnames': {
'Supplier Quotation': 'opportunity',
'Quotation': 'opportunity'
},
'transactions': [
{

View File

@ -139,6 +139,7 @@ var btn_create_vital_signs = function (frm) {
}
frappe.route_options = {
"patient": frm.doc.patient,
"appointment": frm.doc.appointment
};
frappe.new_doc("Vital Signs");
};

View File

@ -216,7 +216,7 @@
"label": "Gender",
"length": 0,
"no_copy": 0,
"options": "\nMale\nFemale",
"options": "\nMale\nFemale\nOther",
"permlevel": 0,
"precision": "",
"print_hide": 1,
@ -1004,7 +1004,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-05 12:13:52.596750",
"modified": "2017-11-22 14:03:30.434304",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Consultation",

View File

@ -114,7 +114,7 @@
"columns": 0,
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
@ -185,7 +185,7 @@
"label": "Gender",
"length": 0,
"no_copy": 0,
"options": "\nMale\nFemale",
"options": "\nMale\nFemale\nOther",
"permlevel": 0,
"precision": "",
"print_hide": 1,
@ -1388,7 +1388,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-05 12:14:57.078823",
"modified": "2017-11-22 14:32:27.994634",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test",

View File

@ -126,7 +126,7 @@
"label": "Gender",
"length": 0,
"no_copy": 0,
"options": "\nMale\nFemale",
"options": "\nMale\nFemale\nOther",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -185,7 +185,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "DOB",
"label": "Date of birth",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -353,37 +353,6 @@
"set_only_once": 1,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "company",
"fieldtype": "Link",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Company",
"length": 0,
"no_copy": 0,
"options": "Company",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -884,7 +853,7 @@
"label": "Marital Status",
"length": 0,
"no_copy": 0,
"options": "Single\nMarried\nDivorced\nWidow",
"options": "\nSingle\nMarried\nDivorced\nWidow",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -1274,7 +1243,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 50,
"modified": "2017-10-04 17:41:03.219934",
"modified": "2017-11-24 12:39:33.061005",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient",

View File

@ -69,7 +69,10 @@ class Patient(Document):
frappe.db.set_value("Patient", self.name, "disabled", 0)
send_registration_sms(self)
if(frappe.get_value("Healthcare Settings", None, "registration_fee")>0):
sales_invoice = make_invoice(self.name, self.company)
company = frappe.defaults.get_user_default('company')
if not company:
company = frappe.db.get_value("Global Defaults", None, "default_company")
sales_invoice = make_invoice(self.name, company)
sales_invoice.save(ignore_permissions=True)
return {'invoice': sales_invoice.name}
@ -110,7 +113,7 @@ def make_invoice(patient, company):
return sales_invoice
@frappe.whitelist()
def get_patient_detail(patient, company=None):
def get_patient_detail(patient):
patient_dict = frappe.db.sql("""select * from tabPatient where name=%s""", (patient), as_dict=1)
if not patient_dict:
frappe.throw("Patient not found")

View File

@ -185,6 +185,7 @@ var btn_create_vital_signs = function (frm) {
}
frappe.route_options = {
"patient": frm.doc.patient,
"appointment": frm.doc.name,
};
frappe.new_doc("Vital Signs");
};

View File

@ -165,6 +165,100 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Patient Name",
"length": 0,
"no_copy": 0,
"options": "patient.patient_name",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "patient_sex",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Gender",
"length": 0,
"no_copy": 1,
"options": "patient.sex",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "patient_age",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Patient Age",
"length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -440,158 +534,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_2",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "patient_details",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Patient Details",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "patient",
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Patient Name",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "patient_sex",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Gender",
"length": 0,
"no_copy": 1,
"options": "patient.sex",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "patient_age",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Patient Age",
"length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -756,7 +698,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-25 23:33:36.060803",
"modified": "2017-11-22 16:32:57.240736",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Appointment",

View File

@ -43,6 +43,37 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Patient Name",
"length": 0,
"no_copy": 0,
"options": "patient.patient_name",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -751,7 +782,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-04 16:08:36.340607",
"modified": "2017-11-22 17:31:16.620650",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Vital Signs",

View File

@ -448,6 +448,8 @@ class ProductionOrder(Document):
for item in sorted(item_dict.values(), key=lambda d: d['idx']):
self.append('required_items', {
'item_code': item.item_code,
'item_name': item.item_name,
'description': item.description,
'required_qty': item.qty,
'source_warehouse': item.source_warehouse or item.default_warehouse
})

View File

@ -15,62 +15,66 @@ def get_item_list(prod_list, filters):
out = []
#Add a row for each item/qty
for prod_order in prod_list:
prod_details = frappe.db.get_value("Production Order", prod_order.name,
["bom_no", "source_warehouse", "qty", "produced_qty"], as_dict=1)
for prod_details in prod_list:
desc = frappe.db.get_value("BOM", prod_details.bom_no, "description")
item_list = frappe.db.sql("""SELECT
bom_item.item_code as item_code,
ifnull(ledger.actual_qty*bom.quantity/bom_item.stock_qty,0) as build_qty
FROM
`tabBOM` as bom, `tabBOM Item` AS bom_item
LEFT JOIN `tabBin` AS ledger
ON bom_item.item_code = ledger.item_code
AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
WHERE
bom.name = bom_item.parent
and bom.name = %(bom)s
GROUP BY
bom_item.item_code""",
{"bom": prod_details.bom_no, "warehouse": prod_details.source_warehouse,
"filterhouse": filters.warehouse}, as_dict=1)
stock_qty = 0
count = 0
buildable_qty = prod_details.qty
for item in item_list:
count = count + 1
if item.build_qty >= (prod_details.qty - prod_details.produced_qty):
stock_qty = stock_qty + 1
elif buildable_qty >= item.build_qty:
buildable_qty = item.build_qty
if count == stock_qty:
build = "Y"
else:
build = "N"
row = frappe._dict({
"production_order": prod_order.name,
"status": prod_order.status,
"req_items": cint(count),
"instock": stock_qty,
"description": desc,
"bom_no": prod_details.bom_no,
"qty": prod_details.qty,
"buildable_qty": buildable_qty,
"ready_to_build": build
})
out.append(row)
for prod_item_details in frappe.db.get_values("Production Order Item",
{"parent": prod_details.name}, ["item_code", "source_warehouse"], as_dict=1):
item_list = frappe.db.sql("""SELECT
bom_item.item_code as item_code,
ifnull(ledger.actual_qty*bom.quantity/bom_item.stock_qty,0) as build_qty
FROM
`tabBOM` as bom, `tabBOM Item` AS bom_item
LEFT JOIN `tabBin` AS ledger
ON bom_item.item_code = ledger.item_code
AND ledger.warehouse = ifnull(%(warehouse)s,%(filterhouse)s)
WHERE
bom.name = bom_item.parent
and bom_item.item_code = %(item_code)s
and bom.name = %(bom)s
GROUP BY
bom_item.item_code""",
{"bom": prod_details.bom_no, "warehouse": prod_item_details.source_warehouse,
"filterhouse": filters.warehouse, "item_code": prod_item_details.item_code}, as_dict=1)
stock_qty = 0
count = 0
buildable_qty = prod_details.qty
for item in item_list:
count = count + 1
if item.build_qty >= (prod_details.qty - prod_details.produced_qty):
stock_qty = stock_qty + 1
elif buildable_qty >= item.build_qty:
buildable_qty = item.build_qty
if count == stock_qty:
build = "Y"
else:
build = "N"
row = frappe._dict({
"production_order": prod_details.name,
"status": prod_details.status,
"req_items": cint(count),
"instock": stock_qty,
"description": desc,
"source_warehouse": prod_item_details.source_warehouse,
"item_code": prod_item_details.item_code,
"bom_no": prod_details.bom_no,
"qty": prod_details.qty,
"buildable_qty": buildable_qty,
"ready_to_build": build
})
out.append(row)
return out
def get_production_orders():
out = frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")}, fields=["name","status"], order_by='name')
out = frappe.get_all("Production Order", filters={"docstatus": 1, "status": ( "!=","Completed")},
fields=["name","status", "bom_no", "qty", "produced_qty"], order_by='name')
return out
def get_columns():
@ -93,6 +97,18 @@ def get_columns():
"options": "",
"width": 230
}, {
"fieldname": "item_code",
"label": "Item Code",
"fieldtype": "Link",
"options": "Item",
"width": 110
},{
"fieldname": "source_warehouse",
"label": "Source Warehouse",
"fieldtype": "Link",
"options": "Warehouse",
"width": 110
},{
"fieldname": "qty",
"label": "Qty to Build",
"fieldtype": "Data",

View File

@ -470,3 +470,6 @@ erpnext.patches.v9_2.rename_translated_domains_in_en
erpnext.patches.v9_0.set_shipping_type_for_existing_shipping_rules
erpnext.patches.v9_0.update_multi_uom_fields_in_material_request
erpnext.patches.v10_0.rename_schools_to_education
erpnext.patches.v9_2.repost_reserved_qty_for_production
erpnext.patches.v9_2.remove_company_from_patient
erpnext.patches.v9_2.set_item_name_in_production_order

View File

@ -0,0 +1,5 @@
import frappe
def execute():
if 'company' in frappe.db.get_table_columns("Patient"):
frappe.db.sql("alter table `tabPatient` drop column company")

View File

@ -0,0 +1,7 @@
import frappe
def execute():
bins = frappe.db.sql("select name from `tabBin` where reserved_qty_for_production > 0")
for d in bins:
bin_doc = frappe.get_doc("Bin", d[0])
bin_doc.update_reserved_qty_for_production()

View File

@ -0,0 +1,11 @@
import frappe
def execute():
frappe.db.sql("""
update `tabBOM Item` bom, `tabProduction Order Item` po_item
set po_item.item_name = bom.item_name,
po_item.description = bom.description
where po_item.item_code = bom.item_code
and (po_item.item_name is null or po_item.description is null)
""")

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "field:party_type",
@ -13,6 +14,7 @@
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -43,17 +45,17 @@
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"in_create": 1,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-02-20 13:25:04.456818",
"modified": "2017-11-23 17:46:27.075001",
"modified_by": "Administrator",
"module": "Setup",
"name": "Party Type",
@ -64,8 +66,8 @@
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"create": 0,
"delete": 0,
"email": 1,
"export": 1,
"if_owner": 0,
@ -78,14 +80,14 @@
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
"write": 0
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"create": 0,
"delete": 0,
"email": 1,
"export": 1,
"if_owner": 0,
@ -98,14 +100,14 @@
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
"write": 0
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"create": 0,
"delete": 0,
"email": 1,
"export": 1,
"if_owner": 0,
@ -118,10 +120,10 @@
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
"write": 0
}
],
"quick_entry": 1,
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 1,

View File

@ -0,0 +1,23 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Party Type", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Party Type
() => frappe.tests.make('Party Type', [
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View File

@ -88,11 +88,10 @@ class Bin(Document):
and item.source_warehouse = %s
and pro.status not in ("Stopped", "Completed")''', (self.item_code, self.warehouse))[0][0]
if self.reserved_qty_for_production:
self.set_projected_qty()
self.set_projected_qty()
self.db_set('reserved_qty_for_production', self.reserved_qty_for_production)
self.db_set('projected_qty', self.projected_qty)
self.db_set('reserved_qty_for_production', flt(self.reserved_qty_for_production))
self.db_set('projected_qty', self.projected_qty)
def update_item_projected_qty(item_code):

View File

@ -410,11 +410,11 @@ def get_pos_profile_item_details(company, args, pos_profile=None):
@frappe.whitelist()
def get_pos_profile(company):
pos_profile = frappe.db.sql("""select * from `tabPOS Profile` where user = %s
and company = %s""", (frappe.session['user'], company), as_dict=1)
and company = %s and ifnull(disabled,0) != 1""", (frappe.session['user'], company), as_dict=1)
if not pos_profile:
pos_profile = frappe.db.sql("""select * from `tabPOS Profile`
where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
where ifnull(user,'') = '' and company = %s and ifnull(disabled,0) != 1""", company, as_dict=1)
return pos_profile and pos_profile[0] or None