Merge branch 'mig/18.0/timesheet_description' into '18.0-test'

mig/18.0/timesheet_description into 18.0-test

See merge request hibou-io/hibou-odoo/suite!1738
This commit is contained in:
Jared Kipe
2024-10-24 16:34:05 +00:00
6 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,24 @@
{
'name': 'Timesheet Description',
'version': '18.0.1.0.0',
'author': 'Hibou Corp. <hello@hibou.io>',
'website': 'https://hibou.io/',
'license': 'AGPL-3',
'category': 'Tools',
'complexity': 'easy',
'description': """
Timesheet entries will be made in a form view, allowing the end user to enter more descriptive timesheet entries.
Optionally, allows you to display your timesheet entries in markdown on the front end of the website.
""",
'depends': [
'project',
'hr_timesheet',
],
'data': [
'views/project_templates.xml',
'views/timesheet_views.xml',
],
'installable': True,
'auto_install': False,
}

View File

@@ -0,0 +1 @@
from . import timesheet

View File

@@ -0,0 +1,22 @@
try:
from markdown import markdown
except ImportError:
markdown = None
from odoo import api, fields, models
class AnalyticLine(models.Model):
_inherit = 'account.analytic.line'
name_markdown = fields.Html(compute='_compute_name_markdown')
def _compute_name_markdown(self):
if not markdown:
for line in self:
# Why not just name? Because it needs to be escaped.
# Use nothing to indicate that it shouldn't be used.
line.name_markdown = ''
else:
for line in self:
line.name_markdown = markdown(line.name)

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="portal_my_task_markdown" inherit_id='hr_timesheet.portal_timesheet_table' customize_show="True" name="Timesheet Use Markdown">
<xpath expr="//t[@t-esc='timesheet.name']" position="replace">
<div t-if="timesheet.name_markdown" t-field="timesheet.name_markdown" />
<t t-else="" t-esc="timesheet.name" />
</xpath>
</template>
</odoo>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_task_form2_inherit" model="ir.ui.view">
<field name="name">project.task.form.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited" />
<field name="arch" type="xml">
<xpath expr="//field[@name='timesheet_ids']/list" position="attributes">
<attribute name="editable"/>
</xpath>
<xpath expr="//field[@name='timesheet_ids']/form//field[@name='name']" position="attributes">
<attribute name="widget">text</attribute>
<attribute name="placeholder">Describe your activity (you can use markdown)</attribute>
<attribute name="colspan">2</attribute>
</xpath>
</field>
</record>
<record id="hr_timesheet_line_tree_inherit" model="ir.ui.view">
<field name="name">account.analytic.line.tree.hr_timesheet.inherit</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" />
<field name="arch" type="xml">
<xpath expr="//list" position="attributes">
<attribute name="editable"/>
</xpath>
</field>
</record>
</odoo>