mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-24 17:38:42 -06:00
Migration to new api improved in model's file and data tag remove in xml file
This commit is contained in:
parent
14a88d9554
commit
8626a02aef
@ -1,22 +1,3 @@
|
|||||||
"""Data models initialisation."""
|
"""Data models initialisation."""
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2013 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/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
from . import document_page_approval, document_page_history_workflow
|
from . import document_page_approval, document_page_history_workflow
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp import models, fields
|
from openerp import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
class DocumentPageApproval(models.Model):
|
class DocumentPageApproval(models.Model):
|
||||||
@ -27,6 +27,7 @@ class DocumentPageApproval(models.Model):
|
|||||||
|
|
||||||
_inherit = 'document.page'
|
_inherit = 'document.page'
|
||||||
|
|
||||||
|
@api.multi
|
||||||
def _get_display_content(self):
|
def _get_display_content(self):
|
||||||
"""Display the content of document."""
|
"""Display the content of document."""
|
||||||
for page in self:
|
for page in self:
|
||||||
@ -49,6 +50,7 @@ class DocumentPageApproval(models.Model):
|
|||||||
content = page.content
|
content = page.content
|
||||||
page.display_content = content
|
page.display_content = content
|
||||||
|
|
||||||
|
@api.multi
|
||||||
def _get_approved_date(self):
|
def _get_approved_date(self):
|
||||||
"""Return the approved date of a document."""
|
"""Return the approved date of a document."""
|
||||||
for page in self:
|
for page in self:
|
||||||
@ -66,6 +68,7 @@ class DocumentPageApproval(models.Model):
|
|||||||
approved_date = history_ids.approved_date
|
approved_date = history_ids.approved_date
|
||||||
page.approved_date = approved_date
|
page.approved_date = approved_date
|
||||||
|
|
||||||
|
@api.multi
|
||||||
def _get_approved_uid(self):
|
def _get_approved_uid(self):
|
||||||
"""Return the user's id of the approved user."""
|
"""Return the user's id of the approved user."""
|
||||||
for page in self:
|
for page in self:
|
||||||
|
@ -30,40 +30,39 @@ class DocumentPageHistoryWorkflow(models.Model):
|
|||||||
|
|
||||||
_inherit = 'document.page.history'
|
_inherit = 'document.page.history'
|
||||||
|
|
||||||
def page_approval_draft(self, cr, uid, ids, context=None):
|
def page_approval_draft(self):
|
||||||
"""Set a document state as draft and notified the reviewers."""
|
"""Set a document state as draft and notified the reviewers."""
|
||||||
self.write(cr, uid, ids, {'state': 'draft'})
|
self.write({'state': 'draft'})
|
||||||
template_id = self.pool.get('ir.model.data').get_object_reference(
|
template_id = self.pool.get('ir.model.data').get_object_reference(
|
||||||
cr, uid,
|
self.env.cr, self.env.uid,
|
||||||
'document_page_approval',
|
'document_page_approval',
|
||||||
'email_template_new_draft_need_approval')[1]
|
'email_template_new_draft_need_approval')[1]
|
||||||
for page in self.browse(cr, uid, ids, context=context):
|
for page in self:
|
||||||
if page.is_parent_approval_required:
|
if page.is_parent_approval_required:
|
||||||
self.pool.get('mail.template').send_mail(
|
self.pool.get('mail.template').send_mail(
|
||||||
cr,
|
self.env.cr, self.env.uid,
|
||||||
uid,
|
|
||||||
template_id,
|
template_id,
|
||||||
page.id,
|
page.id,
|
||||||
force_send=True
|
force_send=True
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def page_approval_approved(self, cr, uid, ids, context=None):
|
def page_approval_approved(self):
|
||||||
"""Set a document state as approve."""
|
"""Set a document state as approve."""
|
||||||
model_data_obj = self.pool.get('ir.model.data')
|
model_data_obj = self.pool.get('ir.model.data')
|
||||||
message_obj = self.pool.get('mail.message')
|
message_obj = self.pool.get('mail.message')
|
||||||
self.write(cr, uid, ids, {
|
self.write({
|
||||||
'state': 'approved',
|
'state': 'approved',
|
||||||
'approved_date': datetime.now().strftime(
|
'approved_date': datetime.now().strftime(
|
||||||
DEFAULT_SERVER_DATETIME_FORMAT),
|
DEFAULT_SERVER_DATETIME_FORMAT),
|
||||||
'approved_uid': uid
|
'approved_uid': self.env.uid
|
||||||
}, context=context)
|
})
|
||||||
# Notify followers a new version is available
|
# Notify followers a new version is available
|
||||||
for page_history in self.browse(cr, uid, ids, context=context):
|
for page_history in self:
|
||||||
subtype_id = model_data_obj.get_object_reference(
|
subtype_id = model_data_obj.get_object_reference(
|
||||||
cr, SUPERUSER_ID, 'mail', 'mt_comment')[1]
|
self.env.cr, SUPERUSER_ID, 'mail', 'mt_comment')[1]
|
||||||
message_obj.create(
|
message_obj.create(
|
||||||
cr, uid,
|
self.env.cr, self.env.uid,
|
||||||
{'res_id': page_history.page_id.id,
|
{'res_id': page_history.page_id.id,
|
||||||
'model': 'document.page',
|
'model': 'document.page',
|
||||||
'subtype_id': subtype_id,
|
'subtype_id': subtype_id,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""DocumentPageApproval test."""
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from openerp.tests import common
|
from openerp.tests import common
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""DocumentPageApproval test."""
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from openerp.tests import common
|
from openerp.tests import common
|
||||||
# Import logger
|
# Import logger
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
|
||||||
<record id="wiki_history_form_inherit" model="ir.ui.view">
|
<record id="wiki_history_form_inherit" model="ir.ui.view">
|
||||||
<field name="name">document.page.history.form</field>
|
<field name="name">document.page.history.form</field>
|
||||||
<field name="model">document.page.history</field>
|
<field name="model">document.page.history</field>
|
||||||
@ -89,5 +88,4 @@
|
|||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
|
||||||
|
|
||||||
<record model="workflow" id="wkf_document_page_history_aproval">
|
<record model="workflow" id="wkf_document_page_history_aproval">
|
||||||
<field name="name">document.page.history.aproval.wkf</field>
|
<field name="name">document.page.history.aproval.wkf</field>
|
||||||
<field name="osv">document.page.history</field>
|
<field name="osv">document.page.history</field>
|
||||||
@ -37,7 +35,4 @@
|
|||||||
<field name="act_to" ref="act_draft" />
|
<field name="act_to" ref="act_draft" />
|
||||||
<field name="signal">edit</field>
|
<field name="signal">edit</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
Loading…
Reference in New Issue
Block a user