bemade-addons/customer_applications/models/application.py
Marc Durepos 87a1cb8860 Major changes for applications and equipment.
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.
2024-10-17 15:28:07 -04:00

36 lines
1.1 KiB
Python

from odoo import models, fields, Command
class Application(models.Model):
_name = "partner.application"
_description = "Partner Application"
_inherit = ["mail.thread", "mail.activity.mixin"]
name = fields.Char(tracking=1)
description = fields.Text(tracking=2)
partner_id = fields.Many2one(
comodel_name="res.partner",
required=True,
tracking=3,
copy=False,
)
application_type_id = fields.Many2one(
comodel_name="partner.application.type",
required=True,
tracking=4,
ondelete="restrict",
)
specification_ids = fields.One2many(
comodel_name="partner.application.specification",
inverse_name="application_id",
tracking=5,
)
def copy(self, default=None):
self.ensure_one() # This logic won't work for batches, and it doesn't need to
default = default or {}
if "specification_ids" not in default:
default["specification_ids"] = [
Command.create(line.copy_data()[0]) for line in self.specification_ids
]
return super().copy(default)