[MIG] web_calendar_slot_duration: Migration to 16.0

TT45649
pull/3084/head
Henrik Norlin 2023-08-30 16:08:17 +02:00 committed by Christopher Rogos
parent cf3f722f8b
commit 084c67a07a
6 changed files with 87 additions and 35 deletions

View File

@ -2,10 +2,13 @@
Calendar slot duration Calendar slot duration
====================== ======================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b6cdb18144c44833ba86f19e14860a819285cd5d4ffd937f9633f6fbdfbeb93d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status :target: https://odoo-community.org/page/development-status
@ -14,14 +17,14 @@ Calendar slot duration
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/15.0/web_calendar_slot_duration :target: https://github.com/OCA/web/tree/16.0/web_calendar_slot_duration
:alt: OCA/web :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_calendar_slot_duration :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_calendar_slot_duration
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/15.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:alt: Try me on Runbot :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -63,8 +66,8 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_calendar_slot_duration%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_calendar_slot_duration%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -76,6 +79,14 @@ Authors
* Tecnativa * Tecnativa
Contributors
~~~~~~~~~~~~
* `Tecnativa <https://www.tecnativa.com>`_:
* Jairo Llopis
* Stefan Ungureanu
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -97,6 +108,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-Yajo| |maintainer-Yajo|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/15.0/web_calendar_slot_duration>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_calendar_slot_duration>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -3,7 +3,7 @@
{ {
"name": "Calendar slot duration", "name": "Calendar slot duration",
"summary": "Customizable calendar slot durations", "summary": "Customizable calendar slot durations",
"version": "15.0.1.0.0", "version": "16.0.1.0.0",
"development_status": "Production/Stable", "development_status": "Production/Stable",
"category": "Extra Tools", "category": "Extra Tools",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",
@ -14,7 +14,8 @@
"installable": True, "installable": True,
"assets": { "assets": {
"web.assets_backend": [ "web.assets_backend": [
"web_calendar_slot_duration/static/src/js/calendar_model.esm.js" "web_calendar_slot_duration/static/src/js/calendar_common_renderer.esm.js",
"web_calendar_slot_duration/static/src/js/calendar_model.esm.js",
] ]
}, },
"depends": ["web"], "depends": ["web"],

View File

@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Jairo Llopis
* Stefan Ungureanu

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Calendar slot duration</title> <title>Calendar slot duration</title>
<style type="text/css"> <style type="text/css">
@ -366,8 +366,10 @@ ul.auto-toc {
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b6cdb18144c44833ba86f19e14860a819285cd5d4ffd937f9633f6fbdfbeb93d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_calendar_slot_duration"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_calendar_slot_duration"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_calendar_slot_duration"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_calendar_slot_duration"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of backend calendars to support custom <p>This module extends the functionality of backend calendars to support custom
slot durations and to allow you to provide more specific UX regarding event slot durations and to allow you to provide more specific UX regarding event
duration and snapping.</p> duration and snapping.</p>
@ -380,7 +382,8 @@ duration and snapping.</p>
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li> <li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul> <li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li> <li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li> <li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -411,8 +414,8 @@ doesnt provide any end-user functionality.</p>
<h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1> <h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_calendar_slot_duration%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_calendar_slot_duration%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -423,8 +426,18 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Tecnativa</li> <li>Tecnativa</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id7">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Jairo Llopis</li>
<li>Stefan Ungureanu</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2> <h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
@ -432,7 +445,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/Yajo"><img alt="Yajo" src="https://github.com/Yajo.png?size=40px" /></a></p> <p><a class="reference external" href="https://github.com/Yajo"><img alt="Yajo" src="https://github.com/Yajo.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_calendar_slot_duration">OCA/web</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_calendar_slot_duration">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -0,0 +1,21 @@
/** @odoo-module **/
/* Copyright 2023 Tecnativa - Stefan Ungureanu
* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
import {CalendarCommonRenderer} from "@web/views/calendar/calendar_common/calendar_common_renderer";
import {patch} from "@web/core/utils/patch";
patch(
CalendarCommonRenderer.prototype,
"WebCalendarSlotDurationCalendarCommonRenderer",
{
get options() {
const options = this._super(...arguments);
if (this.env.searchModel.context.calendar_slot_duration) {
options.slotDuration =
this.env.searchModel.context.calendar_slot_duration;
}
return options;
},
}
);

View File

@ -1,20 +1,22 @@
/* Copyright 2021 Tecnativa - Jairo Llopis /** @odoo-module **/
/* Copyright 2023 Tecnativa - Stefan Ungureanu
* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ * License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
odoo.define("web_calendar_slot_duration.CalendarModel", function (require) { import {CalendarModel} from "@web/views/calendar/calendar_model";
var CalendarModel = require("web.CalendarModel"); import {patch} from "@web/core/utils/patch";
CalendarModel.include({ patch(CalendarModel.prototype, "WebCalendarSlotDurationCalendarModel", {
/** buildRawRecord(partialRecord, options = {}) {
* @override if (
*/ this.env.searchModel.context.calendar_slot_duration &&
_getFullCalendarOptions: function () { partialRecord.isAllDay != true
var result = this._super.call(this, arguments); ) {
result.slotDuration = const slot_duration = this.env.searchModel.context.calendar_slot_duration;
this.data.context.calendar_slot_duration || const [hours, minutes, seconds] = slot_duration.match(/(\d+):(\d+):(\d+)/);
result.slotDuration || const durationFloat = hours + minutes / 60 + seconds / 3600;
"00:30:00"; partialRecord.end = partialRecord.start.plus({hours: durationFloat});
return result; }
}, return this._super(partialRecord, options);
}); },
}); });