← Back to team overview

openupgrade-drivers team mailing list archive

Re: [Question #227303]: what to do in post/pre migration scripts with NEW fields

 

Question #227303 on OpenUpgrade Server changed:
https://answers.launchpad.net/openupgrade-server/+question/227303

    Status: Open => Answered

Stefan Rijnhart (Therp) proposed the following answer:
No action is needed on a required field if there is a sane default
value. Such a default will be applied automatically by the ORM (but for
required fields only). That is why the analysis files attempt to list
the default value under 'req_default'.

If the default value is delivered by a method the return value of which
depends on the user (e.g. company_id), use a call to
openupgrade.set_defaults(cr, pool, {'model': [(field, None)]}). The None
value triggers that the default will be calculated as the user that
created the record.

-- 
You received this question notification because you are a member of
OpenUpgrade Drivers, which is an answer contact for OpenUpgrade Server.