Skip to content

Commit

Permalink
Merge branch '17.0_tms' into 17.0_tms_sale
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagordz committed Aug 15, 2024
2 parents 26a0430 + 2da7170 commit 58363e1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 64 deletions.
3 changes: 1 addition & 2 deletions tms/data/tms_stage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
<field name="sequence">30</field>
<field name="fold">True</field>
<field name="stage_type">order</field>
<field name="is_closed">True</field>
<field name="is_default">True</field>
<field name="is_completed">True</field>
<field name="custom_color">#1C2833</field>
</record>
<record id="tms_stage_order_cancelled" model="tms.stage">
<field name="name">Cancelled</field>
<field name="sequence">40</field>
<field name="fold">True</field>
<field name="stage_type">order</field>
<field name="is_closed">True</field>
<field name="is_default">True</field>
<field name="custom_color">#1C2833</field>
</record>
Expand Down
4 changes: 2 additions & 2 deletions tms/models/tms_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def _default_team_ids(self):
help="This stage is folded in the kanban view when "
"there are no record in that stage to display.",
)
is_closed = fields.Boolean(
"Is a close stage", help="Services in this stage are considered " "as closed."
is_completed = fields.Boolean(
help="Defines how this stage is evaluated as completed stage",
)
is_default = fields.Boolean(readonly=True, default=False)
custom_color = fields.Char(
Expand Down
42 changes: 18 additions & 24 deletions tms/models/tms_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def _default_stages(self):

def _compute_order_count(self):
order_data = self.env["tms.order"].read_group(
[("team_id", "in", self.ids), ("stage_id.is_closed", "=", False)],
[
("team_id", "in", self.ids),
("stage_id.is_completed", "!=", True),
],
["team_id"],
["team_id"],
)
Expand Down Expand Up @@ -51,7 +54,7 @@ def _compute_vehicle_count(self):
"tms.order",
"team_id",
string="Orders",
domain=[("stage_id.is_closed", "=", False)],
domain=[("stage_id.is_completed", "!=", True)],
)
order_count = fields.Integer(compute="_compute_order_count", string="Orders Count")
sequence = fields.Integer(default=1, help="Used to sort teams. Lower is better.")
Expand Down Expand Up @@ -85,12 +88,6 @@ def _compute_vehicle_count(self):
trips_todo_count = fields.Integer(
string="Number of Trips", compute="_compute_trips_todo_count"
)
trips_todo_count_draft = fields.Integer(
string="Number of Trips", compute="_compute_trips_todo_count"
)
trips_todo_count_confirmed = fields.Integer(
string="Number of Trips", compute="_compute_trips_todo_count"
)

@api.depends("order_ids.stage_id")
def _compute_trips_todo_count(self):
Expand All @@ -99,34 +96,31 @@ def _compute_trips_todo_count(self):
[
("team_id", "=", team.id),
(
"stage_id.id",
"stage_id.is_completed",
"!=",
team.env.ref("tms.tms_stage_order_completed").id,
True,
),
]
)
data = self.env["tms.order"].read_group(
[
("team_id", "=", team.id),
(
"stage_id.id",
"stage_id.is_completed",
"!=",
team.env.ref("tms.tms_stage_order_completed").id,
True,
),
],
["stage_id"],
["__count"],
)
team.trips_todo_count = sum(count for (_, count) in data)
team.trips_todo_count_draft = sum(
count
for (stage_id, count) in data
if stage_id.id == team.env.ref("tms.tms_stage_order_draft").id
)
team.trips_todo_count_confirmed = sum(
count
for (stage_id, count) in data
if stage_id.id == team.env.ref("tms.tms_stage_order_confirmed").id
["stage_id", "count(*) as count"],
)

team.trips_todo_count = 0
team.trips_todo_count_draft = 0
team.trips_todo_count_confirmed = 0

for record in data:
if "stage_id_count" in record:
team.trips_todo_count += record["stage_id_count"]

_sql_constraints = [("name_uniq", "unique (name)", "Team name already exists!")]
1 change: 1 addition & 0 deletions tms/views/fleet_vehicle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</xpath>
<xpath expr="//field[@name='driver_id']" position="attributes">
<attribute name="domain">[("tms_type", "=", "driver")]</attribute>
<attribute name="context">{"default_tms_type": "driver"}</attribute>
</xpath>
</field>
</record>
Expand Down
3 changes: 1 addition & 2 deletions tms/views/tms_stage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<field name="sequence" widget="handle" groups="base.group_no_one" />
<field name="name" />
<field name="stage_type" />
<field name="is_closed" />
</tree>
</field>
</record>
Expand All @@ -31,7 +30,7 @@
<group>
<field name="custom_color" />
<field name="fold" />
<field name="is_closed" />
<field name="is_completed" />
<field
name="company_id"
groups="base.group_multi_company"
Expand Down
34 changes: 0 additions & 34 deletions tms/views/tms_team.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
<field name="vehicle_count" />
<field name="crew_ids" />
<field name="trips_todo_count" />
<field name="trips_todo_count_draft" />
<field name="trips_todo_count_confirmed" />
<templates>
<t t-name="kanban-box">
<div
Expand Down Expand Up @@ -74,38 +72,6 @@
TRIPS
</button>
</div>
<div
class="oe_kanban_bottom_right d-flex flex-column align-items-end"
>
<div
t-if="record.trips_todo_count_draft.raw_value > 0"
>
<a
name="%(tms.action_tms_operation_trip)d"
type="action"
context="{'search_default_team_id': id, 'search_default_stage_id': 1}"
>
<t
t-esc="record.trips_todo_count_draft.value"
/>
Draft
</a>
</div>
<div
t-if="record.trips_todo_count_confirmed.raw_value > 0"
>
<a
name="%(tms.action_tms_operation_trip)d"
type="action"
context="{'search_default_team_id': id, 'search_default_stage_id': 2}"
>
<t
t-esc="record.trips_todo_count_confirmed.value"
/>
Confirmed
</a>
</div>
</div>
</div>
</div>
</t>
Expand Down

0 comments on commit 58363e1

Please sign in to comment.