custom Magento modules, error at category import: The value "xxxx" for the field "default_sort_by" is not in the selection

Created by Raphaƫl Valyi - http://www.akretion.com on on 2011-02-23
Keywords:

If you get such an error during category import:
Validate Error: The value "editora" for the field "default_sort_by" is not in the selection

Here our Magento has a module/customization bringing an extra category called "editora". Unfortunately, currently you can work around with this with a small patch because OpenERP selections are not extensible at runtime.
The good news is that the patch is simple. For us it is as simple as:

=== modified file 'product.py'
--- product.py 2011-02-21 12:46:43 +0000
+++ product.py 2011-02-23 00:28:36 +0000
@@ -67,13 +67,15 @@
                     ('None', 'Use Config Settings'),
                     ('position', 'Best Value'),
                     ('name', 'Name'),
- ('price', 'Price')
+ ('price', 'Price'),
+ ("['editora']", 'Editora')
                     ], 'Available Product Listing (Sort By)'),
         'default_sort_by': fields.selection([
                     ('None', 'Use Config Settings'),
                     ('position', 'Best Value'),
                     ('name', 'Name'),
- ('price', 'Price')
+ ('price', 'Price'),
+ ('editora', 'Editora')
                     ], 'Default Product Listing Sort (Sort By)'),
         'magerp_stamp':fields.datetime('Magento stamp')
         }