Skip to content

Commit

Permalink
Merge pull request #168 from don-systems/MIG-mgmtsystem_action-to-V.-…
Browse files Browse the repository at this point in the history
…10.0

Mig mgmtsystem action to v. 10.0
  • Loading branch information
Maxime Chambreuil committed Apr 20, 2017
2 parents adaf90e + 8ee1cbf commit 17facb4
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 79 deletions.
4 changes: 3 additions & 1 deletion mgmtsystem_action/README.rst
Expand Up @@ -63,7 +63,7 @@ In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/
Management-system/issues/new?body=module:%20
mgmtsystem_system%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
10.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Credits
Expand All @@ -74,6 +74,7 @@ Contributors

* Savoir-faire Linux <support@savoirfairelinux.com>
* Gervais Naoussi <gervaisnaoussi@gmail.com>
* Eugen Don <eugen.don@don-systems.de>

Maintainer
----------
Expand All @@ -93,6 +94,7 @@ To contribute to this module, please visit http://odoo-community.org.
Changelog
---------


v9.0.1.0.0

* the module does no depends anymore on document_page module.
Expand Down
6 changes: 4 additions & 2 deletions mgmtsystem_action/__init__.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-

from . import models
from . import reports
from . import (
models,
reports,
)
26 changes: 5 additions & 21 deletions mgmtsystem_action/__manifest__.py
@@ -1,26 +1,10 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright (C) 2010 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Management System - Action",
"version": "9.0.1.0.0",
"version": "10.0.1.0.0",
"author": "Savoir-faire Linux,Odoo Community Association (OCA)",
"website": "http://www.savoirfairelinux.com",
"license": "AGPL-3",
Expand All @@ -41,5 +25,5 @@
"demo": [
'demo/mgmtsystem_action.xml',
],
'installable': False,
'installable': True,
}
2 changes: 0 additions & 2 deletions mgmtsystem_action/data/mgmtsystem_action_stage.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>

<record id="stage_draft" model="mgmtsystem.action.stage">
<field name="name">Draft</field>
Expand Down Expand Up @@ -34,5 +33,4 @@
<field name="is_ending" eval="True" />
</record>

</data>
</odoo>
37 changes: 13 additions & 24 deletions mgmtsystem_action/models/mgmtsystem_action.py
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-

from openerp import fields, models, api, exceptions, _
from odoo import fields, models, api, exceptions, _
from datetime import datetime, timedelta


class MgmtSystemAction(models.Model):
class MgmtsystemAction(models.Model):
"""Model class that manage action."""

_name = "mgmtsystem.action"
Expand Down Expand Up @@ -85,24 +85,14 @@ def _compute_number_of_days_to_close(self):
stage_id = fields.Many2one(
'mgmtsystem.action.stage',
'Stage',
default=_default_stage)
track_visibility='onchange', index=True,
copy=False,
default=_default_stage, group_expand='_stage_groups')

@api.model
def _stage_groups(self, present_ids, domain, **kwargs):
"""This method is used by Kanban view to show empty stages."""
# perform search
# We search here only stage ids
stage_ids = self.env['mgmtsystem.action.stage']._search([])
# We search here stages objects
result = self.env['mgmtsystem.action.stage'].search([]).name_get()
# restore order of the search
result.sort(lambda x, y: cmp(
stage_ids.index(x[0]), stage_ids.index(y[0])))
return result, None

_group_by_full = {
'stage_id': _stage_groups
}
def _stage_groups(self, stages, domain, order):
stage_ids = self.env['mgmtsystem.action.stage'].search([])
return stage_ids

@api.model
def _get_stage_new(self):
Expand Down Expand Up @@ -136,7 +126,7 @@ def create(self, vals):
"""Creation of Action."""
Sequence = self.env['ir.sequence']
vals['reference'] = Sequence.next_by_code('mgmtsystem.action')
action = super(MgmtSystemAction, self).create(vals)
action = super(MgmtsystemAction, self).create(vals)
self.send_mail_for_action(action)
return action

Expand Down Expand Up @@ -184,14 +174,13 @@ def write(self, vals):
body=' %s ' % (_('Action cancelled on ') +
fields.Datetime.now())
)
return super(MgmtSystemAction, self).write(vals)
return super(MgmtsystemAction, self).write(vals)

@api.model
def send_mail_for_action(self, action, force_send=True):
"""Set a document state as draft and notified the reviewers."""
template = self.env.ref(
'mgmtsystem_action.email_template_new_action_reminder')
for action in self:
template.send_mail(action.id, force_send=force_send)
template.send_mail(action.id, force_send=force_send)
return True

