mirror of
https://github.com/bringout/oca-ocb-project.git
synced 2026-04-19 19:42:04 +02:00
Initial commit: Project packages
This commit is contained in:
commit
89613c97b0
753 changed files with 496325 additions and 0 deletions
5
odoo-bringout-oca-ocb-project/project/wizard/__init__.py
Normal file
5
odoo-bringout-oca-ocb-project/project/wizard/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import project_task_type_delete
|
||||
from . import project_share_wizard
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ProjectShareWizard(models.TransientModel):
|
||||
_name = 'project.share.wizard'
|
||||
_inherit = 'portal.share'
|
||||
_description = 'Project Sharing'
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
result = super().default_get(fields)
|
||||
if not result.get('access_mode'):
|
||||
result.update(
|
||||
access_mode='read',
|
||||
display_access_mode=True,
|
||||
)
|
||||
return result
|
||||
|
||||
@api.model
|
||||
def _selection_target_model(self):
|
||||
project_model = self.env['ir.model']._get('project.project')
|
||||
return [(project_model.model, project_model.name)]
|
||||
|
||||
access_mode = fields.Selection([('read', 'Readonly'), ('edit', 'Edit')])
|
||||
display_access_mode = fields.Boolean()
|
||||
|
||||
@api.depends('res_model', 'res_id')
|
||||
def _compute_resource_ref(self):
|
||||
for wizard in self:
|
||||
if wizard.res_model and wizard.res_model == 'project.project':
|
||||
wizard.resource_ref = '%s,%s' % (wizard.res_model, wizard.res_id or 0)
|
||||
else:
|
||||
wizard.resource_ref = None
|
||||
|
||||
def action_send_mail(self):
|
||||
self.ensure_one()
|
||||
if self.access_mode == 'edit':
|
||||
portal_partners = self.partner_ids.filtered('user_ids')
|
||||
note = self._get_note()
|
||||
self.resource_ref._add_collaborators(self.partner_ids)
|
||||
self._send_public_link(note, portal_partners)
|
||||
self._send_signup_link(note, partners=self.partner_ids - portal_partners)
|
||||
self.resource_ref.message_subscribe(partner_ids=self.partner_ids.ids)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
return super().action_send_mail()
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="project_share_wizard_view_form" model="ir.ui.view">
|
||||
<field name="name">project.share.wizard.view.form</field>
|
||||
<field name="model">project.share.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Share Project">
|
||||
<field name="res_model" invisible="1"/>
|
||||
<field name="res_id" invisible="1"/>
|
||||
<field name="display_access_mode" invisible="1" />
|
||||
<p class="alert alert-warning" attrs="{'invisible': [('access_warning', '=', '')]}" role="alert"><field name="access_warning"/></p>
|
||||
<group attrs="{'invisible': [('display_access_mode', '=', False)]}">
|
||||
<field class="flex-row" name="access_mode" widget="radio"/>
|
||||
</group>
|
||||
<group name="share_link" attrs="{'invisible': [('access_mode', '=', 'edit')]}">
|
||||
<field name="share_link" widget="CopyClipboardChar" options="{'string': 'Copy Link'}"/>
|
||||
</group>
|
||||
<group>
|
||||
<div class="o_td_label">
|
||||
<label for="partner_ids" string="Invite People" attrs="{'invisible': [('access_mode', '=', 'read')]}"/>
|
||||
<label for="partner_ids" attrs="{'invisible': [('access_mode', '=', 'edit')]}"/>
|
||||
</div>
|
||||
<field name="partner_ids" widget="many2many_tags_email" placeholder="Add contacts to share the project..." nolabel="1" context="{'show_email': True}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="note" placeholder="Add a note" nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Send" name="action_send_mail" attrs="{'invisible': [('access_warning', '!=', '')]}" type="object" class="btn-primary" data-hotkey="q"/>
|
||||
<button string="Discard" class="btn-secondary" special="cancel" data-hotkey="z" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="project_share_wizard_action" model="ir.actions.act_window">
|
||||
<field name="name">Share Project</field>
|
||||
<field name="res_model">project.share.wizard</field>
|
||||
<field name="binding_model_id" ref="model_project_project"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from ast import literal_eval
|
||||
|
||||
|
||||
class ProjectTaskTypeDelete(models.TransientModel):
|
||||
_name = 'project.task.type.delete.wizard'
|
||||
_description = 'Project Stage Delete Wizard'
|
||||
|
||||
project_ids = fields.Many2many('project.project', domain="['|', ('active', '=', False), ('active', '=', True)]", string='Projects', ondelete='cascade')
|
||||
stage_ids = fields.Many2many('project.task.type', string='Stages To Delete', ondelete='cascade')
|
||||
tasks_count = fields.Integer('Number of Tasks', compute='_compute_tasks_count')
|
||||
stages_active = fields.Boolean(compute='_compute_stages_active')
|
||||
|
||||
@api.depends('project_ids')
|
||||
def _compute_tasks_count(self):
|
||||
for wizard in self:
|
||||
wizard.tasks_count = self.with_context(active_test=False).env['project.task'].search_count([('stage_id', 'in', wizard.stage_ids.ids)])
|
||||
|
||||
@api.depends('stage_ids')
|
||||
def _compute_stages_active(self):
|
||||
for wizard in self:
|
||||
wizard.stages_active = all(wizard.stage_ids.mapped('active'))
|
||||
|
||||
def action_archive(self):
|
||||
if len(self.project_ids) <= 1:
|
||||
return self.action_confirm()
|
||||
|
||||
return {
|
||||
'name': _('Confirmation'),
|
||||
'view_mode': 'form',
|
||||
'res_model': 'project.task.type.delete.wizard',
|
||||
'views': [(self.env.ref('project.view_project_task_type_delete_confirmation_wizard').id, 'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_id': self.id,
|
||||
'target': 'new',
|
||||
'context': self.env.context,
|
||||
}
|
||||
|
||||
def action_unarchive_task(self):
|
||||
inactive_tasks = self.env['project.task'].with_context(active_test=False).search(
|
||||
[('active', '=', False), ('stage_id', 'in', self.stage_ids.ids)])
|
||||
inactive_tasks.action_unarchive()
|
||||
|
||||
def action_confirm(self):
|
||||
tasks = self.with_context(active_test=False).env['project.task'].search([('stage_id', 'in', self.stage_ids.ids)])
|
||||
tasks.write({'active': False})
|
||||
self.stage_ids.write({'active': False})
|
||||
return self._get_action()
|
||||
|
||||
def action_unlink(self):
|
||||
self.stage_ids.unlink()
|
||||
return self._get_action()
|
||||
|
||||
def _get_action(self):
|
||||
project_id = self.env.context.get('default_project_id')
|
||||
|
||||
if project_id:
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("project.action_view_task")
|
||||
action['domain'] = [('display_project_id', '=', project_id)]
|
||||
action['context'] = str({
|
||||
'pivot_row_groupby': ['user_ids'],
|
||||
'default_project_id': project_id,
|
||||
})
|
||||
elif self.env.context.get('stage_view'):
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("project.open_task_type_form")
|
||||
else:
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("project.action_view_all_task")
|
||||
|
||||
context = action.get('context', '{}')
|
||||
context = context.replace('uid', str(self.env.uid))
|
||||
context = dict(literal_eval(context), active_test=True)
|
||||
action['context'] = context
|
||||
action['target'] = 'main'
|
||||
return action
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_project_task_type_delete_wizard" model="ir.ui.view">
|
||||
<field name="name">project.task.type.delete.wizard.form</field>
|
||||
<field name="model">project.task.type.delete.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Delete Stage">
|
||||
<field name="tasks_count" invisible="1" />
|
||||
<field name="stages_active" invisible="1" />
|
||||
<div attrs="{'invisible': [('tasks_count', '>', 0)]}">
|
||||
<p>Are you sure you want to delete those stages ?</p>
|
||||
</div>
|
||||
<div attrs="{'invisible': ['|', ('stages_active', '=', False), ('tasks_count', '=', 0)]}">
|
||||
<p>You cannot delete stages containing tasks. You can either archive them or first delete all of their tasks.</p>
|
||||
</div>
|
||||
<div attrs="{'invisible': ['|', ('stages_active', '=', True), ('tasks_count', '=', 0)]}">
|
||||
<p>You cannot delete stages containing tasks. You should first delete all of their tasks.</p>
|
||||
</div>
|
||||
<footer>
|
||||
<button string="Archive Stages" type="object" name="action_archive" class="btn btn-primary" attrs="{'invisible': ['|', ('stages_active', '=', False), ('tasks_count', '=', 0)]}" data-hotkey="q"/>
|
||||
<button string="Delete" type="object" name="action_unlink" class="btn btn-primary" attrs="{'invisible': [('tasks_count', '>', 0)]}" data-hotkey="w"/>
|
||||
<button string="Discard" special="cancel" data-hotkey="z" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_project_task_type_delete_confirmation_wizard" model="ir.ui.view">
|
||||
<field name="name">project.task.type.delete.wizard.form</field>
|
||||
<field name="model">project.task.type.delete.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Delete Stage">
|
||||
<div>
|
||||
<p>This will archive the stages and all the tasks they contain from the following projects:</p>
|
||||
<field name="project_ids" readonly="1">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
<p>Are you sure you want to continue?</p>
|
||||
</div>
|
||||
<footer>
|
||||
<button string="Confirm" type="object" name="action_confirm" class="btn btn-primary" data-hotkey="q"/>
|
||||
<button string="Discard" special="cancel" data-hotkey="z" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_project_task_type_unarchive_wizard" model="ir.ui.view">
|
||||
<field name="name">project.task.type.delete.wizard.form</field>
|
||||
<field name="model">project.task.type.delete.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Delete Stage">
|
||||
<div>
|
||||
<p>Would you like to unarchive all of the tasks contained in these stages as well?</p>
|
||||
</div>
|
||||
<footer>
|
||||
<button string="Confirm" type="object" name="action_unarchive_task" class="btn btn-primary"/>
|
||||
<button string="Discard" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue