sale_order.py 1.2 KB

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. from openerp import models,fields,api,_
  3. from openerp.exceptions import Warning
  4. class sale_order(models.Model):
  5. _inherit = 'sale.order'
  6. @api.multi
  7. def action_button_confirm(self):
  8. message1 = ""
  9. # moneda = self.env['res.currency.rate'].search([('currency_id', '=', self.currency_id.id)], order ='id')
  10. # xrate = moneda[len(moneda) - 1]
  11. # xcambio = xrate.rate
  12. for xorden in self.order_line:
  13. if (xorden.price_unit) < (((xorden.product_id.product_tmpl_id.standard_price*(1+0.62)))) and not self.env['res.users'].browse(self.env.uid).has_group('sale_restrict_price_a.groups_restrict_price_a'):
  14. message1 += "\n Producto "+str(xorden.name)
  15. message1 += "\t Precio de Venta ("+str(xorden.price_unit)+")"
  16. message1 += "\t Precio mínimo ("+str((xorden.product_id.product_tmpl_id.standard_price*(1+0.62)))+")"
  17. message = "¡Precio de venta no permitido!\n¡El monto ingresado es menor al precio A establecido!"
  18. message += message1
  19. if message1:
  20. raise Warning(_(message.rstrip()))
  21. return super(sale_order,self).action_button_confirm()