earthians / marley

Open Source Health Information System
https://frappehealth.com
GNU General Public License v3.0
323 stars 244 forks source link

Attribute Error in Sales Invoice #353

Open Yogeshwaran2210 opened 10 months ago

Yogeshwaran2210 commented 10 months ago

Information about bug

App Versions

{
    "erpnext": "14.8.0",
    "frappe": "14.16.0",
    "healthcare": "14.0.2"
}

Route

Form/Patient/HLC-PAT-2023-00114

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1587, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/handler.py", line 304, in run_doc_method
    response = doc.run_method(method)
  File "apps/frappe/frappe/model/document.py", line 908, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1260, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1242, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 905, in fn
    return method_object(*args, **kwargs)
  File "apps/healthcare/healthcare/healthcare/doctype/patient/patient.py", line 182, in invoice_patient_registration
    sales_invoice.save(ignore_permissions=True)
  File "apps/frappe/frappe/model/document.py", line 303, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 325, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 257, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1039, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 908, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1260, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1244, in runner
    add_to_return_value(self, f(self, method, *args, **kwargs))
  File "apps/healthcare/healthcare/healthcare/utils.py", line 492, in manage_invoice_validate
    if doc.service_unit and len(doc.items):
AttributeError: 'HealthcareSalesInvoice' object has no attribute 'service_unit'

Request Data

{
    "type": "POST",
    "args": {
        "docs": "{\"name\":\"HLC-PAT-2023-00114\",\"owner\":\"22yogesh2001@gmail.com\",\"creation\":\"2023-12-11 10:34:37.945914\",\"modified\":\"2023-12-11 11:31:09.705958\",\"modified_by\":\"22yogesh2001@gmail.com\",\"docstatus\":0,\"idx\":0,\"naming_series\":\"HLC-PAT-.YYYY.-\",\"first_name\":\"Venkat\",\"last_name\":\"Prabhu\",\"patient_name\":\"Venkat Prabhu\",\"sex\":\"Male\",\"blood_group\":\"B Positive\",\"dob\":\"1980-05-05\",\"status\":\"Disabled\",\"inpatient_record\":\"HLC-INP-2023-00026\",\"inpatient_status\":\"Admitted\",\"report_preference\":\"Print\",\"mobile\":\"9813659569\",\"phone\":\"9852165659\",\"email\":\"venkat_prabhu@gmail.com\",\"invite_user\":0,\"pincode\":\"600036\",\"city\":\"Kovilambakkam\",\"district\":\"CHENNAI\",\"state\":\"Tamil Nadu\",\"country\":\"India\",\"address\":\"Kovilambakkam, Chennai - 600036.\",\"corporate_name\":\"\",\"price_list\":\"\",\"customer\":\"Venkat Prabhu\",\"customer_group\":\"All Customer Groups\",\"territory\":\"All Territories\",\"default_currency\":\"INR\",\"default_price_list\":\"Standard Selling\",\"language\":\"en\",\"occupations\":\"Writer\",\"marital_status\":\"Married\",\"allergies\":\"No\",\"medication\":\"No\",\"medical_history\":\"Yes\",\"surgical_history\":\"Yes\",\"tobacco_past_use\":\"Yes\",\"tobacco_current_use\":\"Yes\",\"alcohol_past_use\":\"Yes\",\"alcohol_current_use\":\"Yes\",\"surrounding_factors\":\"No\",\"other_risk_factors\":\"No\",\"doctype\":\"Patient\",\"patient_relation\":[],\"__onload\":{\"addr_list\":[],\"contact_list\":[{\"name\":\"Venkat Prabhu-HLC-PAT-2023-00114\",\"creation\":\"2023-12-11 10:34:39.248974\",\"modified\":\"2023-12-11 10:34:39.459561\",\"modified_by\":\"22yogesh2001@gmail.com\",\"owner\":\"22yogesh2001@gmail.com\",\"docstatus\":0,\"idx\":0,\"first_name\":\"Venkat\",\"middle_name\":null,\"last_name\":\"Prabhu\",\"email_id\":\"venkat_prabhu@gmail.com\",\"user\":null,\"address\":null,\"sync_with_google_contacts\":0,\"status\":\"Passive\",\"salutation\":null,\"designation\":null,\"gender\":\"Male\",\"phone\":\"9852165659\",\"mobile_no\":\"9813659569\",\"company_name\":null,\"image\":\"\",\"google_contacts\":null,\"google_contacts_id\":null,\"pulled_from_google_contacts\":0,\"is_primary_contact\":1,\"department\":null,\"unsubscribed\":0,\"_user_tags\":null,\"_comments\":null,\"_assign\":null,\"_liked_by\":null,\"is_billing_contact\":0,\"email_ids\":[],\"phone_nos\":[]}],\"dashboard_info\":[]},\"__last_sync_on\":\"2023-12-19T08:02:37.703Z\"}",
        "method": "invoice_patient_registration"
    },
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/run_doc_method"
}

