Encoding in XML format is a great way of including information in a structured way in modules datafiles. It’s also a good way to avoid critical information to be overridden by a user.
There is a Tryton limitation because currently modifying a record field coming from xml datafile is an all-or-nothing task (if the field is declared on the xml file, then becomes non-modifiable).
The model fields that are required must be entered in the data file in order to create the record
We include a new attribute (eg, “modifiable”) for the xml element that allows to modify the specific field. This will provide maximum flexibility, on which fields can be modified and which can not.
In the example of the product associated to the GNU Healh WHO meds, this is the situation:
The list and cost prices associated to the product are required fields, so we need to include them in the xml datafile.
If we have include the new attribute :
<field name="list_price" eval="0.0" modifiable="1"/>
Then the system will set the declared value as an initial price, but would later allow the user to modify that price. It will also skip this entry in the xml in the future (to avoid overriding the current value on the system).
With this functionality, in the WHO medicines example, we have both non modifiable fields (medicament product name, category, … ) and modifiable fields (prices). All of this while keeping the benefits of having the datafile in XML format.