Odoo Modify or extend import process

Viewed 352

I want modify or extend the process on csv import in Odoo.

I have some fields autocalculated and other needed but is not in the csv file.

Having search the code and try using ir.action.todo, and ir.action.client but dont work.

Any idea, using hooks, or other work?

Thanks

Yoinier.

1 Answers

You just need to inherit the 'base_import.import' model

class Import(models.TransientModel):

    _inherit = 'base_import.import'

    @api.model
    def _convert_import_data(self, fields, options):
        # Override base method
        # Called when actual import start
        data, import_fields = super(Import, self)._convert_import_data(fields, options)

        # Do something ...

        return data, import_fields

    def parse_preview(self, options, count=10):
        # Override base method
        # Called when data loaded
        preview_data = super(Import, self).parse_preview(options, count=count)

        # Do something ...

        return preview_data

but, override the base import method is probably not a good idea, I'd suggest to use custom import wizard to do your custom import.

Related