Response Data

{
    "exc_type": "DoesNotExistError",
    "exception": "AttributeError: 'HealthcareSalesInvoice' object has no attribute 'service_unit'"
}

Module

Outpatient Module, Inpatient ADT, Laboratory, Clinical Procedure, Patient History, Setup / Configuration, Regional / Other Integrations

Version

"erpnext": "14.8.0",
"frappe": "14.16.0",
"healthcare": "14.0.2"

Installation method

None

Relevant log output / Stack trace / Full Error Message.

No response

Code of Conduct

Yogeshwaran2210 commented 10 months ago

@Sajinsr , This Issue is not solve yet. what i do?

Yogeshwaran2210 commented 10 months ago

@Sajinsr and @akashkrishna619 , Have you tried to fix this issue and there is any updates for the same?

vamagithub commented 10 months ago

This bug looks resolved in the following versions. Tested on v14.xx.xx

ERPNext: v14.55.2 (version-14)
Frappe Framework: v14.60.0 (version-14)
Healthcare: v14.0.2 (version-14)

This bug was capture upon clicking the button - Invoice Patient Registration on Patient DT. To enable this button we have to check Collect Fee for Patient Registration in Healthcare Settings.

Please take a look at the screen-cast to view the flow.

Screencast from 21-12-23 05:52:43 PM IST.webm

Yogeshwaran2210 commented 10 months ago

This bug looks resolved in the following versions. Tested on v14.xx.xx

ERPNext: v14.55.2 (version-14)
Frappe Framework: v14.60.0 (version-14)
Healthcare: v14.0.2 (version-14)

This bug was capture upon clicking the button - Invoice Patient Registration on Patient DT. To enable this button we have to check Collect Fee for Patient Registration in Healthcare Settings.

Please take a look at the screen-cast to view the flow.

Screencast.from.21-12-23.05.52.43.PM.IST.webm

@vamagithub Thanks for your reply,

Please take a look at the screen-cast the issue is still persists.
please give a solution to solve the Issue.

https://github.com/frappe/health/assets/143701136/d7804e58-f3f2-49b9-b825-f1d400a63d0b

vamagithub commented 10 months ago

Hey @Yogeshwaran2210 Can you please share your versions of Frappe,ERPNext & Healthcare.

Yogeshwaran2210 commented 10 months ago

Hey @Yogeshwaran2210 Can you please share your versions of Frappe,ERPNext & Healthcare.

Yes sure, Here are the versions that I used. ERPNext 14.8.0 Frappe 14.16.0 Healthcare 14.0.2

vamagithub commented 10 months ago

Can you try doing bench update for the apps or pull latest v14 minor versions to get the fix for this

Yogeshwaran2210 commented 10 months ago

Can you try doing bench update for the apps or pull latest v14 minor versions to get the fix for this

@vamagithub

After the bench update,
ERPNext 14.56.0
Frappe 14.60.0
Healthcare 14.0.2

Error shows when login to my instance,

**### App Versions

{
    "erpnext": "14.56.0",
    "frappe": "14.60.0",
    "healthcare": "14.0.2"
}

Route

Workspaces/Home

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 95, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1628, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/__init__.py", line 808, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "apps/frappe/frappe/desk/desktop.py", line 400, in get_desktop_page
    workspace.build_workspace()
  File "apps/frappe/frappe/desk/desktop.py", line 165, in build_workspace
    self.number_cards = {"items": self.get_number_cards()}
  File "apps/frappe/frappe/desk/desktop.py", line 23, in wrapper
    return fn(*args, **kwargs)
  File "apps/frappe/frappe/desk/desktop.py", line 355, in get_number_cards
    number_cards = self.doc.number_cards
