# -*- coding: utf-8 -*-
from openerp import models,fields,api,_
from openerp.exceptions import Warning

class sale_order(models.Model):
    _inherit = 'sale.order'

    @api.multi
    def action_button_confirm(self):
        message1 = ""
        # moneda = self.env['res.currency.rate'].search([('currency_id', '=', self.currency_id.id)], order ='id')
        # xrate = moneda[len(moneda) - 1]
        # xcambio = xrate.rate
        for xorden in self.order_line:
            if (xorden.price_unit) < (((xorden.product_id.product_tmpl_id.standard_price*(1+0.43)))) and not self.env['res.users'].browse(self.env.uid).has_group('sale_restrict_price_c.groups_restrict_price_c'):
                message1 += "\n Producto "+str(xorden.name)
                message1 += "\t Precio de Venta ("+str(xorden.price_unit)+")"
                message1 += "\t Precio mínimo ("+str((xorden.product_id.product_tmpl_id.standard_price*(1+0.43)))+")"

        message = "¡Precio de venta no permitido!\n ¡El monto ingresado es menor al precio C establecido!"
        message += message1
        if message1:
            raise Warning(_(message.rstrip()))

        return super(sale_order,self).action_button_confirm()