# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo import tools


class Image(models.Model):
    _name = 'car.image'
    _description = 'Vehicle\'s Image'

    name = fields.Char(string="Commentaire")
    image = fields.Binary(string="Photo", attachment=True)
    # image_small = fields.Binary(string="Image Small", attachment=True, default=lambda self: self._default_image_small)
    vehicle_id = fields.Many2one(comodel_name='car.vehicle', string='Vehicle')
    company_id = fields.Many2one(comodel_name='res.company', string='Company', default=False)

    @api.model
    def create(self, vals):
        return super(Image, self).create(vals)

    def close(self):
        return {
            'type': 'ir.actions.act_window_close'
        }


class Vehicle(models.Model):

    _inherit = 'car.vehicle'

    image_ids = fields.One2many(comodel_name='car.image', inverse_name='vehicle_id', string='Pictures')
