mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of timesheet_description and timesheet_description_sale for 11.0 -- Forces popup for timesheet (detail) and allows you to display them as Markdown in the portal.
This commit is contained in:
1
timesheet_description/__init__.py
Normal file
1
timesheet_description/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
24
timesheet_description/__manifest__.py
Normal file
24
timesheet_description/__manifest__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
'name': 'Timesheet Description',
|
||||
'version': '11.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,
|
||||
}
|
||||
1
timesheet_description/models/__init__.py
Normal file
1
timesheet_description/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import timesheet
|
||||
23
timesheet_description/models/timesheet.py
Normal file
23
timesheet_description/models/timesheet.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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')
|
||||
|
||||
@api.multi
|
||||
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)
|
||||
9
timesheet_description/views/project_templates.xml
Normal file
9
timesheet_description/views/project_templates.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<template id="portal_my_task_markdown" inherit_id='project.portal_my_task' 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>
|
||||
46
timesheet_description/views/timesheet_views.xml
Normal file
46
timesheet_description/views/timesheet_views.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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']" position="attributes">
|
||||
<attribute name="context">{'default_project_id': project_id, 'default_task_id': active_id}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='timesheet_ids']/tree" position="attributes">
|
||||
<attribute name="editable"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='timesheet_ids']" position="inside">
|
||||
<form>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="project_id" invisible="1"/>
|
||||
<field name="task_id" invisible="1"/>
|
||||
<field name="user_id" invisible="1" groups="hr_timesheet.group_timesheet_manager"/>
|
||||
<field name="employee_id" groups="hr_timesheet.group_timesheet_manager"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date"/>
|
||||
<field name="unit_amount" string="Time Spent" widget="float_time"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="name" nolabel="1" widget="text" placeholder="Describe your activity (you can use markdown)" colspan="4"/>
|
||||
</sheet>
|
||||
</form>
|
||||
</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="//tree" position="attributes">
|
||||
<attribute name="editable"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
1
timesheet_description_sale/__init__.py
Normal file
1
timesheet_description_sale/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
21
timesheet_description_sale/__manifest__.py
Normal file
21
timesheet_description_sale/__manifest__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
'name': 'Timesheet Description Sale',
|
||||
'version': '11.0.1.0.0',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'website': 'https://hibou.io/',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Tools',
|
||||
'complexity': 'easy',
|
||||
'description': """
|
||||
Linker module to inject fields required by timesheets for sales.
|
||||
""",
|
||||
'depends': [
|
||||
'timesheet_description',
|
||||
'sale_timesheet',
|
||||
],
|
||||
'data': [
|
||||
'views/timesheet_views.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
19
timesheet_description_sale/views/timesheet_views.xml
Normal file
19
timesheet_description_sale/views/timesheet_views.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?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="timesheet_description.view_task_form2_inherit" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='timesheet_ids']" position="attributes">
|
||||
<attribute name="context">{'default_project_id': project_id, 'default_task_id': active_id}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='timesheet_ids']/tree" position="attributes">
|
||||
<attribute name="editable"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='timesheet_ids']/form//field[@name='project_id']" position="before">
|
||||
<field name="timesheet_invoice_id" invisible="1"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user