在使用第一次筛选后的数据集后
后续再用第一次的结果再次进行筛选
从第二次开始筛选时,就用filtered_domain
search_data = self.env['assets.header.common.info'].search([
['company_id', '=', self.company_id.id],
['asset_type', '!=', 'low_value']
]) # 符合公司的、不等于低值的
if len(search_data) != 0:
if self.asset_type and len(search_data) != 0:
search_data = search_data.filtered_domain([
['asset_type', '=', self.asset_type]
])
if self.asset_class and len(search_data) != 0:
search_data = search_data.filtered_domain([
['asset_category_id', 'in', self.asset_class.ids]
])
if self.admin_dept_id and len(search_data) != 0:
search_data = search_data.filtered_domain([
['admin_dept_id', 'in', self.admin_dept_id.ids]
])
search_data_result = search_data.filtered_domain([
['usage_status', '=', 'running'],
['depreciation_method', '!=', 'no_depreciation'],
['depreciation_times', '>', 0],
['depreciation_convention', '=', 'next_month']
])
print(search_data_result)
if len(search_data_result) != 0:
# 排除掉入账日期属于参数所选折旧期间
search_data_result = search_data_result.filtered_domain([
'|',
['record_date', '<', self.period_id.start_date],
['record_date', '>', self.period_id.end_date]
])
|