Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cb_maintenance/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"maintenance_request_sequence",
"maintenance_request_stage_transition",
"maintenance_team_hierarchy",
"maintenance_request_purchase",
"web_widget_open_tab",
"base",
],
Expand Down
22 changes: 22 additions & 0 deletions cb_maintenance/models/maintenance_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ class MaintenanceRequest(models.Model):

external_link = fields.Char()

total_purchase_amount = fields.Monetary(
compute="_compute_total_purchase_amount",
store=True,
groups="purchase.group_purchase_user",
)

currency_id = fields.Many2one(
"res.currency", string="Currency", compute="_compute_currency", store=True
)

@api.depends("purchase_order_ids.amount_total")
def _compute_total_purchase_amount(self):
for record in self:
record.total_purchase_amount = sum(
record.purchase_order_ids.mapped("amount_total")
)

@api.depends("company_id")
def _compute_currency(self):
for record in self:
record.currency_id = record.company_id.currency_id

# link_ocs = fields.Char(string="Link OCS") # TODO: Not sure if necessary
@api.depends("close_datetime", "create_date")
def _compute_hours_to_close(self):
Expand Down