#python #odoo-13
Вопрос:
Этот код взят из моей реализации в Odoo. Когда моя форма создается, к сожалению, время в форме указано неверно. В приложении сеанс установлен на 10:30 (24-часовой формат), но в форме он выводится как 10:18.. В чем может быть проблема?
# -*- coding: utf-8 -*-
from odoo import models, fields, _
from odoo.addons import decimal_precision as dp
class OperationalLog(models.Model):
_name = 'operational.details.log'
_description = 'Operation Details Log'
_rec_name = 'customer_id'
_order = 'sequence, customer_id'
sequence = fields.Integer(string="Sequence", default=10)
customer_id = fields.Many2one(
string='Customer',
comodel_name='planning.role',
)
date = fields.Date(string="Date")
serial_no = fields.Integer(string="Log Page Serial No", default=1)
scheduled_hours = fields.Float(string="Schedule Hours")
scheduled_starting_time = fields.Float(string="Starting Time", digits=dp.get_precision('Product Price'))
scheduled_ending_time = fields.Float(string="Ending Time", digits=dp.get_precision('Product Price'))
engine_type = fields.Char(string="Engine Type/Rating")
training_type = fields.Selection([
('lpc', 'LPC'),
('ppc', 'PPC'),
('check', 'Check'),
('training', 'Training'),
('recurrent_training', 'Recurrent Training'),
('assessment', 'Assessment of Competence')], string="Type of Training")
activity_type = fields.Char(string="Activity Type")
company_id = fields.Many2one(
"res.company", string="Company", default=lambda self: self.env.company.id,
)
actual_hours = fields.Float(string="Actual Hours")
actual_starting_time = fields.Float(string="Starting Time", digits='Product Price',)
actual_ending_time = fields.Float(string="Ending Time", digits=dp.get_precision('Product Price'))
utilized = fields.Float(string="Utilized")
downtime = fields.Float(string="Downtime")
tri_name = fields.Char(string="TRI")
tre_name = fields.Char(string="TRE")
observer_name = fields.Char(string="Observer")
trainee_1 = fields.Char(string="Trainee 1")
trainee_2 = fields.Char(string="Trainee 2")
trainee_3 = fields.Char(string="Trainee 3")
trainee_4 = fields.Char(string="Trainee 4")
faults_or_remarks = fields.Text(string="SESSION REMARKS/FAULTS")
simulator = fields.Char(string="Simulator")
def format_time(self, time):
time = '{0:02.0f}:{1:02.0f}'.format(*divmod(time * 60, 60))
return time