AttributeError: 'Workspace' object has no attribute 'number_cards'

Request Data

{
    "type": "POST",
    "args": {
        "page": "{\"name\":\"Healthcare\",\"title\":\"Healthcare\",\"for_user\":\"\",\"parent_page\":\"\",\"content\":\"[{\\\"id\\\":\\\"3deFvd-YPk\\\",\\\"type\\\":\\\"chart\\\",\\\"data\\\":{\\\"chart_name\\\":\\\"Patient Appointments\\\",\\\"col\\\":12}},{\\\"id\\\":\\\"WRuLHUjK58\\\",\\\"type\\\":\\\"spacer\\\",\\\"data\\\":{\\\"col\\\":12}},{\\\"id\\\":\\\"pVT4jz2UL0\\\",\\\"type\\\":\\\"header\\\",\\\"data\\\":{\\\"text\\\":\\\"<span class=\\\\\\\"h4\\\\\\\">Your Shortcuts</span>\\\",\\\"col\\\":12}},{\\\"id\\\":\\\"mUrQz0D-UU\\\",\\\"type\\\":\\\"shortcut\\\",\\\"data\\\":{\\\"shortcut_name\\\":\\\"Patient Appointment\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"zvj6QVGoaF\\\",\\\"type\\\":\\\"shortcut\\\",\\\"data\\\":{\\\"shortcut_name\\\":\\\"Patient\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"_oW7Ib4vBn\\\",\\\"type\\\":\\\"shortcut\\\",\\\"data\\\":{\\\"shortcut_name\\\":\\\"Dashboard\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"NozrN3A_KZ\\\",\\\"type\\\":\\\"spacer\\\",\\\"data\\\":{\\\"col\\\":12}},{\\\"id\\\":\\\"dWnYzaIC7W\\\",\\\"type\\\":\\\"header\\\",\\\"data\\\":{\\\"text\\\":\\\"<span class=\\\\\\\"h4\\\\\\\">Reports &amp; Masters</span>\\\",\\\"col\\\":12}},{\\\"id\\\":\\\"v72SzkLMCN\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Masters\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"LOyPMqtwF4\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Consultation Setup\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"PtcRwL9lw6\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Consultation\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"LmU3aBRTFJ\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Healthcare Services\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"pBQ7dpru5s\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Records and History\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"ySManrYqBj\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Inpatient Records\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"YVmv637Q27\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Assessments & Settings\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"5q8NRq0lIn\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Lab\\\",\\\"col\\\":4}},{\\\"id\\\":\\\"hRd_GoodC_\\\",\\\"type\\\":\\\"card\\\",\\\"data\\\":{\\\"card_name\\\":\\\"Exercise & Therapy\\\",\\\"col\\\":4}}]\",\"public\":1,\"module\":\"Healthcare\",\"icon\":\"healthcare\",\"is_hidden\":0,\"label\":\"Healthcare\",\"is_editable\":true,\"selected\":true}"
    },
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.desktop.get_desktop_page"
}

Response Data


{
    "exception": "AttributeError: 'Workspace' object has no attribute 'number_cards'"
}
```**

Now, what I do. Please help me to fix the issue.
Yogeshwaran2210 commented 10 months ago
@vamagithub Here I attached a image error msg.
Please give me any solution to fix this issue.

Screenshot (22)

vamagithub commented 10 months ago

Strange, it works for me correctly on the same versions. @Yogeshwaran2210

vamagithub commented 10 months ago

Try

  1. bench update
  2. bench restart
  3. bench start
Yogeshwaran2210 commented 10 months ago

@vamagithub Thanks for reply, When I try to restart the bench the error shows, and I am running the instance using Virtual Box.

image

vamagithub commented 10 months ago

Please share your email

Yogeshwaran2210 commented 10 months ago

Please share your email

@vamagithub yogeshwaran@agilehealth.in

Yogeshwaran2210 commented 9 months ago

@vamagithub Hi, is there is any solution for this error..