How I can set the "square meter" as the default unit of measure automatically?

My decision was very simple:
in file i configure function after_install:

after_install = "default_settings.stock_settings.default_square_meters"

In file I created functions:

def set_default_unit(unit):
        doc = frappe.get_doc({"doctype": "Stock Settings"})
        doc.stock_uom = unit

def default_square_meters():
      set_default_unit("Square Meter")

But when docker install all applications, it gives me the next exception:

frappe.exceptions.LinkValidationError: Could not find Default Stock UOM: Square Meter

How I can fix it or is exist another way of realization of this case?

could you set the default using customize form instead? You could export customization to an app after your done.