Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces 3 settings: - (De)activate scheduled actions - Set list view as default view for albums and artists - Set LastFM info fetching manual
- Loading branch information
1 parent
70d4288
commit d572bcc
Showing
7 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class OomusicConfigSettings(models.TransientModel): | ||
_name = 'oomusic.config.settings' | ||
_inherit = 'res.config.settings' | ||
|
||
cron = fields.Selection([ | ||
('active', 'Active'), | ||
('inactive', 'Inactive'), | ||
], string='Scheduled Actions', help='Activate automatic folder scan and image cache mechanism') | ||
view = fields.Selection([ | ||
('kanban', 'Kanban, with thumbnails'), | ||
('tree', 'List, without thumbnails'), | ||
], string='Default Views') | ||
fm_info = fields.Selection([ | ||
('auto', 'Fetched automatically'), | ||
('manual', 'Fetched manually'), | ||
], string='LastFM Info') | ||
|
||
@api.model | ||
def get_values(self): | ||
res = super(OomusicConfigSettings, self).get_values() | ||
cron = ( | ||
self.env.ref('oomusic.oomusic_scan_folder') + | ||
self.env.ref('oomusic.oomusic_build_artists_image_cache') + | ||
self.env.ref('oomusic.oomusic_build_image_cache') + | ||
self.env.ref('oomusic.oomusic_build_lastfm_cache') | ||
).mapped('active') | ||
view = ( | ||
self.env.ref('oomusic.action_album') + | ||
self.env.ref('oomusic.action_artist') | ||
).mapped('view_mode') | ||
res['cron'] = 'active' if all([c for c in cron]) else 'inactive' | ||
res['view'] = 'tree' if all([v.split(',')[0] == 'tree' for v in view]) else 'kanban' | ||
res['fm_info'] = self.env['ir.config_parameter'].sudo().get_param('oomusic.fm_info', 'auto') | ||
return res | ||
|
||
def set_values(self): | ||
super(OomusicConfigSettings, self).set_values() | ||
# Activate/deactive ir.cron | ||
( | ||
self.env.ref('oomusic.oomusic_scan_folder') + | ||
self.env.ref('oomusic.oomusic_build_artists_image_cache') + | ||
self.env.ref('oomusic.oomusic_build_image_cache') + | ||
self.env.ref('oomusic.oomusic_build_lastfm_cache') | ||
).write({'active': bool(self.cron == 'active')}) | ||
# Set view order | ||
if self.view == 'tree': | ||
view_mode_album = 'tree,kanban,form,graph,pivot' | ||
view_mode_artist = 'tree,kanban,form' | ||
else: | ||
view_mode_album = 'kanban,tree,form,graph,pivot' | ||
view_mode_artist = 'kanban,tree,form' | ||
self.env.ref('oomusic.action_album').write({'view_mode': view_mode_album}) | ||
self.env.ref('oomusic.action_artist').write({'view_mode': view_mode_artist}) | ||
# Set LastFM Info | ||
self.env['ir.config_parameter'].sudo().set_param('oomusic.fm_info', self.fm_info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data> | ||
<record id="oomusic_config_settings_view_form" model="ir.ui.view"> | ||
<field name="name">OOMusic Settings</field> | ||
<field name="model">oomusic.config.settings</field> | ||
<field name="arch" type="xml"> | ||
<form string="Configure OOMusic" class="oe_form_configuration"> | ||
<header> | ||
<button string="Apply" type="object" name="execute" class="oe_highlight"/> | ||
<button string="Cancel" type="object" name="cancel" class="oe_link" special="cancel"/> | ||
</header> | ||
<group string="Features"> | ||
<field name="cron" widget="radio"/> | ||
<field name="view" widget="radio"/> | ||
<field name="fm_info" widget="radio"/> | ||
</group> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_oomusic_config_settings" model="ir.actions.act_window"> | ||
<field name="name">Settings</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">oomusic.config.settings</field> | ||
<field name="view_mode">form</field> | ||
<field name="target">inline</field> | ||
</record> | ||
|
||
<menuitem | ||
id="menu_stock_general_settings" | ||
name="Settings" | ||
parent="menu_oomusic_config" | ||
sequence="0" | ||
action="action_oomusic_config_settings" | ||
groups="base.group_system"/> | ||
</data> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters