Skip to content

Commit

Permalink
fixup! [IMP] hair_salon
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeschwa committed Sep 6, 2024
1 parent 22a6d3a commit 706f499
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 101 deletions.
10 changes: 5 additions & 5 deletions hair_salon/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
""",
'depends': [
'account_edi_ubl_cii',
"base_automation",
'base_geolocalize',
'hr_hourly_cost',
'knowledge',
Expand All @@ -17,11 +18,14 @@
'sales_team',
'website_appointment',
'theme_orchid',
"base_automation",
"web_studio",
],
'data': [
'data/res_config_settings.xml',
'data/ir_model_fields.xml',
'data/ir_ui_view.xml',
'data/ir_actions_server.xml',
'data/base_automation.xml',
'data/project_task_type.xml',
'data/product_template.xml',
'data/product_attribute.xml',
Expand All @@ -34,11 +38,7 @@
'data/knowledge_article.xml',
'data/knowledge_article_favorite.xml',
'data/mail_message.xml',
'data/ir_model_fields.xml',
'data/appointment_type.xml',
'data/ir_ui_view.xml',
'data/ir_actions_server.xml',
'data/base_automation.xml',
],
'demo': [
'demo/website.xml',
Expand Down
40 changes: 17 additions & 23 deletions hair_salon/data/appointment_type.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo noupdate="1">
<record id="appointment_type_1" model="appointment.type">
<field name="name">Haircut &amp; Brushing</field>
<field name="location_id" ref="base.main_partner"/>
<field name="appointment_tz" model="res.users" eval="obj().env.ref('base.user_admin').tz or 'Europe/Brussels'"/>
<field name="category">recurring</field>
<field name="reminder_ids" eval="[(6, 0, [ref('calendar.alarm_notif_1'), ref('calendar.alarm_mail_1'), ref('appointment_sms.calendar_alarm_data_1h_sms')])]"/>
<field name="canceled_mail_template_id" ref="appointment.appointment_canceled_mail_template"/>
<field name="sequence">11</field>
<field name="work_hours_activated" eval="True"/>
<field name="booked_mail_template_id" ref="appointment.attendee_invitation_mail_template"/>
<field name="avatars_display">show</field>
<field name="event_videocall_source" eval="False"/>
<field name="name">Haircut &amp; Brushing</field>
<field name="sequence">11</field>
<field name="appointment_duration">1.0</field>
<field name="appointment_tz" model="res.users" eval="obj().env.ref('base.user_admin').tz or 'Europe/Brussels'"/>
<field name="staff_user_ids" eval="[(4, ref('base.user_admin'))]"/>
</record>
<record id="appointment_type_2" model="appointment.type">
<field name="name">Haircut &amp; Color &amp; Brushing</field>
<field name="location_id" ref="base.main_partner"/>
<field name="category">recurring</field>
<field name="appointment_duration">3.0</field>
<field name="appointment_tz" model="res.users" eval="obj().env.ref('base.user_admin').tz or 'Europe/Brussels'"/>
<field name="reminder_ids" eval="[(6, 0, [ref('calendar.alarm_notif_1'), ref('calendar.alarm_mail_1'), ref('appointment_sms.calendar_alarm_data_1h_sms')])]"/>
<field name="canceled_mail_template_id" ref="appointment.appointment_canceled_mail_template"/>
<field name="sequence">12</field>
<field name="work_hours_activated" eval="True"/>
<field name="booked_mail_template_id" ref="appointment.attendee_invitation_mail_template"/>
<field name="avatars_display">show</field>
<field name="event_videocall_source" eval="False"/>
<field name="appointment_duration">3.0</field>
<field name="appointment_tz" model="res.users" eval="obj().env.ref('base.user_admin').tz or 'Europe/Brussels'"/>
<field name="x_break" eval="True"/>
<field name="x_break_start_appointment">1.0</field>
<field name="x_break_end_appointment">2.0</field>
<field name="event_videocall_source" eval="False"/>
<field name="name">Haircut &amp; Color &amp; Brushing</field>
<field name="sequence">12</field>
<field name="staff_user_ids" eval="[(4, ref('base.user_admin'))]"/>
</record>
<record id="appointment_type_3" model="appointment.type">
<field name="name">Brushing</field>
<field name="location_id" ref="base.main_partner"/>
<field name="category">recurring</field>
<field name="appointment_duration">0.5</field>
<field name="appointment_tz" model="res.users" eval="obj().env.ref('base.user_admin').tz or 'Europe/Brussels'"/>
<field name="reminder_ids" eval="[(6, 0, [ref('calendar.alarm_notif_1'), ref('calendar.alarm_mail_1'), ref('appointment_sms.calendar_alarm_data_1h_sms')])]"/>
<field name="canceled_mail_template_id" ref="appointment.appointment_canceled_mail_template"/>
<field name="sequence">10</field>
<field name="work_hours_activated" eval="True"/>
<field name="booked_mail_template_id" ref="appointment.attendee_invitation_mail_template"/>
<field name="avatars_display">show</field>
<field name="event_videocall_source" eval="False"/>
<field name="name">Brushing</field>
<field name="appointment_duration">0.5</field>
<field name="appointment_tz" model="res.users" eval="obj().env.ref('base.user_admin').tz or 'Europe/Brussels'"/>
<field name="staff_user_ids" eval="[(4, ref('base.user_admin'))]"/>
</record>
</odoo>
10 changes: 5 additions & 5 deletions hair_salon/data/base_automation.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="break_booking_automation" model="base.automation">
<field name="name">Break Booking Automation</field>
<field name="name">Delete Main Event</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="action_server_ids" eval="[(6, 0, [ref('break_booking_server_action')])]"/>
<field name="trigger">on_unlink</field>
<field name="filter_domain">[("appointment_type_id", "!=", False)]</field>
<field name="filter_domain">[("appointment_type_id", "!=", False),("x_break_start","!=","False"),("x_break_end","!=","False")]</field>
</record>
<record id="delete_subpart_calendar_event" model="base.automation">
<field name="name">Delete Main Appointment</field>
<field name="name">Break Appointment</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="action_server_ids" eval="[(6, 0, [ref('delete_subpart_calendar_event_server_action')])]"/>
<field name="trigger">on_create_or_write</field>
<field name="filter_domain">["&amp;", ("name", "not ilike", "PART 1"), ("name", "not ilike", "PART 2"), ("user_id", "!=", False)]</field>
<field name="filter_domain">[("name", "not ilike", "PART 1"), ("name", "not ilike", "PART 2"), ("user_id", "!=", False)]</field>
</record>
<record id="delete_subpart_main_calendar_event" model="base.automation">
<field name="name">Delete Sub Appointment</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="action_server_ids" eval="[(6, 0, [ref('delete_subpart_main_calendar_event_server_action')])]"/>
<field name="trigger">on_unlink</field>
<field name="filter_domain">["&amp;", ("name", "ilike", "PART 1"), ("user_id", "!=", False)]</field>
<field name="filter_domain">[("name", "ilike", "PART 1"), ("user_id", "!=", False)]</field>
</record>
</odoo>
68 changes: 31 additions & 37 deletions hair_salon/data/ir_actions_server.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="break_booking_server_action" model="ir.actions.server">
<field name="code"><![CDATA[# Fetch related records by field 'x_appointment_part_2'
related_records_1 = env['calendar.event'].search([('x_linked_to', '=', record.id)])
related_records_1.unlink()]]></field>
<field name="code"><![CDATA[
env['calendar.event'].search([('x_parent_id', '=', record.id)]).unlink()
]]></field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="state">code</field>
<field name="name">Execute Code</field>
</record>
<record id="delete_subpart_main_calendar_event_server_action" model="ir.actions.server">
<field name="child_ids" eval="[(6, 0, [ref('break_booking_server_action')])]"/>
<field name="code"><![CDATA[parent_record = env['calendar.event'].search([('id', '=', record.x_linked_to.id)])
if parent_record.x_appointment_part_2.id == record.id:
parent_record.x_appointment_part_2.unlink()
else:
parent_record.x_appointment_part_2.unlink()
parent_record["active"] = False]]></field>
<field name="code"><![CDATA[parent_record = env['calendar.event'].browse(record.x_parent_id)
parent_record.x_appointment_part_2.unlink()
parent_record.unlink()]]></field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="state">code</field>
<field name="name">Execute Code</field>
Expand All @@ -27,35 +24,32 @@ appointment_duration = record.duration
start_time = record.start
end_time = record.stop
if x_break_end > 0 and x_break_start > 0 :
event2_vals = {
'name': "[PART 1]" + record.name ,
'start': start_time,
'stop': start_time + datetime.timedelta(hours=x_break_start),
'allday': record.allday,
'user_id': record.user_id.id,
'x_linked_to': record.id,
'alarm_ids' : [],
'partner_ids': [record.partner_ids[0].id],
'appointment_type_id':record.appointment_type_id.id,
}
part_1 = env['calendar.event'].create(event2_vals)
event2_vals = {
'name': "[PART 1]" + record.name ,
'start': start_time,
'stop': start_time + datetime.timedelta(hours=x_break_start),
'user_id': record.user_id.id,
'x_parent_id': record.id,
'alarm_ids' : [],
'partner_ids': [record.partner_ids[0].id],
'appointment_type_id':record.appointment_type_id.id,
}
part_1 = env['calendar.event'].create(event2_vals)
# Third event - From Break End to Original End
event3_vals = {
'name': "[PART 2]" + record.name,
'start': start_time + datetime.timedelta(hours=x_break_end),
'stop': end_time,
'allday': record.allday,
'user_id': record.user_id.id,
'partner_ids': [record.partner_ids[0].id],
'x_linked_to': record.id,
'alarm_ids' : [],
'appointment_type_id':record.appointment_type_id.id,
}
part_2 = env['calendar.event'].create(event3_vals)
record.write({'user_id': False, 'show_as': "free",'x_appointment_part_1': part_1.id, 'x_appointment_part_2': part_2.id})
# Third event - From Break End to Original End
event3_vals = {
'name': "[PART 2]" + record.name,
'start': start_time + datetime.timedelta(hours=x_break_end),
'stop': end_time,
'user_id': record.user_id.id,
'partner_ids': [record.partner_ids[0].id],
'x_parent_id': record.id,
'alarm_ids' : [],
'appointment_type_id':record.appointment_type_id.id,
}
part_2 = env['calendar.event'].create(event3_vals)
record.write({'user_id': False, 'show_as': "free",'x_appointment_part_1': part_1.id, 'x_appointment_part_2': part_2.id})
Expand Down
19 changes: 9 additions & 10 deletions hair_salon/data/ir_model_fields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
<field name="field_description">Break End</field>
<field name="model_id" ref="appointment.model_appointment_type"/>
<field name="name">x_break_end_appointment</field>
<field name="on_delete" eval="False"/>
</record>
<record id="x_break" model="ir.model.fields">
<field name="ttype">boolean</field>
<field name="field_description">Break</field>
<field name="model_id" ref="appointment.model_appointment_type"/>
<field name="help">Insert a free time in your booking.</field>
<field name="name">x_break</field>
</record>
<record id="x_break_start_appointment_model" model="ir.model.fields">
<field name="ttype">float</field>
<field name="field_description">Break Start</field>
<field name="model_id" ref="appointment.model_appointment_type"/>
<field name="name">x_break_start_appointment</field>
<field name="on_delete" eval="False"/>
</record>
<record id="x_linked_to" model="ir.model.fields">
<record id="x_parent_id" model="ir.model.fields">
<field name="ttype">many2one</field>
<field name="field_description">Linked to</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="name">x_linked_to</field>
<field name="name">x_parent_id</field>
<field name="relation">calendar.event</field>
</record>
<record id="x_appointment_part_2" model="ir.model.fields">
Expand All @@ -40,19 +45,13 @@
<field name="field_description">Break End</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="name">x_break_end</field>
<field name="on_delete" eval="False"/>
<field name="readonly" eval="True"/>
<field name="store" eval="False"/>
<field name="related">appointment_type_id.x_break_end_appointment</field>
</record>
<record id="calendar_x_break_start" model="ir.model.fields">
<field name="ttype">float</field>
<field name="field_description">Break Start</field>
<field name="model_id" ref="calendar.model_calendar_event"/>
<field name="name">x_break_start</field>
<field name="on_delete" eval="False"/>
<field name="readonly" eval="True"/>
<field name="store" eval="False"/>
<field name="related">appointment_type_id.x_break_start_appointment</field>
</record>
</odoo>
28 changes: 11 additions & 17 deletions hair_salon/data/ir_ui_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
</record>
<record id="appointment_type_customization" model="ir.ui.view">
<field name="arch" type="xml">
<data>
<xpath expr="//form[1]/sheet[1]/group[1]/group[@name='left_details']/div[1]" position="after">
<field name="x_break_start_appointment" string="Break Start" options="{&quot;human_readable&quot;:false}" widget="float_time"/>
<field name="x_break_end_appointment" options="{&quot;human_readable&quot;:false}" widget="float_time"/>
<field name="x_break" widget="boolean"/>
<field name="x_break_start_appointment" widget="float_time" invisible="not x_break"/>
<field name="x_break_end_appointment" widget="float_time" invisible="not x_break"/>
</xpath>
</data>
</field>
<field name="active" eval="True"/>
<field name="inherit_id" ref="appointment.appointment_type_view_form"/>
Expand All @@ -36,34 +35,29 @@
<field name="inherit_id" ref="appointment.calendar_event_view_form_gantt_booking"/>
<field name="active" eval="True"/>
<field name="arch" type="xml">
<data>
<xpath expr="//form/sheet/group/group" position="after">
<div class="o_form_group o_inline">
<label for="x_linked_to" invisible="not x_linked_to" string="Linked to:" class="oe_inline me-2"/>
<field name="x_linked_to" invisible="not x_linked_to" options="{'no_create': True}" class="oe_inline"/>
<div class="o_form_group o_inline" invisible="not x_parent_id">
<label for="x_parent_id" string="Linked to:" class="oe_inline me-2"/>
<field name="x_parent_id" options="{'no_create': True}" class="oe_inline"/>
</div>
</xpath>
</data>
</field>
</record>
</odoo>
<record id="calendar_event_parent_customization" model="ir.ui.view">
<field name="arch" type="xml">
<data>
<xpath expr="//form[1]/sheet[1]/group[1]/group[1]/div[1]" position="after">
<field name="x_break_start" invisible="x_linked_to" widget="float_time"/>
<field name="x_break_end" invisible="x_linked_to" widget="float_time"/>
<field name="x_break_start" invisible="x_parent_id" widget="float_time"/>
<field name="x_break_end" invisible="x_parent_id" widget="float_time"/>
</xpath>
<xpath expr="//form[1]/sheet[1]/group[1]/group[2]/div[2]" position="after">
<field name="x_appointment_part_2" string="Part 1" invisible="not x_appointment_part_2"/>
<field name="x_appointment_part_2" invisible="not x_appointment_part_2"/>
<field name="x_linked_to" invisible="not x_linked_to"/>
<xpath expr="//field[@name='location']" position="before">
<field name="x_appointment_part_2" string="Part 2" invisible="not x_appointment_part_2"/>
<field name="x_parent_id" invisible="not x_parent_id"/>
</xpath>
<xpath expr="//field[@name='partner_ids']" position="attributes">
<attribute name="force_save">0</attribute>
<attribute name="readonly">False</attribute>
</xpath>
</data>
</field>
<field name="active" eval="True"/>
<field name="inherit_id" ref="calendar.view_calendar_event_form"/>
Expand Down
3 changes: 0 additions & 3 deletions hair_salon/demo/hr_employee.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<field name="image_1920" type="base64" file="hair_salon/static/src/binary/hr_employee/2-image_1920"/>
<field name="user_id" ref="res_users_6"/>
<field name="company_id" ref="base.main_company"/>
<field name="tz">Europe/Brussels</field>
</record>
<record id="hr_employee_3" model="hr.employee">
<field name="name">Grace Turner</field>
Expand All @@ -20,7 +19,6 @@
<field name="image_1920" type="base64" file="hair_salon/static/src/binary/hr_employee/3-image_1920"/>
<field name="user_id" ref="res_users_7"/>
<field name="company_id" ref="base.main_company"/>
<field name="tz">Europe/Brussels</field>
</record>
<record id="hr_employee_4" model="hr.employee">
<field name="name">Lily Joe</field>
Expand All @@ -31,6 +29,5 @@
<field name="image_1920" type="base64" file="hair_salon/static/src/binary/hr_employee/4-image_1920"/>
<field name="user_id" ref="res_users_8"/>
<field name="company_id" ref="base.main_company"/>
<field name="tz">Europe/Brussels</field>
</record>
</odoo>
1 change: 0 additions & 1 deletion hair_salon/demo/website_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<field name="name">Header Call To Action</field>
<field name="type">qweb</field>
<field name="key">hair_salon.header_call_to_action</field>
<field name="active" eval="True"/>
<field name="arch" type="xml">
<xpath expr="." position="inside">
<li t-attf-class="#{_item_class}">
Expand Down

0 comments on commit 706f499

Please sign in to comment.