Skip to Content
Menu
This question has been flagged
1 Reply
8879 Views

I have a Custom module in which i want to import CSV File record (using buttom beside Create button), I can able to import csv file to odoo database but i want to override import method to our Custom module

I want to import that csv file to outside mysql database so that whenever i import csv it will import to odoo (PostgreSQL) database and also update to mySQL database

I found which method is been used to import functionaility but not able to orverride that import method,

Import module Path: base_import/models/base_import.py
model name: " base_import.import "

Method name:
@api.multi
def do(self, fields, options, dryrun=False):

Any help will worth to me. Thanks in advance

Avatar
Discard
Best Answer

Inherit model 'base_import.import'


# -*- coding: utf-8 -*-

import logging

from odoo import models, api

_logger = logging.getLogger(__name__)


class Import(models.TransientModel):

    _inherit = 'base_import.import'

    @api.multi

    def do(self, fields, options, dryrun=False):

        res_import = super(Import, self).do(fields, options, dryrun)

        if "your.model" == self.res_model:

            if not dryrun:

                # Insert your query

                self._cr.execute("""

                    Insert your query""")

                _logger.info('Done update Department, Province.')

        return res_import


I hope it helps you

Avatar
Discard

How can I generate log after updating a field using CSV import ??