first push message
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
class SelectedApps(models.Model):
|
||||
_name = 'selected.apps'
|
||||
_description = 'Selected Applications'
|
||||
|
||||
subscription_id = fields.Many2one('user.subscription', string='Subscription',
|
||||
required=True, ondelete='cascade')
|
||||
app_name = fields.Char(string='App Name', required=True)
|
||||
app_technical_name = fields.Char(string='Technical Name')
|
||||
app_icon = fields.Char(string='App Icon')
|
||||
app_category = fields.Selection([
|
||||
('sales', 'Sales'),
|
||||
('finance', 'Finance'),
|
||||
('services', 'Services'),
|
||||
('marketing', 'Marketing'),
|
||||
('other', 'Other'),
|
||||
], string='Category', default='other')
|
||||
is_installed = fields.Boolean(string='Installed', default=False)
|
||||
|
||||
@api.constrains('subscription_id')
|
||||
def _check_max_apps(self):
|
||||
for record in self:
|
||||
subscription = record.subscription_id
|
||||
if subscription.max_apps_allowed:
|
||||
app_count = self.search_count([('subscription_id', '=', subscription.id)])
|
||||
if app_count > subscription.max_apps_allowed:
|
||||
raise UserError(
|
||||
f'You can select at most {subscription.max_apps_allowed} apps'
|
||||
)
|
||||
Reference in New Issue
Block a user