bitacora.py
1015 Bytes
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError, Warning, RedirectWarning
from datetime import datetime, timedelta
class hgt_nuevo_correo(models.TransientModel):
_name = 'tpv.correccion_bitacora'
_description = 'Carga de datos extras'
#################Campos del buscador#########################
texto = fields.Text(string='Texto')
modelo = fields.Char(string='Modelo',
required=True)
modelo_id = fields.Integer(string='Id')
#########################Botones#############################
def Agregar(self):
if self.texto == False or self.texto == "":
raise Warning("No se registro nada")
reg = self.env[self.modelo].browse(self.modelo_id)
orig = reg.bitacora
Texto = """{} - {}: {} \n{}""".format(self.env.user.display_name,
(datetime.now() - timedelta(hours=3)).strftime('%Y-%m-%d %H:%M'),
self.texto, orig)
reg.bitacora = Texto