diff --git a/yuthon_hr_employee/models/yuthon_hr_department.py b/yuthon_hr_employee/models/yuthon_hr_department.py index 5d5801634..d304ee1fa 100644 --- a/yuthon_hr_employee/models/yuthon_hr_department.py +++ b/yuthon_hr_employee/models/yuthon_hr_department.py @@ -17,28 +17,28 @@ class YuthonHrDepartment(models.Model): start_date = fields.Date(string="生效日期", default=fields.Date.today()) expiration_date = fields.Date(string="失效日期", default=fields.Date.today()) end_date = fields.Date(string="结束时间") - department_code = fields.Char(string="部门序号", store=True) - lower_ids = fields.One2many('hr.department', 'parent_id', string="下级部门") + department_code = fields.Char(string="部门序号") + # lower_ids = fields.One2many('hr.department', 'parent_id', string="下级部门") @api.onchange('department_code', 'parent_id') def _onchange_department_code(self): for code in self: if code.parent_id.department_code: - code.department_code = code.parent_id.department_code + (code.department_code.split('.')[-1] if code.department_code else '') + code.department_code = code.parent_id.department_code + (code.department_code.split('.')[-1] if code.department_code else '') else: code.department_code = code.department_code - code.update_code() + # code.update_code() + # + # def update_code(self): + # def cycle_code(parent,parent_code): + # for child in parent.lower_ids: + # new_code = parent_code +(child.department_code.split('.')[-1] if child.department_code else '') + # self.env['hr.department'].search([('id', '=', child.id.origin)]).write({'department_code': new_code}) + # cycle_code(child,new_code) + # + # cycle_code(self, self.department_code) - def update_code(self): - def cycle_code(parent,parent_code): - for child in parent.lower_ids: - new_code = parent_code +(child.department_code.split('.')[-1] if child.department_code else '') - self.env['hr.department'].search([('id', '=', child.id.origin)]).write({'department_code': new_code}) - cycle_code(child,new_code) - - cycle_code(self, self.department_code) - - @api.depends('name','parent_id') + @api.depends('name', 'parent_id') def _compute_display_name(self): for record in self: if record.parent_id: diff --git a/源码/源码.js b/源码/源码.js index 199e503db..76b006a83 100644 --- a/源码/源码.js +++ b/源码/源码.js @@ -4,13 +4,13 @@ export class SelectCreateDialog extends Component { setup() { this.viewService = useService("view"); this.dialogService = useService("dialog"); - this.state = useState({ resIds: [] }); + this.state = useState({resIds: []}); // ℹ️ `_t` can only be inlined directly inside JS template literals // after Babel has been updated to version 2.12. const translatedText = _t("No records found!"); this.busy = false; // flag used to ensure we only call once the onSelected/onUnselect props this.baseViewProps = { - display: { searchPanel: true }, // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + display: {searchPanel: true}, // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! editable: false, // readonly noBreadcrumbs: true, noContentHelp: markup(`

${escape(translatedText)}

`), @@ -20,4 +20,14 @@ export class SelectCreateDialog extends Component { this.state.resIds = resIds; }, }; - } \ No newline at end of file + } + + // addons\web\static\src\views\list\list_renderer.js + get getEmptyRowIds() { + let nbEmptyRow = Math.max(0, this.props.list.records.length); // !!!!!!!!!!!!!!!!!!!!!!! + if (nbEmptyRow > 0 && this.displayRowCreates) { + nbEmptyRow -= 1; + } + return Array.from(Array(nbEmptyRow).keys()); + } +} \ No newline at end of file