-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][IMP] custom_mrp_descarga: Add new fields in production.
- Loading branch information
Showing
9 changed files
with
204 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2024 Berezi Amubieta - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from datetime import timedelta | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class MrpWorkorder(models.Model): | ||
_inherit = "mrp.workorder" | ||
|
||
waiting_duration = fields.Float( | ||
string="Waiting", compute="_compute_waiting_duration", store=True | ||
) | ||
total_duration = fields.Float(compute="_compute_total_duration", store=True) | ||
|
||
@api.depends("duration", "waiting_duration") | ||
def _compute_total_duration(self): | ||
for workorder in self: | ||
workorder.total_duration = workorder.duration + workorder.waiting_duration | ||
|
||
@api.depends("date_start", "date_finished", "duration") | ||
def _compute_waiting_duration(self): | ||
for workorder in self: | ||
waiting = 0 | ||
if workorder.date_start and workorder.date_finished: | ||
dif = workorder.date_finished - workorder.date_start | ||
dif = dif.total_seconds() / timedelta(minutes=1).total_seconds() | ||
waiting = dif - workorder.duration | ||
workorder.waiting_duration = waiting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.