Browse Source

[IMP] constraints and views

14.0
Rémi FRANÇOIS 4 years ago
parent
commit
056a8fbe39
  1. 8
      pos_restaurant_table_booking/models/restaurant_booking.py
  2. 15
      pos_restaurant_table_booking/views/res_config_settings.xml
  3. 4
      pos_restaurant_table_booking/views/restaurant_booking.xml
  4. 14
      pos_restaurant_table_booking/views/restaurant_floor.xml
  5. 21
      pos_restaurant_table_booking/views/restaurant_table_booking.xml

8
pos_restaurant_table_booking/models/restaurant_booking.py

@ -54,6 +54,12 @@ class RestaurantBooking(models.Model):
table_booking_ids = fields.One2many(comodel_name="restaurant.table_booking", inverse_name="booking_id",
string="Tables bookings", readonly=True)
_sql_constraints = [
('start_time_check', 'CHECK(time_start >= 0 AND time_start <= 24)', "The start time must be between 0 and 24.")
('stop_time_check', 'CHECK(time_stop >= 0 AND time_stop <= 24)', "The stop time must be between 0 and 24.")
('times_order_check', 'CHECK(time_start < time_stop)', "The start time must be lower than the stop time.")
]
@api.depends('time_start', 'duration')
def _get_time_stop(self):
for booking in self:
@ -114,6 +120,8 @@ class RestaurantBooking(models.Model):
else:
booking.available_table_ids = [(5, 0, 0)]
# CRUD
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:

15
pos_restaurant_table_booking/views/res_config_settings.xml

@ -13,18 +13,15 @@
<div class="o_setting_right_pane">
<div>
<label for="default_duration"/>
<!-- <div class="text-muted">
Default sales tax for products
</div> -->
<div class="content-group mt16">
<field name="default_duration" colspan="4" nolabel="1" widget="float_time" class="oe_inline"/>
<div class="content-group mt16">
<field name="default_duration" colspan="4" nolabel="1" widget="float_time" class="oe_inline"/>
</div>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</xpath>
</field>
</record>
</odoo>

4
pos_restaurant_table_booking/views/restaurant_booking.xml

@ -34,8 +34,8 @@
attrs="{'invisible': ['|',('datetime_start','=',False),('datetime_stop','=',False)]}"/>
<field name="table_capacity" invisible="1"/>
<field name="table_capacity_ok" invisible="1"/>
<div colspan="2" class="alert alert-warning" role="alert" attrs="{'invisible':[('table_capacity_ok','=',True)]}">
<i icon="fa-exclamation-triangle"/>
<div colspan="2" class="text-muted mt16" attrs="{'invisible':[('table_capacity_ok','=',True)]}">
<i icon="fa-exclamation-triangle" class="text-warning"/>
<span class="ml8">The total seats of selected tables is lower than the people count.</span>
</div>
</group>

14
pos_restaurant_table_booking/views/restaurant_floor.xml

@ -12,18 +12,4 @@
</field>
</record>
<!-- <record id="restaurant_floor_tree" model="ir.ui.view">
<field name="name">Booking restaurant.floor tree</field>
<field name="model">restaurant.floor</field>
<field name="arch" type="xml">
</field>
</record> -->
<!-- <record id="restaurant_floor_search" model="ir.ui.view">
<field name="name">Booking restaurant.floor search</field>
<field name="model">restaurant.floor</field>
<field name="arch" type="xml">
</field>
</record> -->
</odoo>

21
pos_restaurant_table_booking/views/restaurant_table_booking.xml

@ -74,6 +74,17 @@
<field name="name"/>
<field name="table_id"/>
<field name="datetime_start"/>
<group expand="0" string="Filters">
<filter name="this_week" string="This week" domain="[('datetime_start','&gt;=',(context_today() + relativedelta(weekday=0)).strftime('%Y-%m-%d 00:00:00')),('date','&lt;=',(context_today() + relativedelta(weekday=6)).strftime('%Y-%m-%d 23:59:59'))]"/>
<filter name="next_week" string="Next week" domain="[('datetime_start','&gt;=',(context_today() + relativedelta(weeks=1, weekday=0)).strftime('%Y-%m-%d 00:00:00')),('date','&lt;=',(context_today() + relativedelta(weeks=1, weekday=6)).strftime('%Y-%m-%d 23:59:59'))]"/>
<separator/>
<filter name="upcoming" string="Upcoming" domain="[('datetime_start','&gt;=',context_today().strftime('%Y-%m-%d 00:00:00'))]"/>
</group>
<group expand="0" string="Group By">
<filter name="by_booking" string="Booking" domain="[]" context="{'group_by': 'booking_id'}"/>
<filter name="by_table" string="Table" domain="[]" context="{'group_by': 'table_id'}"/>
<filter name="by_date" string="Date" domain="[]" context="{'group_by': 'datetime_start:day'}"/>
</group>
</search>
</field>
</record>
@ -82,14 +93,14 @@
<field name="name">Tables bookings</field>
<field name="res_model">restaurant.table_booking</field>
<field name="view_mode">gantt,form</field>
<!-- <field name="context">{'search_default_today':1}</field> -->
<!-- <field name="help" type="html">
<field name="context">{'search_default_upcoming':1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Prendre une nouvelle réservation.
Schedule a new booking.
</p><p>
Une réservation compreend un nom, une date, des horaires et une ou plusieurs tables.
To book, you must provide a name, a date, start and stop hours, the people count and one or more tables.
</p>
</field> -->
</field>
</record>
<menuitem

Loading…
Cancel
Save