[CLN] global : full pre-commit & ruff lint
This commit is contained in:
@@ -1 +1 @@
|
||||
from . import models
|
||||
from . import models
|
||||
|
@@ -7,10 +7,10 @@
|
||||
"version": "16.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Elabore",
|
||||
"website": "https://www.elabore.coop",
|
||||
"website": "https://github.com/elabore-coop/event-tools",
|
||||
"category": "",
|
||||
'summary': 'Link event tracks locations to calendar event',
|
||||
'description': """
|
||||
"summary": "Link event tracks locations to calendar event",
|
||||
"description": """
|
||||
Link event tracks locations to calendar event
|
||||
----------------------------------------------------
|
||||
* Add Partner field on event track location
|
||||
@@ -20,10 +20,7 @@ Link event tracks locations to calendar event
|
||||
|
||||
|
||||
""",
|
||||
"depends": ["website_event_track","calendar"],
|
||||
"data": [
|
||||
'views/event_track_location_views.xml',
|
||||
'views/event_track_views.xml'
|
||||
],
|
||||
"depends": ["website_event_track", "calendar"],
|
||||
"data": ["views/event_track_location_views.xml", "views/event_track_views.xml"],
|
||||
"installable": True,
|
||||
}
|
||||
|
@@ -1,2 +1,2 @@
|
||||
from . import event_track
|
||||
from . import event_track_location
|
||||
from . import event_track_location
|
||||
|
@@ -1,17 +1,19 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models, api, Command, _
|
||||
from datetime import timedelta
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools import format_date
|
||||
|
||||
|
||||
class EventTrack(models.Model):
|
||||
_inherit = "event.track"
|
||||
|
||||
|
||||
location_already_in_use = fields.Boolean('Location already in use', compute='_compute_location_already_in_use')
|
||||
location_already_in_use_message = fields.Text(compute='_compute_location_already_in_use')
|
||||
location_already_in_use = fields.Boolean(
|
||||
"Location already in use", compute="_compute_location_already_in_use"
|
||||
)
|
||||
location_already_in_use_message = fields.Text(
|
||||
compute="_compute_location_already_in_use"
|
||||
)
|
||||
|
||||
@api.depends('date', 'duration', 'location_id')
|
||||
@api.depends("date", "duration", "location_id")
|
||||
def _compute_location_already_in_use(self):
|
||||
for track in self:
|
||||
location_already_in_use = False
|
||||
@@ -21,40 +23,58 @@ class EventTrack(models.Model):
|
||||
|
||||
for calendar_event in track.calendar_event_ids:
|
||||
if track.location_id and calendar_event.start:
|
||||
# search if other calendar event exists for same day on same location
|
||||
search_other_calendar_events = [
|
||||
("event_track_id.location_id", "=", track.location_id.id),
|
||||
("start", ">=", calendar_event.start.replace(hour=0, minute=0)),
|
||||
(
|
||||
"start",
|
||||
"<=",
|
||||
calendar_event.start.replace(hour=23, minute=59),
|
||||
),
|
||||
]
|
||||
|
||||
#search if other calendar event exists for same day on same location
|
||||
search_other_calendar_events = [('event_track_id.location_id','=',track.location_id.id),('start','>=',calendar_event.start.replace(hour=0,minute=0)),('start','<=',calendar_event.start.replace(hour=23,minute=59))]
|
||||
|
||||
#search only on other event tracks
|
||||
# search only on other event tracks
|
||||
if track.id or track.id.origin:
|
||||
search_other_calendar_events.append(('event_track_id','!=',track.id or track.id.origin))
|
||||
search_other_calendar_events.append(
|
||||
("event_track_id", "!=", track.id or track.id.origin)
|
||||
)
|
||||
|
||||
#search calendar events not already founded
|
||||
# search calendar events not already founded
|
||||
if already_found_other_calendar_event_ids:
|
||||
search_other_calendar_events.append(('id','not in',already_found_other_calendar_event_ids))
|
||||
|
||||
other_calendar_events = self.env["calendar.event"].search(search_other_calendar_events)
|
||||
already_found_other_calendar_event_ids.extend(other_calendar_events.ids)
|
||||
search_other_calendar_events.append(
|
||||
("id", "not in", already_found_other_calendar_event_ids)
|
||||
)
|
||||
|
||||
other_calendar_events = self.env["calendar.event"].search(
|
||||
search_other_calendar_events
|
||||
)
|
||||
already_found_other_calendar_event_ids.extend(
|
||||
other_calendar_events.ids
|
||||
)
|
||||
|
||||
if other_calendar_events:
|
||||
location_already_in_use = True
|
||||
location_already_in_use = True
|
||||
for other_calendar_event in other_calendar_events:
|
||||
location_already_in_use_message += other_calendar_event.event_track_id.event_id.name+" - "+\
|
||||
other_calendar_event.event_track_id.name+\
|
||||
" ("+format_date(self.env, other_calendar_event.start)+")"+"\n"
|
||||
location_already_in_use_message += (
|
||||
other_calendar_event.event_track_id.event_id.name
|
||||
+ " - "
|
||||
+ other_calendar_event.event_track_id.name
|
||||
+ " ("
|
||||
+ format_date(self.env, other_calendar_event.start)
|
||||
+ ")"
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
track.location_already_in_use = location_already_in_use
|
||||
track.location_already_in_use_message = location_already_in_use_message
|
||||
|
||||
|
||||
|
||||
def get_calendar_event_partner_value(self):
|
||||
"""Add event track location partner to list of partner ids
|
||||
"""
|
||||
Add event track location partner to list of partner ids.
|
||||
"""
|
||||
|
||||
res = super(EventTrack, self).get_calendar_event_partner_value()
|
||||
res = super().get_calendar_event_partner_value()
|
||||
if self.location_id and self.location_id.partner_id:
|
||||
res.append(self.location_id.partner_id.id)
|
||||
return res
|
||||
|
||||
|
@@ -1,17 +1,22 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models, api
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class EventTrackLocation(models.Model):
|
||||
_inherit = 'event.track.location'
|
||||
_inherit = "event.track.location"
|
||||
|
||||
partner_id = fields.Many2one(
|
||||
"res.partner", "Address", domain="[('is_company','=',True)]"
|
||||
)
|
||||
|
||||
partner_id = fields.Many2one('res.partner', 'Address', domain="[('is_company','=',True)]")
|
||||
|
||||
def write(self, vals):
|
||||
"""update calendar events related to event tracks if partner change
|
||||
"""
|
||||
res = super(EventTrackLocation, self).write(vals)
|
||||
if 'partner_id' in vals:
|
||||
event_tracks = self.env['event.track'].search([('location_id','in',self.ids)])
|
||||
Update calendar events related to event tracks if partner change.
|
||||
"""
|
||||
res = super().write(vals)
|
||||
if "partner_id" in vals:
|
||||
event_tracks = self.env["event.track"].search(
|
||||
[("location_id", "in", self.ids)]
|
||||
)
|
||||
event_tracks.sync_calendar_event()
|
||||
return res
|
||||
return res
|
||||
|
@@ -1,9 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- EVENTS/CONFIGURATION/EVENT locations -->
|
||||
<record model="ir.ui.view" id="view_event_location_form_inherit_event_track_location_calendar">
|
||||
<field name="name">Event Locations inherit for event track location calendar</field>
|
||||
<record
|
||||
model="ir.ui.view"
|
||||
id="view_event_location_form_inherit_event_track_location_calendar"
|
||||
>
|
||||
<field
|
||||
name="name"
|
||||
>Event Locations inherit for event track location calendar</field>
|
||||
<field name="model">event.track.location</field>
|
||||
<field name="inherit_id" ref="website_event_track.view_event_location_form" />
|
||||
<field name="arch" type="xml">
|
||||
@@ -13,7 +18,10 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_event_location_tree_inherit_event_track_location_calendar">
|
||||
<record
|
||||
model="ir.ui.view"
|
||||
id="view_event_location_tree_inherit_event_track_location_calendar"
|
||||
>
|
||||
<field name="name">Event Location</field>
|
||||
<field name="model">event.track.location</field>
|
||||
<field name="inherit_id" ref="website_event_track.view_event_location_tree" />
|
||||
|
@@ -1,16 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
<record model="ir.ui.view" id="view_event_track_form_inherit_event_track_location_calendar">
|
||||
<field name="name">event.track.form inherit for event track location calendar</field>
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<record
|
||||
model="ir.ui.view"
|
||||
id="view_event_track_form_inherit_event_track_location_calendar"
|
||||
>
|
||||
<field
|
||||
name="name"
|
||||
>event.track.form inherit for event track location calendar</field>
|
||||
<field name="model">event.track</field>
|
||||
<field name="inherit_id" ref="website_event_track.view_event_track_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header" position="after">
|
||||
<field name="location_already_in_use" invisible="1" />
|
||||
<div attrs="{'invisible':[('location_already_in_use','=',False)]}" class="alert alert-warning mb-0" role="alert">
|
||||
<strong>Location already in use for this date !</strong><field name="location_already_in_use_message" />
|
||||
<field name="location_already_in_use" invisible="1" />
|
||||
<div
|
||||
attrs="{'invisible':[('location_already_in_use','=',False)]}"
|
||||
class="alert alert-warning mb-0"
|
||||
role="alert"
|
||||
>
|
||||
<strong>Location already in use for this date !</strong><field
|
||||
name="location_already_in_use_message"
|
||||
/>
|
||||
</div>
|
||||
</xpath>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
Reference in New Issue
Block a user