5/22/2019 - 8:58 AM

Odoo install function

Add the data file to your openerp file Create the data file with the noupdate="1" flag This indicates the code should be run once, then never again It will run upon installation, or if the module is already installed, then it will the next time the module is upgraded. Define the function element in your data file to trigger the appropriate python method You can see the documentation here for details, but the end result looks something like this:

    'data': [


    <data noupdate="1">
        <function model="" name="method_name"/>


from openerp import models
import logging
_logger = logging.getLogger(__name__)

class ResCountry(models.Model):
    _inherit = ''

    def method_name(self):
        for country in[]):