Skip to content

URY Table autoname fails: missing imports and apostrophe in restaurant name breaks naming series #101

@os-erps

Description

@os-erps

Environment

  • ERPNext: 15.102.0
  • Frappe: 15.103.1
  • URY: 0.2.1

Bug 1: Missing imports in ury_table.py

Error

NameError: name 're' is not defined

Location

ury/ury/doctype/ury_table/ury_table.pyautoname() method

Cause

re and make_autoname are used but never imported.

Fix

import re
from frappe.model.naming import make_autoname

Bug 2: Apostrophe in restaurant name breaks naming series

Error

InvalidNamingSeriesError: Special Characters except '-', '#', '.', 
'/', '{' and '}' not allowed in naming series Victoria's-.##

Cause

self.restaurant.replace(" ", "-") strips spaces but not apostrophes,
causing the naming series to contain an invalid ' character.

Fix

prefix = re.sub("-+", "-", re.sub(r"[^a-zA-Z0-9-]", "", 
    self.restaurant.replace(" ", "-")))

Fixed file

import re
from frappe.model.naming import make_autoname
import frappe
from frappe.model.document import Document

class URYTable(Document):
    def autoname(self):
        prefix = re.sub("-+", "-", re.sub(r"[^a-zA-Z0-9-]", "", 
            self.restaurant.replace(" ", "-")))
        self.name = make_autoname(prefix + "-.##")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions