29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding:utf-8 -*-
|
|
# @FileName :planning_slot.py
|
|
# @Time :2025/1/12 下午3:18
|
|
# @Author :zzw
|
|
from odoo import models, fields, api, _
|
|
from typing import Dict, List
|
|
|
|
|
|
class TxPlanningSlot(models.Model):
|
|
_inherit = "planning.slot"
|
|
_order = 'resource_id'
|
|
|
|
@api.model
|
|
@api.returns('self')
|
|
def search_fetch(self, domain, field_names, offset=0, limit=None, order=None):
|
|
if self._context.get('show_job_title', False):
|
|
if not order:
|
|
order = 'resource_id'
|
|
return super().search_fetch(domain, field_names, offset, limit, order)
|
|
|
|
def web_read(self, specification: Dict[str, Dict]) -> List[Dict]:
|
|
res = super().web_read(specification)
|
|
if self._context.get('show_job_title', False):
|
|
if res and res[0].get('resource_id', {}).get('id'):
|
|
data_list = [r.get('resource_id', {}).get('id') for r in res if r.get('resource_id', {})]
|
|
self.env['resource.resource'].search([('id', 'in', data_list)], order="sequence,name")
|
|
return res
|