Add the notion of application specification keys to allow administrators to specify the names of specification items that can be used on an application. This aims to homogenize specifications and to later provide a sort of checklist when creating a new application for a customer. Added groups for partner applications (user and admin). Administrators have the right to create specification keys while users can only read them (and use them to create specifications on an application). Various view improvements across the affected modules.
29 lines
910 B
Python
29 lines
910 B
Python
from odoo import models, fields, api
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class PartnerApplication(models.Model):
|
|
_inherit = "partner.application"
|
|
|
|
equipment_ids = fields.One2many(
|
|
comodel_name="fsm.equipment",
|
|
inverse_name="application_id",
|
|
string="Equipment",
|
|
)
|
|
equipment_count = fields.Integer(
|
|
compute="_compute_equipment_count",
|
|
string="Equipment Count",
|
|
)
|
|
|
|
@api.constrains("equipment_ids")
|
|
def _check_equipment_ids(self):
|
|
for application in self:
|
|
if len(application.equipment_ids.partner_id) > 1:
|
|
raise ValidationError(
|
|
"An application can only be linked to one partner."
|
|
)
|
|
|
|
@api.depends("equipment_ids")
|
|
def _compute_equipment_count(self):
|
|
for application in self:
|
|
application.equipment_count = len(application.equipment_ids)
|