Functions in direct bindings

Registered by Guewen Baconnier @ Camptocamp

As discussed in https://bugs.launchpad.net/openerp-connector/+bug/1210471 we should provide a way to use function in direct mappings. It should be done using a closure function.

Example of function mappings:

    direct = [
            (normalize_date('created_at'), 'created_at'),
            (unwrap_m2o('country_id'), 'country_id'),
            (convert('myfield', float), 'origin_field'),
    ]

     def normalize_date(field): # specific magento
         def transform(self, record):
             if record[field] == '0000-00-00 00:00:00':
                 return None
             return record[field]
        return transform

     def convert(field, conv_type):
         def transform(self, record):
             return conv_type(field)
        return transform

     def unwrap_m2o(field):
         def transform(self, record):
             # get the unwrapped id from the binding
        return transform

Blueprint information

Status:
Complete
Approver:
None
Priority:
Undefined
Drafter:
Guewen Baconnier @ Camptocamp
Direction:
Approved
Assignee:
Guewen Baconnier @ Camptocamp
Definition:
Approved
Series goal:
None
Implementation:
Implemented
Milestone target:
None
Started by
Guewen Baconnier @ Camptocamp
Completed by
Guewen Baconnier @ Camptocamp

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.