first push message
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import ks_ir_ui_view_inherit
|
||||
from . import ks_ir_actions_act_window_view_inherit
|
||||
from . import ks_task_link
|
||||
from . import ks_week_days
|
||||
from . import ks_res_config_settings
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class KsActWindowView(models.Model):
|
||||
_inherit = 'ir.actions.act_window.view'
|
||||
|
||||
view_mode = fields.Selection(selection_add=[('ks_gantt', "Gantt")], ondelete={'ks_gantt': 'cascade'})
|
||||
@@ -0,0 +1,91 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
# Inheriting view and adding Gantt view to View.
|
||||
class KsGanttView(models.Model):
|
||||
_inherit = "ir.ui.view"
|
||||
|
||||
type = fields.Selection(
|
||||
selection_add=[('ks_gantt', "Gantt")],
|
||||
ondelete={'ks_gantt': 'cascade'},
|
||||
)
|
||||
|
||||
def _postprocess_access_rights(self, tree):
|
||||
"""
|
||||
Override to handle access rights for the custom ks_gantt view type.
|
||||
|
||||
Odoo 19 Note: _postprocess_access_rights signature is unchanged from 17→19.
|
||||
The only functional change is that the 'ks_gantt' tag check uses the same
|
||||
pattern as Odoo core kanban/list views — we inherit the base implementation
|
||||
for all standard tags and only add our own handling for <ks_gantt> nodes.
|
||||
"""
|
||||
# Guard: skip extra processing when called in form view context
|
||||
if self._context.get('view_type', False) == 'form':
|
||||
return super()._postprocess_access_rights(tree)
|
||||
|
||||
# Strip nodes the user cannot access based on @groups attribute
|
||||
for node in tree.xpath('//*[@groups]'):
|
||||
if not self.user_has_groups(node.attrib.pop('groups')):
|
||||
node.getparent().remove(node)
|
||||
elif node.tag == 't' and not node.attrib:
|
||||
for child in reversed(node):
|
||||
node.addnext(child)
|
||||
node.getparent().remove(node)
|
||||
|
||||
# Apply model-level create/write/delete access flags to view nodes
|
||||
base_model = tree.get('model_access_rights')
|
||||
for node in tree.xpath('//*[@model_access_rights]'):
|
||||
model = self.env[node.attrib.pop('model_access_rights')]
|
||||
if node.tag == 'field':
|
||||
can_create = model.check_access_rights('create', raise_exception=False)
|
||||
can_write = model.check_access_rights('write', raise_exception=False)
|
||||
node.set('can_create', 'true' if can_create else 'false')
|
||||
node.set('can_write', 'true' if can_write else 'false')
|
||||
else:
|
||||
is_base_model = base_model == model._name
|
||||
for action, operation in (
|
||||
('create', 'create'),
|
||||
('delete', 'unlink'),
|
||||
('edit', 'write'),
|
||||
):
|
||||
if (
|
||||
not node.get(action)
|
||||
and not model.check_access_rights(operation, raise_exception=False)
|
||||
or not self._context.get(action, True)
|
||||
and is_base_model
|
||||
):
|
||||
node.set(action, 'false')
|
||||
|
||||
# Extra group_by model access check specific to ks_gantt nodes
|
||||
if node.tag == 'ks_gantt':
|
||||
group_by_name = node.get('default_group_by')
|
||||
group_by_field = model._fields.get(group_by_name)
|
||||
if group_by_field and group_by_field.type == 'many2one':
|
||||
group_by_model = model.env[group_by_field.comodel_name]
|
||||
for action, operation in (
|
||||
('group_create', 'create'),
|
||||
('group_delete', 'unlink'),
|
||||
('group_edit', 'write'),
|
||||
):
|
||||
if (
|
||||
not node.get(action)
|
||||
and not group_by_model.check_access_rights(
|
||||
operation, raise_exception=False
|
||||
)
|
||||
or not self._context.get(action, True)
|
||||
and is_base_model
|
||||
):
|
||||
node.set(action, 'false')
|
||||
|
||||
return super()._postprocess_access_rights(tree)
|
||||
|
||||
|
||||
class KsBase(models.AbstractModel):
|
||||
_inherit = "base"
|
||||
|
||||
@api.model
|
||||
def get_view(self, view_id=None, view_type='form', **options):
|
||||
"""Pass view_type into context so _postprocess_access_rights can inspect it."""
|
||||
self = self.with_context(view_type=view_type)
|
||||
return super().get_view(view_id=view_id, view_type=view_type, **options)
|
||||
@@ -0,0 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class KsResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
ks_gantt_theme = fields.Selection(
|
||||
selection=[
|
||||
('dhtmlxgantt_terrace.css', 'Default'),
|
||||
('dhtmlxgantt_skyblue.css', 'Sky Blue'),
|
||||
('dhtmlxgantt_meadow.css', 'Meadow'),
|
||||
('dhtmlxgantt_broadway.css', 'Broadway'),
|
||||
('dhtmlxgantt_material.css', 'Material'),
|
||||
('dhtmlxgantt_contrast_white.css', 'Contrast White'),
|
||||
('dhtmlxgantt_contrast_black.css', 'Contrast Black'),
|
||||
],
|
||||
default='dhtmlxgantt_terrace.css',
|
||||
string='Gantt View Theme',
|
||||
required=True,
|
||||
config_parameter='ks_gantt_view_base.selected_theme',
|
||||
)
|
||||
|
||||
ks_gantt_rtl = fields.Boolean(
|
||||
string='Enable RTL',
|
||||
config_parameter='ks_gantt_view_base.ks_gantt_rtl',
|
||||
default=False,
|
||||
)
|
||||
|
||||
@api.model
|
||||
def ks_gantt_view_theme(self):
|
||||
"""
|
||||
Return current Gantt theme and RTL settings as a dict.
|
||||
|
||||
Odoo 19: Use sudo().get_param() directly — searching ir.config_parameter
|
||||
manually is still supported but get_param() is the recommended API.
|
||||
"""
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
return {
|
||||
'ks_gantt_view_theme': ICP.get_param(
|
||||
'ks_gantt_view_base.selected_theme',
|
||||
default='dhtmlxgantt_terrace.css',
|
||||
),
|
||||
'ks_gantt_rtl': ICP.get_param(
|
||||
'ks_gantt_view_base.ks_gantt_rtl',
|
||||
default='False',
|
||||
),
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class KsTaskLink(models.Model):
|
||||
_name = 'ks.task.link'
|
||||
_description = 'Ks Gantt Task Linking'
|
||||
|
||||
ks_task_link_type = fields.Selection(
|
||||
string='Task Link Type',
|
||||
selection=[('0', 'Finish to start'),
|
||||
('1', 'Start to start'),
|
||||
('2', 'Finish to finish'),
|
||||
('3', 'Start to finish'),
|
||||
],
|
||||
required=True, )
|
||||
|
||||
def unlink(self):
|
||||
"""
|
||||
Override unlink function to avoid error 'could not serialize access due to concurrent update',
|
||||
this error occur when user tries to delete the record that is already deleted or not exist,
|
||||
problem with this - when this issue occurs then CRUD operations are also stopped working.
|
||||
"""
|
||||
|
||||
# Check if request id is already deleted or doesn't exist.
|
||||
for rec in self:
|
||||
try:
|
||||
if not len(self.env['ks.task.link'].search([('id', '=', rec.id)])):
|
||||
return True
|
||||
except Exception as e:
|
||||
# If id is out of range.
|
||||
return True
|
||||
return super(KsTaskLink, self).unlink()
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class KsWeekDays(models.Model):
|
||||
_name = 'ks.week.days'
|
||||
_description = 'Week Days'
|
||||
_rec_name = 'ks_day_name'
|
||||
|
||||
ks_day_no = fields.Integer()
|
||||
ks_day_name = fields.Char(string='Day')
|
||||
Reference in New Issue
Block a user