mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 12:12:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import maintenance_request
|
||||
from . import purchase_order
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2019 Creu Blanca
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class MaintenanceRequest(models.Model):
|
||||
|
||||
_inherit = "maintenance.request"
|
||||
|
||||
purchase_order_ids = fields.Many2many(
|
||||
"purchase.order",
|
||||
"maintenance_purchase_order",
|
||||
"maintenance_request_id",
|
||||
"purchase_order_id",
|
||||
groups="purchase.group_purchase_user",
|
||||
string="Purchase Orders",
|
||||
copy=False,
|
||||
)
|
||||
purchases_count = fields.Integer(
|
||||
compute="_compute_purchases_count",
|
||||
store=True,
|
||||
groups="purchase.group_purchase_user",
|
||||
)
|
||||
|
||||
@api.depends("purchase_order_ids")
|
||||
def _compute_purchases_count(self):
|
||||
for record in self:
|
||||
record.purchases_count = len(record.purchase_order_ids.ids)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# Copyright 2019 Creu Blanca
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class PurchaseOrder(models.Model):
|
||||
|
||||
_inherit = "purchase.order"
|
||||
|
||||
maintenance_request_ids = fields.Many2many(
|
||||
"maintenance.request",
|
||||
"maintenance_purchase_order",
|
||||
"purchase_order_id",
|
||||
"maintenance_request_id",
|
||||
string="Maintenance Requests",
|
||||
copy=False,
|
||||
)
|
||||
|
||||
maintenance_requests_count = fields.Integer(
|
||||
compute="_compute_maintenance_requests_count", store=True
|
||||
)
|
||||
|
||||
@api.depends("maintenance_request_ids")
|
||||
def _compute_maintenance_requests_count(self):
|
||||
for record in self:
|
||||
record.maintenance_requests_count = len(record.maintenance_request_ids.ids)
|
||||
|
||||
def action_view_maintenance_request(self):
|
||||
action = self.env["ir.actions.act_window"]._for_xml_id(
|
||||
"maintenance.hr_equipment_request_action"
|
||||
)
|
||||
if len(self.maintenance_request_ids) > 1:
|
||||
action["domain"] = [("id", "in", self.maintenance_request_ids.ids)]
|
||||
elif self.maintenance_request_ids:
|
||||
action["views"] = [(False, "form")]
|
||||
action["res_id"] = self.maintenance_request_ids.id
|
||||
action["context"] = {}
|
||||
return action
|
||||
Loading…
Add table
Add a link
Reference in a new issue