Save/delete in proteus script, "You are not allowed..." error

Exploring the opportunity with proteus script and have some problem:

from proteus import config, Model, Wizard, Report
logger.info('Connecting to DB...')
config = config.set_trytond('my_database', config_file='/etc/trytond.conf')
logger.info('Picking Images table')
TrytonImage = Model.get('mymodule.image')  # Class with all images

def main():
    try:
        directory = r'./static'        
        logger.info('Searching for all images...')
        for filename in os.listdir(directory):
            if filename.endswith(".svg"):
                search_domain = ['OR',[('filename', 'like', f'{filename[:-4]}.jpg')],[('filename', 'like', f'{filename[:-4]}.png')]]
                image_ids = TrytonImage.find(search_domain) # 
                if len(image_ids)>0:
                    image_record = image_ids[0]
                    svg_filename_with_path = os.path.join(directory,filename)
                    image_record.svg_filename = filename
                    with open(svg_filename_with_path,'rb') as f:
                        image_record.svg_image = f.read()
                        logger.info('Copied svg data to the record...')
                    try:
                        image_record.save() # Finally save the record    
                        logger.info(f'Record {image_record.id} saved to DB successfully.')
                    except Exception as e:
                        logger.warning(e)
                    logger.info('Image record was updated with SVG data successfully.')

While a couple of records are updated successfully, others throw the Error:

You are not allowed to access “Image in mymodule”. -

And I have no idea what is the problem. I tried to update/delete it manually — it works fine.
Also, I don’t understand if I need a config.set_context(??WHAT IS HERE??).
And if so — how?

You have define access right on your custom model such that the default “admin” user has no access.

Why I think that is the context feature because some of the records were updated successfully:

01/17/2021 05:41:24 AM: /__main__/ INFO: Copied svg data to the record.
01/17/2021 05:41:24 AM: /__main__/ INFO: Saving Image with id 858
{'language': 'en', 'language_direction': 'ltr', 'groups': [1, 3, 2]}
01/17/2021 05:41:24 AM: /__main__/ INFO: Record 858 saved to DB sucessfully.
01/17/2021 05:41:24 AM: /__main__/ INFO: Image record was updated with SVG data sucessfully.
01/17/2021 05:41:24 AM: /__main__/ INFO: Lets remove the svg image record if it exists...
01/17/2021 05:41:24 AM: /__main__/ INFO: ...didnt found image record with such svg
01/17/2021 05:41:24 AM: /__main__/ INFO: Found: 1 IDs...
01/17/2021 05:41:24 AM: /__main__/ INFO: JPG file name in the record: d39bdd4c42_2020-12-30-21-29-17.jpg
01/17/2021 05:41:24 AM: /__main__/ INFO: Copied svg data to the record.
01/17/2021 05:41:24 AM: /__main__/ INFO: Saving Image with id 779
{'language': 'en', 'language_direction': 'ltr', 'groups': [1, 3, 2]}
01/17/2021 05:41:24 AM: /__main__/ WARNING: You are not allowed to access "Image of Inspection". - 
01/17/2021 05:41:24 AM: /__main__/ INFO: Image record was updated with SVG data sucessfully.
01/17/2021 05:41:24 AM: /__main__/ INFO: Found: 1 IDs...
01/17/2021 05:41:24 AM: /__main__/ INFO: JPG file name in the record: 8139132416_2020-12-30-10-55-51.jpg
01/17/2021 05:41:24 AM: /__main__/ INFO: Copied svg data to the record.
01/17/2021 05:41:24 AM: /__main__/ INFO: Saving Image with id 765
{'language': 'en', 'language_direction': 'ltr', 'groups': [1, 3, 2]}
01/17/2021 05:41:24 AM: /__main__/ WARNING: You are not allowed to access "Image of Inspection". - 
01/17/2021 05:41:24 AM: /__main__/ INFO: Image record was updated with SVG data sucessfully.

Here I can see,

Saving Image with id 858
01/17/2021 05:41:24 AM: /__main__/ INFO: Image record was updated with SVG data sucessfully.

ID id:858 passed while id:779 did not.

Except if you have written access rights depending on the context (which is a bad idea), it should not depend on the context.

Is there a way to have a more detailed error — what’s wrong in trytond with saving a record to DB??
Not just: “You are not allowed to access…”
I didn’t set any restrictions on access to the module.

Thank you. You sent me in the right direction, that was a weird discrepancy in user rights for the “admin” (admin had additional restrictions in groups config!). Removed those silly rights restrictions and it worked okay.

Constantine.