diff --git a/yuthon_property/models/property_accounts_receivable.py b/yuthon_property/models/property_accounts_receivable.py index 038edab00..0f3303bee 100644 --- a/yuthon_property/models/property_accounts_receivable.py +++ b/yuthon_property/models/property_accounts_receivable.py @@ -1,5 +1,7 @@ from odoo import models, fields, api import xlwt +from odoo.modules import get_module_resource + class PropertyAccountsReceivable(models.Model): _name = 'property.accounts.receivable' @@ -40,19 +42,79 @@ class PropertyAccountsReceivable(models.Model): def unlink(self): return super().unlink() - def report_button_xls(self): - workbook = xlwt.Workbook() # 创建一个工作簿 - worksheet = workbook.add_sheet('Sheet1') - for record in self: - worksheet.write(1, 0, record.original_amount) - action = { - 'type': 'ir.actions.act_url', # 表示将执行一个客户端动作。 - 'tag': 'self', - 'context': dict({ - 'url': 'yuthon_property/static/others/property_bases_account.xlsx', - 'module': 'yuthon_property', # 指定模块名称 - 'content_type': 'application/vnd.ms-excel' - }, **self._context) - } - return action + def style_excel(self): + # 定义样式,可根据需要修改 + report_no_style = xlwt.XFStyle() + report_title_style = xlwt.XFStyle() + style_white = xlwt.XFStyle() + report_borders_style = xlwt.XFStyle() + + # 设置样式属性,例如字体、边框等 + # 这里简单示例,可根据实际需求完善 + font = xlwt.Font() + font.bold = True + report_title_style.font = font + + borders = xlwt.Borders() + borders.left = xlwt.Borders.THIN + borders.right = xlwt.Borders.THIN + borders.top = xlwt.Borders.THIN + borders.bottom = xlwt.Borders.THIN + report_borders_style.borders = borders + + return [report_no_style, report_title_style, style_white, report_borders_style] + + def download_template_with_data(self): + # 获取当前记录 + record = self + + # 通用样式 + workbook = xlwt.Workbook() # 创建一个工作簿 + worksheet = workbook.add_sheet('Sheet1') # 为工作簿添加一个页签 + + report_no_style = self.style_excel()[0] + report_title_style = self.style_excel()[1] + style_white = self.style_excel()[2] + report_borders_style = self.style_excel()[3] + + # 这里假设从当前记录中获取数据,可根据实际模型字段修改 + report_data = record + + # 设置列宽 + for col in range(0, 7): + worksheet.col(col).width = 3000 + + # 写入表头 + header = ['字段1', '字段2', '字段3', '字段4', '字段5', '字段6', '字段7'] + for col, value in enumerate(header): + worksheet.write(0, col, value, report_borders_style) + + # 写入数据行 + # 假设模型中有多个相关记录,可根据实际情况修改 + row = 1 + for record in self: + worksheet.write(row, 0, record.lessee_id.name, report_borders_style) + # worksheet.write(row, 1, record.field2, report_borders_style) + # worksheet.write(row, 2, record.field3, report_borders_style) + # worksheet.write(row, 3, record.field4, report_borders_style) + # worksheet.write(row, 4, record.field5, report_borders_style) + # worksheet.write(row, 5, record.field6, report_borders_style) + # worksheet.write(row, 6, record.field7, report_borders_style) + row += 1 + + # 保存文件 + template_path = get_module_resource('yuthon_property', 'static', 'tmpl', 'fapiaojibenxinxi.xlsx') + workbook.save(template_path) + + # # 导出动作 + # action = { + # 'type': 'ir.actions.act_url', # 表示将执行一个客户端动作。 + # 'tag': 'self', + # 'context': dict({ + # 'url': 'yuthon_property/static/tmpl/fapiaojibenxinxi.xlsx', + # 'module': 'yuthon_property', # 指定模块名称 + # 'content_type': 'application/vnd.ms-excel' + # }, **self._context) + # } + # return action diff --git a/yuthon_property/models/property_bank_statements.py b/yuthon_property/models/property_bank_statements.py index 251eb638b..f73568c4c 100644 --- a/yuthon_property/models/property_bank_statements.py +++ b/yuthon_property/models/property_bank_statements.py @@ -8,9 +8,18 @@ class PropertyBankStatements(models.Model): _name = 'property.bank.statements' _description = '银行流水' - name = fields.Char('账户卡号') + name = fields.Char('对方账号') company_id = fields.Many2one('yuthon.property.company', string="收款账户") - name_account = fields.Char('户名') + name_account = fields.Char('对方户名') + bank_branch = fields.Char('对方开户机构') + bank_number = fields.Char('对方行号') + bank_name = fields.Char('对方行名') + account_code = fields.Char('账户明细编号') + journal_date = fields.Date('记账日期') + purpose = fields.Char('用途') + message = fields.Char('回单个性化信息') + number = fields.Char('凭证号') + extract = fields.Char('摘要') start_time = fields.Datetime('交易时间') contract_account = fields.Char(string="合同累计应收") contract_penalty = fields.Char(string="合同累计违约金") diff --git a/yuthon_property/static/tmpl/fapiaojibenxinxi.xlsx b/yuthon_property/static/tmpl/fapiaojibenxinxi.xlsx index 998599a9d..3d3e41dfc 100644 Binary files a/yuthon_property/static/tmpl/fapiaojibenxinxi.xlsx and b/yuthon_property/static/tmpl/fapiaojibenxinxi.xlsx differ diff --git a/yuthon_property/views/property_accounts_receivable_views.xml b/yuthon_property/views/property_accounts_receivable_views.xml index 233364b3a..059c4a16d 100644 --- a/yuthon_property/views/property_accounts_receivable_views.xml +++ b/yuthon_property/views/property_accounts_receivable_views.xml @@ -73,11 +73,10 @@ code - - - + action = model.download_template_with_data() + + + 发票明细信息模板下载 diff --git a/yuthon_property/views/property_bank_statements_views.xml b/yuthon_property/views/property_bank_statements_views.xml index a029379a1..73e708b99 100644 --- a/yuthon_property/views/property_bank_statements_views.xml +++ b/yuthon_property/views/property_bank_statements_views.xml @@ -8,12 +8,21 @@ + + + + + + + + +