from odoo import fields, models


class WooOrder(models.Model):
    _name = 'woo.order'
    _description = 'WooCommerce Order'

    instance_id = fields.Many2one('woo.instance', required=True, ondelete='cascade')
    sale_order_id = fields.Many2one('sale.order')
    woo_order_id = fields.Integer(index=True)
    woo_order_number = fields.Char()
    woo_status = fields.Char()
    invoice_id = fields.Many2one('account.move')
    invoice_synced = fields.Boolean()
    company_id = fields.Many2one(
        'res.company', required=True, default=lambda self: self.env.company,
    )
    state = fields.Selection([
        ('new', 'New'),
        ('confirmed', 'Confirmed'),
        ('shipped', 'Shipped'),
        ('completed', 'Completed'),
        ('cancelled', 'Cancelled'),
    ], default='new')
    shipment_ids = fields.One2many('woo.shipment', 'order_id')
