[MIG] web_calendar_slot_duration: Migration to 17.0

pull/3084/head
Christopher Rogos 2024-03-28 13:39:41 +00:00
parent f868b1923c
commit ee02fc15fc
12 changed files with 49 additions and 40 deletions

View File

@ -7,7 +7,7 @@ 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:1274b3dddbcd34bf1401a1f208b67af94f47a47121fa32b120acbc37c84a63be !! source digest: sha256:2be0b00f67ed141f98a951795ae0ba21a2912b90c42a00ed2ce136cee2def017
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
@ -43,8 +43,8 @@ Configuration
This documentation is for developers. This documentation is for developers.
If you want to configure your calendar view's snap duration, make sure If you want to configure your calendar view's snap duration, make sure
that you action includes a context similar to this (example is the that your window action includes a context similar to this (example is
default value): the default value):
:: ::
@ -53,12 +53,22 @@ default value):
It can be added in actions defined on python or as It can be added in actions defined on python or as
``ir.actions.act_window`` records. ``ir.actions.act_window`` records.
|edit action settings|
|result|
.. |edit action settings| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_calendar_slot_duration/static/description/edit_action.png
.. |result| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_calendar_slot_duration/static/description/calendar_result.png
Usage Usage
===== =====
To use this module, you need to install some other addon that uses it, To use this module, you need to install some other addon that uses it,
as it doesn't provide any end-user functionality. as it doesn't provide any end-user functionality.
As demo data, this module modifies the "Scheduled Actions" calendar to
have slots of 10 minutes as feature demonstration.
Known issues / Roadmap Known issues / Roadmap
====================== ======================

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": "16.0.1.0.1", "version": "17.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",
@ -18,5 +18,6 @@
"web_calendar_slot_duration/static/src/js/calendar_model.esm.js", "web_calendar_slot_duration/static/src/js/calendar_model.esm.js",
] ]
}, },
"data": ["demo/scheduled_actions.xml"],
"depends": ["web"], "depends": ["web"],
} }

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="base.ir_cron_act" model="ir.actions.act_window">
<field
name="context"
>{'search_default_all': 1, "calendar_slot_duration": "00:10:00"}</field>
</record>
</odoo>

View File

@ -1,14 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

View File

@ -3,7 +3,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 16.0\n" "Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"

View File

@ -1,10 +1,14 @@
This documentation is for developers. This documentation is for developers.
If you want to configure your calendar view's snap duration, make sure If you want to configure your calendar view's snap duration, make sure
that you action includes a context similar to this (example is the that your window action includes a context similar to this (example is the
default value): default value):
{"calendar_slot_duration": "00:30:00"} {"calendar_slot_duration": "00:30:00"}
It can be added in actions defined on python or as It can be added in actions defined on python or as
`ir.actions.act_window` records. `ir.actions.act_window` records.
![edit action settings](../static/description/edit_action.png)
![result](../static/description/calendar_result.png)

View File

@ -1,2 +1,4 @@
To use this module, you need to install some other addon that uses it, To use this module, you need to install some other addon that uses it,
as it doesn't provide any end-user functionality. as it doesn't provide any end-user functionality.
As demo data, this module modifies the "Scheduled Actions" calendar to have slots of 10 minutes as feature demonstration.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
@ -367,7 +366,7 @@ 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:1274b3dddbcd34bf1401a1f208b67af94f47a47121fa32b120acbc37c84a63be !! source digest: sha256:2be0b00f67ed141f98a951795ae0ba21a2912b90c42a00ed2ce136cee2def017
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/17.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 image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/web/tree/17.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 image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=17.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 <p>This module extends the functionality of backend calendars to support
@ -392,18 +391,22 @@ regarding event duration and snapping.</p>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1> <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>This documentation is for developers.</p> <p>This documentation is for developers.</p>
<p>If you want to configure your calendar views snap duration, make sure <p>If you want to configure your calendar views snap duration, make sure
that you action includes a context similar to this (example is the that your window action includes a context similar to this (example is
default value):</p> the default value):</p>
<pre class="literal-block"> <pre class="literal-block">
{&quot;calendar_slot_duration&quot;: &quot;00:30:00&quot;} {&quot;calendar_slot_duration&quot;: &quot;00:30:00&quot;}
</pre> </pre>
<p>It can be added in actions defined on python or as <p>It can be added in actions defined on python or as
<tt class="docutils literal">ir.actions.act_window</tt> records.</p> <tt class="docutils literal">ir.actions.act_window</tt> records.</p>
<p><img alt="edit action settings" src="https://raw.githubusercontent.com/OCA/web/17.0/web_calendar_slot_duration/static/description/edit_action.png" /></p>
<p><img alt="result" src="https://raw.githubusercontent.com/OCA/web/17.0/web_calendar_slot_duration/static/description/calendar_result.png" /></p>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1> <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>To use this module, you need to install some other addon that uses it, <p>To use this module, you need to install some other addon that uses it,
as it doesnt provide any end-user functionality.</p> as it doesnt provide any end-user functionality.</p>
<p>As demo data, this module modifies the “Scheduled Actions” calendar to
have slots of 10 minutes as feature demonstration.</p>
</div> </div>
<div class="section" id="known-issues-roadmap"> <div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1> <h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>

View File

@ -5,17 +5,12 @@
import {CalendarCommonRenderer} from "@web/views/calendar/calendar_common/calendar_common_renderer"; import {CalendarCommonRenderer} from "@web/views/calendar/calendar_common/calendar_common_renderer";
import {patch} from "@web/core/utils/patch"; import {patch} from "@web/core/utils/patch";
patch( patch(CalendarCommonRenderer.prototype, {
CalendarCommonRenderer.prototype,
"WebCalendarSlotDurationCalendarCommonRenderer",
{
get options() { get options() {
const options = this._super(...arguments); const options = super.options;
if (this.env.searchModel.context.calendar_slot_duration) { if (this.env.searchModel.context.calendar_slot_duration) {
options.slotDuration = options.slotDuration = this.env.searchModel.context.calendar_slot_duration;
this.env.searchModel.context.calendar_slot_duration;
} }
return options; return options;
}, },
} });
);

View File

@ -6,7 +6,7 @@
import {CalendarModel} from "@web/views/calendar/calendar_model"; import {CalendarModel} from "@web/views/calendar/calendar_model";
import {patch} from "@web/core/utils/patch"; import {patch} from "@web/core/utils/patch";
patch(CalendarModel.prototype, "WebCalendarSlotDurationCalendarModel", { patch(CalendarModel.prototype, {
buildRawRecord(partialRecord, options = {}) { buildRawRecord(partialRecord, options = {}) {
if ( if (
!partialRecord.end && !partialRecord.end &&
@ -20,6 +20,6 @@ patch(CalendarModel.prototype, "WebCalendarSlotDurationCalendarModel", {
const durationFloat = hours + minutes / 60 + seconds / 3600; const durationFloat = hours + minutes / 60 + seconds / 3600;
partialRecord.end = partialRecord.start.plus({hours: durationFloat}); partialRecord.end = partialRecord.start.plus({hours: durationFloat});
} }
return this._super(partialRecord, options); return super.buildRawRecord(partialRecord, options);
}, },
}); });