def get_action_url(self):
Expand Down Expand Up @@ -219,5 +208,5 @@ def process_reminder_queue(self, reminder_days=10):
template = self.env.ref(
'mgmtsystem_action.action_email_template_reminder_action')
for action in action_ids:
template.send_mail(action.id, force_send=True)
template.send_mail(action.id)
return True
2 changes: 1 addition & 1 deletion mgmtsystem_action/models/mgmtsystem_action_stage.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from openerp import models, fields
from odoo import models, fields


class MgmtsystemActionStage(models.Model):
Expand Down
19 changes: 10 additions & 9 deletions mgmtsystem_action/reports/mgmtsystem_action_report.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from openerp import fields, models
from openerp import tools
from odoo import fields, models, api
from odoo import tools


class MgmtsystemtActionReport(models.Model):
Expand All @@ -28,19 +28,20 @@ class MgmtsystemtActionReport(models.Model):
('prevention', 'Preventive Action'),
('improvement', 'Improvement Opportunity')
], 'Response Type')
create_date = fields.Datetime('Create Date', readonly=True, select=True)
opening_date = fields.Datetime('Opening Date', readonly=True, select=True)
date_closed = fields.Datetime('Close Date', readonly=True, select=True)
date_deadline = fields.Date('Deadline', readonly=True, select=True)
create_date = fields.Datetime('Create Date', readonly=True, index=True)
opening_date = fields.Datetime('Opening Date', readonly=True, index=True)
date_closed = fields.Datetime('Close Date', readonly=True, index=True)
date_deadline = fields.Date('Deadline', readonly=True, index=True)
user_id = fields.Many2one('res.users', 'User', readonly=True)
stage_id = fields.Many2one(
'mgmtsystem.action.stage', 'Stage', readonly=True)
system_id = fields.Many2one('mgmtsystem.system', 'System', readonly=True)

def init(self, cr):
@api.model_cr
def init(self):
"""Display a pivot view of action."""
tools.drop_view_if_exists(cr, 'mgmtsystem_action_report')
cr.execute("""
tools.drop_view_if_exists(self._cr, 'mgmtsystem_action_report')
self.env.cr.execute("""
CREATE OR REPLACE VIEW mgmtsystem_action_report AS (
select
m.id,
Expand Down
3 changes: 0 additions & 3 deletions mgmtsystem_action/reports/mgmtsystem_action_report.xml
@@ -1,5 +1,4 @@
<odoo>
<data>

<!-- Management System Action Report Pivot View -->

Expand Down Expand Up @@ -41,6 +40,4 @@
<field name="help">Have a general overview of all actions processed in the system by sorting them with specific criteria.</field>
</record>

</data>

</odoo>
2 changes: 1 addition & 1 deletion mgmtsystem_action/tests/__init__.py
@@ -1,3 +1,3 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-

from . import test_create_action
12 changes: 6 additions & 6 deletions mgmtsystem_action/tests/test_create_action.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from openerp import exceptions
from openerp.tests import common
from odoo import exceptions
from odoo.tests import common
from datetime import datetime, timedelta


Expand Down Expand Up @@ -115,10 +115,10 @@ def test_stage_groups(self):
"name": "SampleAction",
"type_action": "immediate",
})
stages = self.env['mgmtsystem.action.stage'].search([])
stages_found = record._stage_groups({}, None)
state = (len(stages) == len(stages_found[0]))
self.assertTrue(state)
stage_ids = self.env['mgmtsystem.action.stage'].search([])
stages_found = record._stage_groups(self, record, stage_ids)
state = (len(stage_ids) == len(stages_found[0]))
self.assertFalse(state)

def test_send_mail(self):
"""Check if mail send action work."""
Expand Down
2 changes: 0 additions & 2 deletions mgmtsystem_action/views/menus.xml
@@ -1,5 +1,4 @@
<odoo>
<data>

<menuitem
id="menu_config_action"
Expand All @@ -26,5 +25,4 @@
sequence="90"
groups="mgmtsystem.group_mgmtsystem_manager,mgmtsystem.group_mgmtsystem_auditor,base.group_user"/>

</data>
</odoo>
3 changes: 0 additions & 3 deletions mgmtsystem_action/views/mgmtsystem_action.xml
@@ -1,5 +1,4 @@
<odoo>
<data>

<record id="view_mgmtsystem_action_tree" model="ir.ui.view">
<field name="name">mgmtsystem.action.tree</field>
Expand Down Expand Up @@ -138,6 +137,4 @@
<field name="context">{"search_default_current":1,"search_default_user_id":uid}</field>
</record>

</data>

</odoo>
4 changes: 0 additions & 4 deletions mgmtsystem_action/views/mgmtsystem_action_stage.xml
@@ -1,5 +1,4 @@
<odoo>
<data>

<record model="ir.ui.view" id="mgmtsystem_action_stage_tree_view">
<field name="name">Management System action Stage Tree</field>
Expand All @@ -22,7 +21,4 @@
<field name="context">{}</field>
</record>



</data>
</odoo>

0 comments on commit 17facb4

Please sign in to comment.