Create on field added form and list view, export datetime format changed

This commit is contained in:
prakash 2022-01-20 13:14:21 +05:30
parent 696a762a13
commit ed405196f6
2 changed files with 36 additions and 16 deletions

View File

@ -1,21 +1,34 @@
# -*- coding: utf-8 -*-
# from odoo import http
import io
from odoo.tools import image_process, topological_sort, html_escape, pycompat, ustr, apply_inheritance_specs, lazy_property, float_repr
from odoo.addons.web.controllers.main import ExportXlsxWriter, ExportFormat, ExcelExport
from odoo.exceptions import AccessError, UserError, AccessDenied
from odoo.tools.translate import _
from odoo.tools.misc import str2bool, xlsxwriter, file_open
from odoo import api, http, SUPERUSER_ID, _
from odoo.tests import common, tagged
# class CorCustom(http.Controller):
# @http.route('/cor_custom/cor_custom/', auth='public')
# def index(self, **kw):
# return "Hello, world"
class CustomExportXlsxWriter(ExportXlsxWriter): #http.Controller
def __custom_init__(self, field_names, row_count=0):
self.field_names = field_names
self.output = io.BytesIO()
self.workbook = xlsxwriter.Workbook(self.output, {'in_memory': True})
self.base_style = self.workbook.add_format({'text_wrap': True})
self.header_style = self.workbook.add_format({'bold': True})
self.header_bold_style = self.workbook.add_format({'text_wrap': True, 'bold': True, 'bg_color': '#e9ecef'})
self.date_style = self.workbook.add_format({'text_wrap': True, 'num_format': 'dd/mm/yyyy'})
self.datetime_style = self.workbook.add_format({'text_wrap': True, 'num_format': 'dd/mm/yyyy hh:mm:ss'})
self.worksheet = self.workbook.add_worksheet()
self.value = False
if row_count > self.worksheet.xls_rowmax:
raise UserError(
_('There are too many rows (%s rows, limit: %s) to export as Excel 2007-2013 (.xlsx) format. Consider splitting the export.') % (
row_count, self.worksheet.xls_rowmax))
ExportXlsxWriter.__init__ = __custom_init__
# @http.route('/cor_custom/cor_custom/objects/', auth='public')
# def list(self, **kw):
# return http.request.render('cor_custom.listing', {
# 'root': '/cor_custom/cor_custom',
# 'objects': http.request.env['cor_custom.cor_custom'].search([]),
# })
# @http.route('/cor_custom/cor_custom/objects/<model("cor_custom.cor_custom"):obj>/', auth='public')
# def object(self, obj, **kw):
# return http.request.render('cor_custom.object', {
# 'object': obj
# })

View File

@ -6,6 +6,12 @@
<field name="model">project.project</field>
<field name="inherit_id" ref="sale_timesheet.project_project_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='options_active']/div" position="after">
<div name="creation_div" attrs="{'invisible': [('id', '=', False)]}">
<label for="create_date" class="oe_inline" string="Created On"/>
<field name="create_date" readonly="1" class="oe_inline"/>
</div>
</xpath>
<xpath expr="//button[@name='action_view_timesheet']" position="replace">
<button string="Project Overview" class="oe_stat_button" type="object" name="action_view_timesheet"
icon="fa-puzzle-piece" attrs="{'invisible': [('allow_billable', '=', False)]}" invisible="1"/>
@ -175,6 +181,7 @@
<field name="inherit_id" ref="project.view_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="create_date"/>
<field name="sub_project" widget="many2many_tags" context="{'default_is_sub_project':True}"/>
</xpath>
</field>