Initial commit: OCA Mrp packages (117 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:05 +02:00
commit 277e84fd7a
4403 changed files with 395154 additions and 0 deletions

View file

@ -0,0 +1,2 @@
from . import event_configurator
from . import event_edit_registration

View file

@ -0,0 +1,27 @@
# Copyright 2021 Tecnativa - Carlos Roca
# Copyright 2021 Moka Tourisme (https://www.mokatourisme.fr).
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class EventConfigurator(models.TransientModel):
_inherit = "event.event.configurator"
event_use_sessions = fields.Boolean(related="event_id.use_sessions")
event_session_id = fields.Many2one(
string="Session",
comodel_name="event.session",
domain="[('event_id', '=', event_id)]",
)
@api.onchange("event_id")
def _onchange_event_id_session(self):
# Automatically set the session, if there's only one available
# and also to clear event_session_id if it's inconsistent with the event
event = self.event_id
if event.session_count == 1:
self.event_session_id = event.session_ids[0]
elif not event.use_sessions or event != self.event_session_id.event_id:
self.event_session_id = False

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2017-19 Tecnativa - David Vidal
Copyright 2021 Moka Tourisme (https://www.mokatourisme.fr)
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="event_configurator_view_form" model="ir.ui.view">
<field name="model">event.event.configurator</field>
<field name="inherit_id" ref="event_sale.event_configurator_view_form" />
<field name="arch" type="xml">
<field name="event_id" position="after">
<field name="event_use_sessions" invisible="1" />
<field
name="event_session_id"
domain="[
('event_id', '=', event_id),
('date_end', '&gt;=', time.strftime('%Y-%m-%d 00:00:00')),
]"
attrs="{
'invisible': [('event_use_sessions', '=', False)],
'required': [('event_use_sessions', '=', True)],
}"
options="{'no_open': True, 'no_create': True}"
/>
</field>
</field>
</record>
</odoo>

View file

@ -0,0 +1,38 @@
# Copyright 2017-19 Tecnativa - David Vidal
# Copyright 2021 Moka Tourisme (https://www.mokatourisme.fr).
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class RegistrationEditor(models.TransientModel):
_inherit = "registration.editor"
@api.model
def default_get(self, fields):
# OVERRIDE to fill in the session_id for existing and new registration vals
# If the registration already exists, we get it from the registration itself
# If the registration doesn't exist, we get it from the sale order line
res = super().default_get(fields)
for __, __, attendee_vals in res["event_registration_ids"]:
registration_id = attendee_vals.get("registration_id")
if registration_id:
registration = self.env["event.registration"].browse(registration_id)
attendee_vals["session_id"] = registration.session_id.id
else:
sale_order_line_id = attendee_vals.get("sale_order_line_id")
sale_order_line = self.env["sale.order.line"].browse(sale_order_line_id)
attendee_vals["session_id"] = sale_order_line.event_session_id.id
return res
class RegistrationEditorLine(models.TransientModel):
_inherit = "registration.editor.line"
session_id = fields.Many2one(comodel_name="event.session", string="Session")
def get_registration_data(self):
res = super().get_registration_data()
res["session_id"] = self.sale_order_line_id.event_session_id.id
return res

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2017-19 Tecnativa - David Vidal
Copyright 2021 Moka Tourisme (https://www.mokatourisme.fr)
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_event_inherit_registration_editor_form" model="ir.ui.view">
<field name="model">registration.editor</field>
<field name="inherit_id" ref="event_sale.view_event_registration_editor_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='event_registration_ids']//field[@name='event_id']"
position="after"
>
<field
name="session_id"
domain="[('event_id', '=', event_id)]"
readonly="1"
force_save="1"
/>
</xpath>
</field>
</record>
</odoo>