Error in saving Customer Address

Hi all,

I have installed Frappe 16 and ErpNext 16 on an ubuntu virtual machine. All the install process goes well.

Now i’m connected to the ERP.

I try to save a customer and I have this issue :

App Versions

{
	"frappe": "16.0.0-dev",
	"erpnext": "16.0.0",
	"hrms": "16.0.0-dev"
}

Route

Form/Address/new-address-nlczvjlzso

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 121, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 63, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
    return frappe.handler.handle()
           ~~~~~~~~~~~~~~~~~~~~~^^
  File "apps/frappe/frappe/handler.py", line 53, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1124, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 36, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/desk/form/save.py", line 43, in savedocs
    doc.save()
    ~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 518, in save
    return self._save(*args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 540, in _save
    return self.insert()
           ~~~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 447, in insert
    self.run_before_save_methods()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 1332, in run_before_save_methods
    self.run_method("validate")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1181, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1578, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1556, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ~~^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1178, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/custom/address.py", line 12, in validate
    self.validate_reference()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "apps/erpnext/erpnext/accounts/custom/address.py", line 31, in validate_reference
    if self.is_your_company_address and not [row for row in self.links if row.link_doctype == "Company"]:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ExtendedAddress' object has no attribute 'is_your_company_address'. Did you mean: 'update_company_address'?

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Address\",\"name\":\"new-address-nlczvjlzso\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"address_type\":\"Plant\",\"country\":\"France\",\"is_primary_address\":1,\"is_shipping_address\":1,\"disabled\":0,\"links\":[],\"address_title\":\"par défaut\",\"address_line1\":\"ZA les Douets Jaunes\",\"pincode\":\"49360\",\"city\":\"Somloire\"}",
		"action": "Save"
	},
	"btn": {
		"jQuery370042494640436555431": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 2556,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": null
}

Response Data

{
	"exception": "AttributeError: 'ExtendedAddress' object has no attribute 'is_your_company_address'. Did you mean: 'update_company_address'?",
	"exc_type": "AttributeError",
	"_exc_source": "erpnext (app)"
}

Any solution ?

Regards,

PoyPoy

From my understanding, this error is happening because the Address validation code is trying to access a field that doesn’t exist in your Address DocType.

The traceback shows this line being executed:
self.is_your_company_address
but the Address document (ExtendedAddress) does not have this field, so it throws:
AttributeError: ‘ExtendedAddress’ object has no attribute ‘is_your_company_address’
This is most probably a schema mismatch
May be migration did not run properly after upgrading ERPNext.

  1. Run migrations and clear cache
  2. Open Customize Form → Address and confirm whether is_your_company_address exists.
    If it’s missing, that explains the error.

Dear Rishabgupta,

It’s a fresh install and not a migration…

I’m an old developper and I am not yet sufficiently proficient in the new framework update protocols such as frappe…

Following your comment, I checked my DocType Address on my installation against the Cloud version and indeed I am missing two fields:

21 Is Your Company Address Check Is Your Company Address

22 Links Table Links Dynamic Link

I have to find a way to integrate these fields on my install…

Regards,

PoyPoy

Dear PoyPoy,

Thank you for the clarification.

If it’s a fresh install, then a migration issue is less likely, though I’ve still seen similar behaviour when the DocType schema and the loaded Python code go slightly out of sync.

It would be helpful to double-check whether the is_your_company_address field exists in the Address DocType on your setup and whether any custom app or patch is extending the Address model. That might explain why the validation logic is being triggered while the field itself is missing.

Please do share what you find during your investigation.

I have fixed the issue by generating a CUSTOMIZE FORM

I added the field “is_your_company_address” which was not present on the initial DOCTYPE.

Now the address saved correctly…

I continue my discover of this wonderful software…

Regards,

PoyPoy