kudos changes commit
This commit is contained in:
parent
20d22c1f04
commit
d362ef87aa
|
|
@ -0,0 +1 @@
|
|||
from . import models
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
'name': 'Project Kudos Link (Fixed)',
|
||||
'version': '18.0.1.0.0',
|
||||
'summary': 'Add Assign Kudos button and controlled employee domain by project visibility/generic',
|
||||
'category': 'Project',
|
||||
'author': 'You',
|
||||
'license': 'LGPL-3',
|
||||
'depends': [
|
||||
'project',
|
||||
'project_kudos_plus',
|
||||
'project_task_timesheet_extended',
|
||||
],
|
||||
'data': [
|
||||
# 'views/project_task_kudo_button.xml',
|
||||
'views/task_assign_kudos_action.xml',
|
||||
'views/kudo_log_extend.xml',
|
||||
],
|
||||
'post_init_hook': 'post_init_hook',
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import project_kudo_extend
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ProjectTask(models.Model):
|
||||
_inherit = "project.task"
|
||||
|
||||
def action_assign_kudos(self):
|
||||
# Always load real task (form/kanban/list safe)
|
||||
task_id = self.id or self._context.get('active_id')
|
||||
task = self.env['project.task'].browse(task_id)
|
||||
task.ensure_one()
|
||||
|
||||
allowed = task._allowed_employees().ids
|
||||
|
||||
ctx = dict(
|
||||
self.env.context,
|
||||
default_task_id=task.id,
|
||||
default_project_id=task.project_id.id,
|
||||
employee_domain=allowed,
|
||||
)
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': 'Assign Kudos',
|
||||
'res_model': 'project.kudos',
|
||||
'view_mode': 'form',
|
||||
'target': 'new',
|
||||
'context': ctx,
|
||||
}
|
||||
|
||||
def _allowed_employees(self):
|
||||
self.ensure_one()
|
||||
|
||||
Employee = self.env['hr.employee']
|
||||
task = self
|
||||
project = task.project_id
|
||||
visibility = project.privacy_visibility
|
||||
|
||||
admin_emp = Employee.search([('user_id.id', '=', 2)])
|
||||
|
||||
# FIXED HERE ↓↓↓
|
||||
if task.is_generic:
|
||||
assignees = (
|
||||
task.user_ids # your system uses user_ids assigned manually
|
||||
).mapped("employee_id")
|
||||
|
||||
return assignees - admin_emp
|
||||
|
||||
# PRIVATE
|
||||
if visibility == "followers":
|
||||
users = project.message_partner_ids.mapped("user_ids")
|
||||
internal_users = users.filtered(lambda u: not u.share)
|
||||
employees = internal_users.mapped("employee_id")
|
||||
return employees - admin_emp
|
||||
|
||||
# INTERNAL ONLY
|
||||
if visibility == "employees":
|
||||
employees = Employee.search([
|
||||
('user_id.share', '=', False)
|
||||
])
|
||||
return employees - admin_emp
|
||||
|
||||
# PUBLIC
|
||||
employees = Employee.search([])
|
||||
return employees - admin_emp
|
||||
|
||||
|
||||
class ProjectKudos(models.Model):
|
||||
_inherit = "project.kudos"
|
||||
# unchanged
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<odoo>
|
||||
<record id="project_kudos_form_extend" model="ir.ui.view">
|
||||
<field name="name">project.kudos.form.extend</field>
|
||||
<field name="model">project.kudos</field>
|
||||
<field name="inherit_id" ref="project_kudos_plus.view_project_kudos_form"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<xpath expr="//field[@name='employee_id']" position="attributes">
|
||||
<attribute name="domain">
|
||||
[('id', 'in', context.get('employee_domain', []))]
|
||||
</attribute>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<odoo>
|
||||
<record id="task_form_assign_kudos_button" model="ir.ui.view">
|
||||
<field name="name">task.form.kudos.button</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" ref="project.view_task_form2"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="action_assign_kudos"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
string="Assign Kudos">
|
||||
<div class="o_stat_info" style="font-size:12px;">
|
||||
<span class="o_stat_text">Assign Kudos</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<odoo>
|
||||
<record id="action_task_assign_kudos" model="ir.actions.server">
|
||||
<field name="name">Assign Kudos</field>
|
||||
<field name="model_id" ref="project.model_project_task"/>
|
||||
<field name="binding_model_id" ref="project.model_project_task"/>
|
||||
<field name="binding_type">action</field>
|
||||
<field name="state">code</field>
|
||||
|
||||
<field name="code">
|
||||
action = records.action_assign_kudos()
|
||||
result = action
|
||||
</field>
|
||||
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in New Issue