# Copyright 2020 Raul Carbonell
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models, _


class SaleOrderSage200(models.Model):
    _inherit = "sale.order"

    ejerciciopedido = fields.Char(string="Ejercicio", )

    seriepedido = fields.Char(string="Serie", )

    numeropedido = fields.Char(string="Num. Pedido", )

    no_facturable = fields.Boolean(
        string='No Facturable',
        required=False)

    observaciones_cliente = fields.Text(string="Observaciones Cliente", )

    observaciones_albaran = fields.Text(string="Observaciones Albarán", )

    observaciones_factura = fields.Text(string="Observaciones Factura", )

    traspasarSage200 = fields.Selection(
        string="Traspasar a Sage 200",
        selection=[
                ('pending', 'Pending'),
                ('complete', 'Complete'),
        ],
    )

    nameOrigen = fields.Char(string="Nº Presupuesto Origen", )

    def action_confirm(self):
        res = super(SaleOrderSage200, self).action_confirm()
        self.write({
            'traspasarSage200': 'pending'
        })
