예제 #1
0
    def get_defaults(self):
        '''specifies the defaults for this sobject'''
        # use the naming the generate the next code
        from naming import AssetCodeNaming
        naming = AssetCodeNaming()
        asset_code = naming.get_next_code(self)

        defaults = super(Asset, self).get_defaults()
        defaults.update({"asset_type": "asset", 'code': asset_code})

        return defaults
예제 #2
0
    def create_with_autocode(cls,
                             name,
                             asset_library,
                             description,
                             asset_type="asset"):

        # create the new asset
        asset = SObjectFactory.create(cls.SEARCH_TYPE)
        asset.set_value("name", name)
        asset.set_value("asset_library", asset_library)
        asset.set_value("description", description)

        asset.set_value("asset_type", asset_type)

        # use the naming the generate the next code
        from naming import AssetCodeNaming
        naming = AssetCodeNaming()
        asset_code = naming.get_next_code(asset)
        asset.set_value("code", asset_code)

        asset.commit()
        return asset