from odoo import models, fields

class ShopifyCostLine(models.Model):
    _name = 'shopify.cost.line'
    _description = 'Línea de Sincronización de Costos de Shopify'

    config_id = fields.Many2one(
        'shopify.config',
        string='Configuración Shopify',
        ondelete='cascade'
    )
    product_id = fields.Many2one(
        'product.product',
        string='Variante (Producto)',
        required=True,
        ondelete='cascade'
    )
    product_tmpl_id = fields.Many2one(
        related='product_id.product_tmpl_id',
        string='Plantilla (Modelo)',
        store=True,
    )
    default_code = fields.Char(
        related='product_id.default_code',
        string='SKU',
        store=True,
    )
    current_cost = fields.Float(
        string='Costo Actual (Odoo)',
        digits='Product Price'
    )
    new_cost = fields.Float(
        string='Costo Nuevo (Shopify)',
        digits='Product Price'
    )
    shopify_inventory_item_id = fields.Char(
        string='Inventory Item ID',
        help='ID interno de inventario en Shopify'
    )
    state = fields.Selection([
        ('pending', 'Pendiente'),
        ('done', 'Subido ✓'),
        ('error', 'Error ❌')
    ], string='Estado', default='pending')
    error_message = fields.Char(string='Detalle de Error')
