40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
from odoo import models, fields, api, exceptions, _
|
|
|
|
|
|
class ParkingFeeApproval(models.Model):
|
|
_name = 'parking.fee.approval'
|
|
_description = '停车费发放'
|
|
_inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin']
|
|
|
|
|
|
active = fields.Boolean('Active', default=True, tracking=True)
|
|
code = fields.Char(string="流水号",
|
|
default=lambda self: self.env['ir.sequence'].next_by_code('parking_fee_approval_code'))
|
|
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
|
|
department_id = fields.Many2one(related='users_id.employee_id.department_id', string="申请部门")
|
|
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
|
|
default='normal')
|
|
date_application = fields.Date(string="申请日期")
|
|
license_plate = fields.Char(string="车牌号")
|
|
text = fields.Char(string='事由')
|
|
unit = fields.Char(string="单位")
|
|
name = fields.Char(string="标题", compute='_compute_name')
|
|
duration = fields.Integer(string="时长")
|
|
work_end = fields.Boolean(string="结束")
|
|
|
|
def _get_default_name_title(self):
|
|
return self._description if self._description else self._name
|
|
|
|
name_title = fields.Char(default=_get_default_name_title)
|
|
|
|
@api.depends('license_plate', 'date_application', 'duration')
|
|
def _compute_name(self):
|
|
for rec in self:
|
|
if rec.license_plate and rec.date_application and rec.duration:
|
|
date_str = rec.date_application.strftime('%Y-%m-%d')
|
|
rec.name = f"{rec.license_plate}/{date_str}/{rec.duration}小时"
|
|
else:
|
|
rec.name = self._description
|
|
|