[IMP] sale_(project): remove fields and improve project app
The following changes are made in this PR: - sort projects by favorite > sequence > name for project - add the 'tasks' stat button for project form view - when creating a project on the fly from a task's form view, allow_billable should be set to true by default - Display only the colored dot, hide the status label for project list view - remove following fields from project allow_recurring_tasks task-3251656 closes odoo/odoo#119154 Related: odoo/upgrade#4569 Related: odoo/enterprise#40050 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
committed by
Rohit Kumar
parent
8d0625a95f
commit
05079fe8e3
@@ -160,7 +160,6 @@ class Project(models.Model):
|
||||
date_start = fields.Date(string='Start Date')
|
||||
date = fields.Date(string='Expiration Date', index=True, tracking=True,
|
||||
help="Date on which this project ends. The timeframe defined on the project is taken into account when viewing its planning.")
|
||||
allow_recurring_tasks = fields.Boolean('Recurring Tasks', default=lambda self: self.env.user.has_group('project.group_project_recurring_tasks'))
|
||||
allow_task_dependencies = fields.Boolean('Task Dependencies', default=lambda self: self.env.user.has_group('project.group_project_task_dependencies'))
|
||||
allow_milestones = fields.Boolean('Milestones', default=lambda self: self.env.user.has_group('project.group_project_milestone'))
|
||||
tag_ids = fields.Many2many('project.tags', relation='project_project_project_tags_rel', string='Tags')
|
||||
@@ -434,9 +433,6 @@ class Project(models.Model):
|
||||
|
||||
res = super(Project, self).write(vals) if vals else True
|
||||
|
||||
if 'allow_recurring_tasks' in vals and not vals.get('allow_recurring_tasks'):
|
||||
self.env['project.task'].search([('project_id', 'in', self.ids), ('recurring_task', '=', True)]).write({'recurring_task': False})
|
||||
|
||||
if 'allow_task_dependencies' in vals and not vals.get('allow_task_dependencies'):
|
||||
self.env['project.task'].search([('project_id', 'in', self.ids), ('state', '=', '04_waiting_normal')]).write({'state': '01_in_progress'})
|
||||
|
||||
|
||||
@@ -233,7 +233,6 @@ class Task(models.Model):
|
||||
display_parent_task_button = fields.Boolean(compute='_compute_display_parent_task_button', compute_sudo=True)
|
||||
|
||||
# recurrence fields
|
||||
allow_recurring_tasks = fields.Boolean(related='project_id.allow_recurring_tasks')
|
||||
recurring_task = fields.Boolean(string="Recurrent")
|
||||
recurring_count = fields.Integer(string="Tasks in Recurrence", compute='_compute_recurring_count')
|
||||
recurrence_id = fields.Many2one('project.task.recurrence', copy=False)
|
||||
|
||||
@@ -81,10 +81,9 @@ class ProjectTaskRecurrence(models.Model):
|
||||
|
||||
def _create_next_occurrence(self, occurrence_from):
|
||||
self.ensure_one()
|
||||
if occurrence_from.allow_recurring_tasks:
|
||||
self.env['project.task'].sudo().create(
|
||||
self._create_next_occurrence_values(occurrence_from)
|
||||
)
|
||||
self.env['project.task'].sudo().create(
|
||||
self._create_next_occurrence_values(occurrence_from)
|
||||
)
|
||||
|
||||
def _create_next_occurrence_values(self, occurrence_from):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -35,7 +35,6 @@ class ResConfigSettings(models.TransientModel):
|
||||
features = {
|
||||
# key: (config_flag, is_global), value: project_flag
|
||||
("group_project_rating", True): "rating_active",
|
||||
("group_project_recurring_tasks", True): "allow_recurring_tasks",
|
||||
("group_project_task_dependencies", False): "allow_task_dependencies",
|
||||
("group_project_milestone", False): "allow_milestones",
|
||||
}
|
||||
@@ -66,5 +65,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
rating_project_request_email_template = self.env.ref('project.rating_project_request_email_template')
|
||||
if rating_project_request_email_template.active != self['group_project_rating']:
|
||||
rating_project_request_email_template.active = self['group_project_rating']
|
||||
if not self['group_project_recurring_tasks']:
|
||||
self.env['project.task'].sudo().search([('recurring_task', '=', True)]).write({'recurring_task': False})
|
||||
|
||||
super().set_values()
|
||||
|
||||
+1
-1
@@ -28,4 +28,4 @@ export const projectStateSelectionField = {
|
||||
component: ProjectStateSelectionField,
|
||||
};
|
||||
|
||||
registry.category("fields").add("kanban.project_state_selection", projectStateSelectionField);
|
||||
registry.category("fields").add("project_state_selection", projectStateSelectionField);
|
||||
|
||||
@@ -17,7 +17,6 @@ class TestProjectConfig(TestProjectCommon):
|
||||
cls.Settings = cls.env["res.config.settings"]
|
||||
cls.features = (
|
||||
# Pairs of associated (config_flag, project_flag)
|
||||
("group_project_recurring_tasks", "allow_recurring_tasks"),
|
||||
("group_project_rating", "rating_active"),
|
||||
)
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ class TestProjectRecurrence(TransactionCase):
|
||||
cls.stage_b = cls.env['project.task.type'].create({'name': 'b'})
|
||||
cls.project_recurring = cls.env['project.project'].with_context({'mail_create_nolog': True}).create({
|
||||
'name': 'Recurring',
|
||||
'allow_recurring_tasks': True,
|
||||
'type_ids': [
|
||||
(4, cls.stage_a.id),
|
||||
(4, cls.stage_b.id),
|
||||
@@ -99,3 +98,18 @@ class TestProjectRecurrence(TransactionCase):
|
||||
with freeze_time(self.date_01_01 + relativedelta(days=32)):
|
||||
task.state = '1_done'
|
||||
self.assertEqual(len(task.recurrence_id.task_ids), 2, "Since this is after repeat_until, next occurrence shouldn't have been created")
|
||||
|
||||
def test_recurring_settings_change(self):
|
||||
self.env['res.config.settings'] \
|
||||
.create({'group_project_recurring_tasks': True}) \
|
||||
.execute()
|
||||
test_task = self.env['project.task'].create({
|
||||
'name': "Recurring Task",
|
||||
'project_id': self.project_recurring.id,
|
||||
'recurring_task': True,
|
||||
})
|
||||
self.assertTrue(test_task.recurring_task, 'The "Recurring" feature should be enabled from settings.')
|
||||
self.env['res.config.settings'] \
|
||||
.create({'group_project_recurring_tasks': False}) \
|
||||
.execute()
|
||||
self.assertFalse(test_task.recurring_task, 'The "Recurring" feature should not be enabled by default.')
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
</header>
|
||||
<sheet string="Project">
|
||||
<div class="oe_button_box" name="button_box" groups="base.group_user">
|
||||
<button class="oe_stat_button" type="object" name="action_view_tasks" icon="fa-tasks">
|
||||
<field string="Tasks" name="task_count" widget="statinfo"/>
|
||||
</button>
|
||||
<button class="oe_stat_button" name="project_update_all_action" type="object" groups="project.group_project_manager">
|
||||
<field name="last_update_color" invisible="1"/>
|
||||
<div class="o_stat_info">
|
||||
@@ -109,9 +112,6 @@
|
||||
<group>
|
||||
<group name="group_tasks_managment" string="Tasks Management" col="1" class="row mt16 o_settings_container" groups="project.group_project_task_dependencies,project.group_project_milestone,project.group_project_recurring_tasks">
|
||||
<div>
|
||||
<setting id="recurring_tasks_setting" help="Auto-generate tasks for regular activities" groups="project.group_project_recurring_tasks">
|
||||
<field name="allow_recurring_tasks"/>
|
||||
</setting>
|
||||
<setting id="task_dependencies_setting" help="Determine the order in which to perform tasks" groups="project.group_project_task_dependencies">
|
||||
<field name="allow_task_dependencies"/>
|
||||
</setting>
|
||||
@@ -217,7 +217,7 @@
|
||||
<field name="user_id" optional="show" string="Project Manager" widget="many2one_avatar_user" options="{'no_open':True, 'no_create': True, 'no_create_edit': True}"/>
|
||||
<field name="last_update_color" invisible="1"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}" optional="hide"/>
|
||||
<field name="last_update_status" string="Status" nolabel="1" optional="show" widget="status_with_color" options="{'hide_label': True}"/>
|
||||
<field name="last_update_status" string="Status" nolabel="1" optional="show" widget="project_state_selection" options="{'hide_label': True}"/>
|
||||
<field name="stage_id" options="{'no_open': True}" optional="show"/>
|
||||
<button string="View Tasks" name="action_view_tasks" type="object"/>
|
||||
</tree>
|
||||
@@ -242,9 +242,6 @@
|
||||
<field name="inherit_id" ref="project.view_project"/>
|
||||
<field name="mode">primary</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<attribute name="default_order">sequence, name, id</attribute>
|
||||
</tree>
|
||||
<field name="sequence" position="attributes">
|
||||
<attribute name="invisible">0</attribute>
|
||||
<attribute name="widget">handle</attribute>
|
||||
@@ -524,7 +521,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//kanban" position="attributes">
|
||||
<attribute name="action"></attribute>
|
||||
<attribute name="default_order">sequence, name, id</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -240,7 +240,6 @@
|
||||
<field eval="2" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Task" class="o_form_project_tasks" js_class="project_task_form">
|
||||
<field name="allow_recurring_tasks" invisible="1" />
|
||||
<field name="recurrence_id" invisible="1" />
|
||||
<field name="allow_task_dependencies" invisible="1" />
|
||||
<field name="rating_last_value" invisible="1"/>
|
||||
@@ -343,7 +342,7 @@
|
||||
<field name="date_deadline" nolabel="1"/>
|
||||
<field name="recurring_task" nolabel="1" class="ms-0" style="width: fit-content;"
|
||||
widget="boolean_icon" options="{'icon': 'fa-repeat'}"
|
||||
attrs="{'invisible': ['|', '|', ('allow_recurring_tasks', '=', False), ('active', '=', False), ('parent_id', '!=', False)]}"
|
||||
attrs="{'invisible': ['|', ('active', '=', False), ('parent_id', '!=', False)]}"
|
||||
groups="project.group_project_recurring_tasks"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -68,6 +68,19 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_sale_project_quick_create_task_form" model="ir.ui.view">
|
||||
<field name="name">project.task.view.inherit</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" ref="project.quick_create_task_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='project_id']" position="attributes">
|
||||
<attribute name="context">{'default_allow_billable': True, 'default_type_ids': [(4, context.get('default_stage_id', False))]}
|
||||
</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_sale_project_inherit_form" model="ir.ui.view">
|
||||
<field name="name">project.task.view.inherit</field>
|
||||
<field name="model">project.task</field>
|
||||
@@ -117,6 +130,9 @@
|
||||
<xpath expr="//field[@name='depend_on_ids']/tree/field[@name='partner_id']" position="attributes">
|
||||
<attribute name="attrs">{'column_invisible': [('parent.allow_billable', '=', False)], 'invisible': [('allow_billable', '=', False)]}</attribute>
|
||||
</xpath>
|
||||
<field name="project_id" position="attributes">
|
||||
<attribute name="context">{'default_allow_billable': True}</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user