Skip to content

Commit

Permalink
stay: Add default_no_meals on stay.group
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-via committed Oct 20, 2023
1 parent c546ff5 commit 9bc4fa8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion stay/demo/stay_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<record id="group2" model="stay.group">
<field name="name">Hôtellerie familles</field>
<field name="default_refectory_id" ref="refectory_ste_francoise" />
<field name="default_no_meals" eval="True" />
</record>

<record id="room_st_cure_ars" model="stay.room">
Expand Down
9 changes: 8 additions & 1 deletion stay/models/stay.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ class StayStay(models.Model):
readonly=False,
)
no_meals = fields.Boolean(
compute="_compute_refectory_id",
store=True,
precompute=True,
readonly=False,
tracking=True,
help="The stay lines generated from this stay will not have "
"lunchs nor dinners by default.",
"breakfast/lunch/dinner by default.",
)
construction = fields.Boolean()
rooms_display_name = fields.Char(
Expand Down Expand Up @@ -464,6 +468,8 @@ def _compute_refectory_id(self):
elif stay.company_id.default_refectory_id:
refectory_id = stay.company_id.default_refectory_id.id
stay.refectory_id = refectory_id
if stay.group_id:
stay.no_meals = stay.group_id.default_no_meals

def _prepare_stay_line(self, date): # noqa: C901
self.ensure_one()
Expand Down Expand Up @@ -1111,6 +1117,7 @@ class StayGroup(models.Model):
ondelete="restrict",
check_company=True,
)
default_no_meals = fields.Boolean(string="No Meals by Default")

_sql_constraints = [
(
Expand Down
2 changes: 2 additions & 0 deletions stay/views/stay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ So I use the form view below by default -->
<field name="name" />
<field name="company_id" groups="base.group_multi_company" />
<field name="company_id" invisible="1" />
<field name="default_no_meals" />
<field name="default_refectory_id" />
<field name="user_id" />
<field name="notify_user_ids" widget="many2many_tags" />
Expand All @@ -864,6 +865,7 @@ So I use the form view below by default -->
<tree>
<field name="sequence" widget="handle" />
<field name="name" />
<field name="default_no_meals" optional="show" />
<field name="default_refectory_id" optional="show" />
<field name="user_id" />
<field
Expand Down

0 comments on commit 9bc4fa8

Please sign in to comment.