← Back to team overview

openerp-connector-community team mailing list archive

Re: litteral values

 

Hi David,

On 02/12/2014 09:51 PM, David Beal wrote:
Hi connectoristas,

I noticed the two methods for direct mapping

         direct = [(convert('source', str), 'target')]
         direct = [(none('source'), 'target')]

They are called 'modifiers' and are documented here [0].

Note that you can create and use new modifiers in a particular implementation of a connector if you need (I used them for normalizing dates for instance).

The modifiers (backend_to_m2o, m2o_to_backend) should also be used for all the relational fields (instead of the previous implicit mapping that do not cover all the cases). See [1] for an explanation.


seems really interesting to avoid tedious methods in mapping.

is there a possibility to include a another case for litteral values ? like this
         direct = [(litteral('my_particular_value'), 'target')]

So a default value. My feeling is that such a static assignement is very likely to be decorated with @only_create: once the record is created with 'my_particular_value', we do no longer want to write it again and in most cases we must not write it again to let the user change the value manually. (I did a 'default()' modifier when implementing the modifiers and preferred not to keep it for that reason)

So I'm not convinced that it is useful. Interested to have other opinions though.


Thanks for your replies

David BEAL
OpenERP Development - Integration
+33 (0)6 67 22 86 89
+33 (0)4 82 53 84 60


[0] http://openerp-connector.com/api/api_mapper.html#connector.unit.mapper.Mapper
[1] https://lists.launchpad.net/openerp-connector-community/msg00046.html

--
Guewen Baconnier
Business Solutions Software Developer

Camptocamp SA
PSE A, CH-1015 Lausanne
Phone: +41 21 619 10 39
Office: +41 21 619 10 10
http://www.camptocamp.com/


Follow ups

References