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

from odoo import models, fields


class SkeenVisitaInsumo(models.Model):
    _name = 'skeen.visita.insumo'
    _description = 'Insumo Usado en Visita'

    visita_id = fields.Many2one('skeen.visita', string='Visita', required=True, ondelete='cascade')
    item_id = fields.Many2one('skeen.inventario.item', string='Artículo', required=True,
                               domain=[('active', '=', True)])
    qty = fields.Float(string='Cantidad', required=True, default=1.0)
    notes = fields.Char(string='Notas')

    _sql_constraints = [
        ('qty_positiva', 'CHECK(qty > 0)', 'La cantidad debe ser mayor a 0!')
    ]
