Fixtures question

I would like to validate my understanding of Fixtures.

Let’s use this simple example where I want to apply a property setter that will show the default_item_manufacturer field in Item list view. I would like to add this default to all my production sites.

I would add this fixtures in hooks.py

{
    "doctype": "Property Setter",
    "filters": [
        [
            "name",
            "in",
            [
                "Item-default_item_manufacturer-in_list_view"
            ]
        ]
    ]
}

Then issue a bench export-fixtures.

This is working well, the property setter is assigned after a migrate update on the production site.

Now if the production site user decides to change this and use customize form to set back in_list_view=0.

Question 1
I understand on next migrate, my fixture will be re-applied and overwrite in_list_view back to 1, correct ?

Question 2
How does frappe determine when a fixture needs to be re-applied ? I guess it uses the modified timestamp ? Is it validating if the timestamp on production site is before the fixture timestamp ?

Question 3
If Question 1 is correct, how can I do a ‘one-shot’ fixture that is applied only once, and wont sync on every migrate operation?

Question 3.1
My idea is to define a patches instead, and use make_property_setter().
Is it the way to go ?

Thanks in advance

Yes, due the fact it’s under fixtures, frappe will reimport it again, on every migrate.

It don’t, it just reimport it!

Over patches, they only run one single time.

You line of thinking is properly.

3 Likes