
Prior to this commit, the Odoo documentation was mainly split between two repositories: odoo/odoo/doc and odoo/documentation-user. Some bits of documentation were also hosted elsewhere (e.g., wiki, upgrade, ...). This was causing several problems among which: - The theme, config, Makefile, and similar technical resources had to be duplicated. This resulted in inconsistent layout, features, and build environments from one documentation to another. - Some pages did not fit either documentation as they were relevant for both users and developers. Some were relevant to neither of the two (e.g., DB management). - Cross-doc references had to be absolute links and they broke often. - Merging large image files in the developer documentation would bloat the odoo/odoo repository. Some contributions had to be lightened to avoid merging too many images (e.g., Odoo development tutorials). - Long-time contributors to the user documentation were chilly about going through the merging process of the developer documentation because of the runbot, mergebot, `odoo-dev` repository, etc. - Some contributors would look for the developer documentation in the `odoo/documentation-user` repository. - Community issues about the user documentation were submitted on the `odoo/odoo` repository and vice-versa. Merging all documentations in one repository will allow us to have one place, one theme, one work process, and one set of tools (build environment, ...) for all of the Odoo docs. As this is a good opportunity to revamp the layout of the documentation, a brand new theme replaces the old one. It features a new way to navigate the documentation, centered on the idea of always letting the reader know what is the context (enclosing section, child pages, page structure ...) of the page they are reading. The previous theme would quickly confuse readers as they navigated the documentation and followed cross-application links. The chance is also taken to get rid of all the technical dangling parts, performance issues, and left-overs. Except for some page-specific JS scripts, the Odoo theme Sphinx extension is re-written from scratch based on the latest Sphinx release to benefit from the improvements and ease future contributions. task-2351938 task-2352371 task-2205684 task-2352544 Closes #945
79 lines
2.9 KiB
Plaintext
79 lines
2.9 KiB
Plaintext
# HG changeset patch
|
|
# Parent 85a8d7317b9e13480f39ad739955442d15144451
|
|
# Parent 16fcdc4c6462a7872636f3c19550c16879af5281
|
|
|
|
diff --git a/openacademy/models.py b/openacademy/models.py
|
|
--- a/openacademy/models.py
|
|
+++ b/openacademy/models.py
|
|
@@ -1,5 +1,6 @@
|
|
# -*- coding: utf-8 -*-
|
|
|
|
+from datetime import timedelta
|
|
from odoo import models, fields, api, exceptions
|
|
|
|
class Course(models.Model):
|
|
@@ -57,6 +58,8 @@ class Session(models.Model):
|
|
attendee_ids = fields.Many2many('res.partner', string="Attendees")
|
|
|
|
taken_seats = fields.Float(string="Taken seats", compute='_taken_seats')
|
|
+ end_date = fields.Date(string="End Date", store=True,
|
|
+ compute='_get_end_date', inverse='_set_end_date')
|
|
|
|
@api.depends('seats', 'attendee_ids')
|
|
def _taken_seats(self):
|
|
@@ -83,6 +86,27 @@ class Session(models.Model):
|
|
},
|
|
}
|
|
|
|
+ @api.depends('start_date', 'duration')
|
|
+ def _get_end_date(self):
|
|
+ for r in self:
|
|
+ if not (r.start_date and r.duration):
|
|
+ r.end_date = r.start_date
|
|
+ continue
|
|
+
|
|
+ # Add duration to start_date, but: Monday + 5 days = Saturday, so
|
|
+ # subtract one second to get on Friday instead
|
|
+ duration = timedelta(days=r.duration, seconds=-1)
|
|
+ r.end_date = r.start_date + duration
|
|
+
|
|
+ def _set_end_date(self):
|
|
+ for r in self:
|
|
+ if not (r.start_date and r.end_date):
|
|
+ continue
|
|
+
|
|
+ # Compute the difference between dates, but: Friday - Monday = 4 days,
|
|
+ # so add one day to get 5 days instead
|
|
+ r.duration = (r.end_date - r.start_date).days + 1
|
|
+
|
|
@api.constrains('instructor_id', 'attendee_ids')
|
|
def _check_instructor_not_in_attendees(self):
|
|
for r in self:
|
|
diff --git a/openacademy/views/openacademy.xml b/openacademy/views/openacademy.xml
|
|
--- a/openacademy/views/openacademy.xml
|
|
+++ b/openacademy/views/openacademy.xml
|
|
@@ -125,11 +125,22 @@
|
|
</field>
|
|
</record>
|
|
|
|
+ <!-- calendar view -->
|
|
+ <record model="ir.ui.view" id="session_calendar_view">
|
|
+ <field name="name">session.calendar</field>
|
|
+ <field name="model">openacademy.session</field>
|
|
+ <field name="arch" type="xml">
|
|
+ <calendar string="Session Calendar" date_start="start_date" date_stop="end_date" color="instructor_id">
|
|
+ <field name="name"/>
|
|
+ </calendar>
|
|
+ </field>
|
|
+ </record>
|
|
+
|
|
<record model="ir.actions.act_window" id="session_list_action">
|
|
<field name="name">Sessions</field>
|
|
<field name="res_model">openacademy.session</field>
|
|
<field name="view_type">form</field>
|
|
- <field name="view_mode">tree,form</field>
|
|
+ <field name="view_mode">tree,form,calendar</field>
|
|
</record>
|
|
|
|
<menuitem id="session_menu" name="Sessions"
|