diff --git a/preview_easy/__manifest__.py b/preview_easy/__manifest__.py index b53c89b0f..2622dc98a 100644 --- a/preview_easy/__manifest__.py +++ b/preview_easy/__manifest__.py @@ -11,7 +11,7 @@ 'author': 'zxltwins', 'website': "www.odoo.com", 'version': '17.0', - "depends": ["base", 'sale'], + "depends": ["base",'sale'], "external_dependencies": {"python": ["mammoth"]}, "data": [ 'security/ir.model.access.csv', @@ -22,7 +22,9 @@ ], 'web.assets_backend': [ 'preview_easy/static/src/js/qweb.js', - 'preview_easy/static/src/xml/qweb.xml' + 'preview_easy/static/src/js/preview_many2one.js', + 'preview_easy/static/src/xml/qweb.xml', + 'preview_easy/static/src/xml/preview_many2one.xml', ], 'web.assets_frontend': [ diff --git a/preview_easy/static/description/123.xlsx b/preview_easy/static/description/123.xlsx new file mode 100644 index 000000000..4f8fc6a73 Binary files /dev/null and b/preview_easy/static/description/123.xlsx differ diff --git a/preview_easy/static/description/folder_icon.png b/preview_easy/static/description/folder_icon.png new file mode 100644 index 000000000..67a90d787 Binary files /dev/null and b/preview_easy/static/description/folder_icon.png differ diff --git a/preview_easy/static/src/js/preview_many2one.js b/preview_easy/static/src/js/preview_many2one.js new file mode 100644 index 000000000..daedd2c7f --- /dev/null +++ b/preview_easy/static/src/js/preview_many2one.js @@ -0,0 +1,148 @@ +/** @odoo-module **/ +import { registry } from "@web/core/registry"; +import { FileInput } from "@web/core/file_input/file_input"; +import { useSelectCreate } from "@web/views/fields/relational_utils"; +import { many2OneField, Many2OneField } from "@web/views/fields/many2one/many2one_field"; + + +export class PreviewMany2OneField extends Many2OneField { + static template = "preview_easy.Many2OneField"; + static components = { + ...Many2OneField.components, + FileInput + }; + static props = { + ...Many2OneField.props, + acceptedFileExtensions: { type: String, optional: true }, + showSelectBtn: { type: Boolean, optional: true }, + previewType: { type: String, optional: true }, + previewString: { type: String, optional: true }, + className: { type: String, optional: true }, + }; + setup() { + super.setup(); + const isToMany = false; + this.selectCreate = useSelectCreate({ + resModel: this.relation, + activeActions: {create: false, }, + onSelected: (resId) => { + const resIds = Array.isArray(resId) ? resId : [resId]; + const values = resIds.map((id) => ({ id })); + return this.update(values); + }, + onCreateEdit: ({ context }) => this.openMany2X({ context }), + onUnselect: isToMany ? undefined : () => this.update(), + }); + } + + async onFileUploaded(files) { + for (const file of files) { + if (file.error) { + return this.notification.add(file.error, { + title: _t("Uploading error"), + type: "danger", + }); + } + await this.update([{id: file.id, display_name: file.filename}]); + } + } + + async onFileRemove(deleteId) { + await this.update(false); + } + + get uploadText() { + return this.props.record.fields[this.props.name].string; + } + + // 获取文件 + getFile() { + const jsonData = { + id: Math.floor(Math.random() * 1000 * 1000 * 1000), + jsonrpc: "2.0", + method: "call", + params: { + args: [ + [this.resId], + ["id", "name", "mimetype"] + ], + kwargs: { + context: this.context, + }, + method: "read", + model: this.relation, + } + }; + let file; + $.ajax({ + url: "/web/dataset/call_kw/ir.attachment/read", + method: "POST", + dataType: 'json', + async: false, // 设置为同步请求 + beforeSend: (xhr) => {xhr.setRequestHeader('Content-Type', 'application/json');}, + data : JSON.stringify(jsonData), + success: (result) => { + file = result.result[0]; + } + }) + return file; + } + + getUrl(id) { + return "/web/content/" + id + "?download=true"; + } + + preview_Obj(id, name) { + var winStr = 'height=600,width=1000,top=' + (screen.height - 600) / 2 + ',left=' + (screen.width - 1000) / 2 + ',toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,location=no'; + var newWin = window.open('/web/content/preview/'+ id , name, winStr); + newWin.focus(); + } + + getExtension(file) { + return file.name.replace(/^.*\./, ""); + } + + async onExternalBtnClick() { + const domain = this.getDomain(); + this.selectCreate({ + domain, + context: this.props.record.context, + filters: [], + title: "Search", + }); + } + + get documentsInstalled() { + try { + const result = $.ajax({ + url: "/web/document_module/installed", + type: "POST", + async: false, // 设置为 false 表示同步请求 + contentType: "application/json", + data: "{}" + }); + return result?.responseJSON?.result?.installed; + } catch (error) { + console.error('Error fetching document installed status:', error); + return false; // 或者其他默认值 + } + } +} + +export const previewMany2OneField = { + ...many2OneField, + component: PreviewMany2OneField, + extractProps({ attrs, context, decorations, options, string }, dynamicInfo) { + const result = many2OneField.extractProps.apply(this, arguments); + return { + ...result, + acceptedFileExtensions: options.accepted_file_extensions, + showSelectBtn: options.show_select_btn === undefined ? true : options.show_select_btn, + previewType: options.preview_type, + previewString: options.preview_string, + className: attrs.class, + }; + }, +}; + +registry.category("fields").add("preview_many2one", previewMany2OneField); diff --git a/preview_easy/static/src/scss/qweb.scss b/preview_easy/static/src/scss/qweb.scss new file mode 100644 index 000000000..9e8f9832b --- /dev/null +++ b/preview_easy/static/src/scss/qweb.scss @@ -0,0 +1,5 @@ +.o_field_preview_many2many { + .oe_add { + + } +} \ No newline at end of file diff --git a/preview_easy/static/src/xml/preview_many2one.xml b/preview_easy/static/src/xml/preview_many2one.xml new file mode 100644 index 000000000..e8c2bf88f --- /dev/null +++ b/preview_easy/static/src/xml/preview_many2one.xml @@ -0,0 +1,91 @@ + + + + + + + + + + +
+ + + + + +
+
+ +
+ + + + +
+
+
+
+ + + + + + + + + +
+
+ + +
+ +
+ +
+ +
+
+ +
+
Uploading
+
+
+ +
+
×
+
+
+
+
+ +
diff --git a/preview_easy/views/preview.xml b/preview_easy/views/preview.xml index 24839367e..817df3f15 100644 --- a/preview_easy/views/preview.xml +++ b/preview_easy/views/preview.xml @@ -8,8 +8,10 @@ + + \ No newline at end of file diff --git a/yuthon_hr_employee/wizard/hr_employee_wizard.py b/yuthon_hr_employee/wizard/hr_employee_wizard.py index 59d67b804..2951878fe 100644 --- a/yuthon_hr_employee/wizard/hr_employee_wizard.py +++ b/yuthon_hr_employee/wizard/hr_employee_wizard.py @@ -35,11 +35,11 @@ class YuthonHrEmployeeWizard(models.Model): def employee_user_data(self, row): employee_name = self.env['hr.employee'].search([('name', '=', row[0].value)]) - date1 = pd.to_datetime(row[1].value, unit='d', origin='1899-12-30') - month2 = row[2].value + # date1 = pd.to_datetime(row[1].value, unit='d', origin='1899-12-30') + # month2 = row[2].value employee_date = { - 'open_start_time': date1, - 'interrupt_work_month': month2, + 'work_email': row[1].value, + # 'interrupt_work_month': month2, } if employee_name: employee_name.write(employee_date) diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index 696362ee9..36d593ef4 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -33,14 +33,15 @@

- +

- +

- +
@@ -75,7 +76,7 @@ - + @@ -86,17 +87,15 @@ - - - - - + + - + - + + @@ -171,7 +170,7 @@ - + diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index d68e5fb5c..8f3bdaa28 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -111,7 +111,7 @@ class PropertyLeaseContract(models.Model): legal_entity_id = fields.Many2one('ir.attachment', string="法人身份证") power_attorney_id = fields.Many2one('ir.attachment', string="授权委托书") handle_cards_id = fields.Many2one('ir.attachment', string="经办人身份证") - confirmation_transaction_id = fields.Many2one('ir.attachment', string="成交确认书)") + confirmation_transaction_id = fields.Many2one('ir.attachment', string="成交确认书") responsibility_book_id = fields.Many2one('ir.attachment', string="安全生产责任书") contract_time = fields.Date(string="合同签订日期") handover_time = fields.Date(string="交接日期") diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml index 6d0a408f8..e08754e1b 100644 --- a/yuthon_property_approval/views/property_lease_contract.xml +++ b/yuthon_property_approval/views/property_lease_contract.xml @@ -23,8 +23,10 @@
-
@@ -33,27 +35,28 @@ - - - - - - + + + + + + -