Browse Source

[MIG] base_user_role: Migration to 11.0

14.0
Duc Dao 7 years ago
committed by Jesús Alan Ramos Rodríguez
parent
commit
961f983cd3
  1. 5
      base_user_role/README.rst
  2. 2
      base_user_role/__init__.py
  3. 5
      base_user_role/__manifest__.py
  4. 7
      base_user_role/data/ir_cron.xml
  5. 189
      base_user_role/i18n/base_user_role.pot
  6. 2
      base_user_role/models/__init__.py
  7. 25
      base_user_role/models/role.py
  8. 8
      base_user_role/models/user.py
  9. 2
      base_user_role/tests/__init__.py
  10. 16
      base_user_role/tests/test_user_role.py

5
base_user_role/README.rst

@ -1,5 +1,5 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
==========
@ -51,7 +51,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-tools/issues>`_. 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.
help us smash it by providing detailed and welcomed feedback.
Credits
=======
@ -65,6 +65,7 @@ Contributors
------------
* Sébastien Alix <sebastien.alix@osiell.com>
* Duc, Dao Dong <duc.dd@komit-consulting.com> (https://komit-consulting.com)
Maintainer
----------

2
base_user_role/__init__.py

@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import models

5
base_user_role/__manifest__.py

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2014 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'User roles',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Tools',
'author': 'ABF OSIELL, Odoo Community Association (OCA)',
'license': 'AGPL-3',
@ -15,8 +14,8 @@
],
'data': [
'security/ir.model.access.csv',
'data/ir_module_category.xml',
'data/ir_cron.xml',
'data/ir_module_category.xml',
'views/role.xml',
'views/user.xml',
],

7
base_user_role/data/ir_cron.xml

@ -9,9 +9,10 @@
<field name='interval_type'>hours</field>
<field name="numbercall">-1</field>
<field name="active">True</field>
<field name="doall" eval="False" />
<field name="model">res.users.role</field>
<field name="function">cron_update_users</field>
<field name="doall" eval="False"/>
<field name="model_id" ref="base_user_role.model_res_users_role"/>
<field name="state">code</field>
<field name="code">model.cron_update_users()</field>
<field name="args">()</field>
</record>

189
base_user_role/i18n/base_user_role.pot

@ -1,189 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_user_role
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-18 11:58+0000\n"
"PO-Revision-Date: 2016-11-18 11:58+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_user_role
#: field:res.users.role,model_access:0
msgid "Access Controls"
msgstr ""
#. module: base_user_role
#: field:res.users.role,menu_access:0
msgid "Access Menu"
msgstr ""
#. module: base_user_role
#: field:res.users.role.line,is_enabled:0
msgid "Enabled"
msgstr ""
#. module: base_user_role
#: field:res.users.role,category_id:0
msgid "Application"
msgstr ""
#. module: base_user_role
#: field:res.users.role,group_id:0
msgid "Associated group"
msgstr ""
#. module: base_user_role
#: field:res.users.role,comment:0
msgid "Comment"
msgstr ""
#. module: base_user_role
#: field:res.users.role,create_uid:0
#: field:res.users.role.line,create_uid:0
msgid "Created by"
msgstr ""
#. module: base_user_role
#: field:res.users.role,create_date:0
#: field:res.users.role.line,create_date:0
msgid "Created on"
msgstr ""
#. module: base_user_role
#: field:res.users.role,display_name:0
#: field:res.users.role.line,display_name:0
msgid "Display Name"
msgstr ""
#. module: base_user_role
#: field:res.users.role.line,date_from:0
msgid "From"
msgstr ""
#. module: base_user_role
#: field:res.users.role,full_name:0
msgid "Group Name"
msgstr ""
#. module: base_user_role
#: view:res.users.role:base_user_role.view_res_users_role_form
msgid "Groups"
msgstr ""
#. module: base_user_role
#: field:res.users.role,id:0
#: field:res.users.role.line,id:0
msgid "ID"
msgstr ""
#. module: base_user_role
#: field:res.users.role,implied_ids:0
msgid "Inherits"
msgstr ""
#. module: base_user_role
#: field:res.users.role,__last_update:0
#: field:res.users.role.line,__last_update:0
msgid "Last Modified on"
msgstr ""
#. module: base_user_role
#: field:res.users.role,write_uid:0
#: field:res.users.role.line,write_uid:0
msgid "Last Updated by"
msgstr ""
#. module: base_user_role
#: field:res.users.role,write_date:0
#: field:res.users.role.line,write_date:0
msgid "Last Updated on"
msgstr ""
#. module: base_user_role
#: field:res.users.role,name:0
msgid "Name"
msgstr ""
#. module: base_user_role
#: view:res.users.role:base_user_role.view_res_users_role_form
#: view:res.users.role:base_user_role.view_res_users_role_tree
#: field:res.users.role.line,role_id:0
msgid "Role"
msgstr ""
#. module: base_user_role
#: field:res.users,role_line_ids:0
msgid "Role lines"
msgstr ""
#. module: base_user_role
#: model:ir.actions.act_window,name:base_user_role.action_res_users_role_tree
#: model:ir.ui.menu,name:base_user_role.menu_action_res_users_role_tree
#: view:res.users:base_user_role.view_res_users_form_inherit
#: field:res.users,role_ids:0
#: view:res.users.role:base_user_role.view_res_users_role_search
msgid "Roles"
msgstr ""
#. module: base_user_role
#: field:res.users.role,rule_groups:0
msgid "Rules"
msgstr ""
#. module: base_user_role
#: field:res.users,scoring:0
msgid "Scoring (%)"
msgstr ""
#. module: base_user_role
#: field:res.users.role.line,date_to:0
msgid "To"
msgstr ""
#. module: base_user_role
#: field:res.users.role,trans_implied_ids:0
msgid "Transitively inherits"
msgstr ""
#. module: base_user_role
#: field:res.users.role.line,user_id:0
msgid "User"
msgstr ""
#. module: base_user_role
#: model:ir.model,name:base_user_role.model_res_users_role
msgid "User role"
msgstr ""
#. module: base_user_role
#: model:ir.model,name:base_user_role.model_res_users
#: view:res.users.role:base_user_role.view_res_users_role_form
#: field:res.users.role,line_ids:0
#: field:res.users.role,user_ids:0
#: field:res.users.role,users:0
msgid "Users"
msgstr ""
#. module: base_user_role
#: model:ir.model,name:base_user_role.model_res_users_role_line
msgid "Users associated to a role"
msgstr ""
#. module: base_user_role
#: help:res.users.role,implied_ids:0
msgid "Users of this group automatically inherit those groups"
msgstr ""
#. module: base_user_role
#: field:res.users.role,view_access:0
msgid "Views"
msgstr ""

2
base_user_role/models/__init__.py

@ -1,4 +1,2 @@
# -*- coding: utf-8 -*-
from . import role
from . import user

25
base_user_role/models/role.py

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2014 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import datetime
import logging
@ -17,12 +15,14 @@ class ResUsersRole(models.Model):
_description = "User role"
group_id = fields.Many2one(
'res.groups', required=True, ondelete='cascade',
readonly=True, string=u"Associated group")
comodel_name='res.groups', required=True, ondelete='cascade',
readonly=True, string="Associated group")
line_ids = fields.One2many(
'res.users.role.line', 'role_id', string=u"Users")
comodel_name='res.users.role.line',
inverse_name='role_id', string="Users")
user_ids = fields.One2many(
'res.users', string=u"Users", compute='_compute_user_ids')
comodel_name='res.users', string="Users",
compute='_compute_user_ids')
group_category_id = fields.Many2one(
related='group_id.category_id',
default=lambda cls: cls.env.ref(
@ -55,7 +55,7 @@ class ResUsersRole(models.Model):
@api.model
def cron_update_users(self):
logging.info(u"Update user roles")
logging.info("Update user roles")
self.search([]).update_users()
@ -64,12 +64,13 @@ class ResUsersRoleLine(models.Model):
_description = 'Users associated to a role'
role_id = fields.Many2one(
'res.users.role', string=u"Role", ondelete='cascade')
comodel_name='res.users.role', string="Role",
ondelete='cascade')
user_id = fields.Many2one(
'res.users', string=u"User")
date_from = fields.Date(u"From")
date_to = fields.Date(u"To")
is_enabled = fields.Boolean(u"Enabled", compute='_compute_is_enabled')
comodel_name='res.users', string="User")
date_from = fields.Date("From")
date_to = fields.Date("To")
is_enabled = fields.Boolean("Enabled", compute='_compute_is_enabled')
@api.multi
@api.depends('date_from', 'date_to')

8
base_user_role/models/user.py

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2014 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
@ -9,9 +7,11 @@ class ResUsers(models.Model):
_inherit = 'res.users'
role_line_ids = fields.One2many(
'res.users.role.line', 'user_id', string=u"Role lines")
comodel_name='res.users.role.line',
inverse_name='user_id', string="Role lines")
role_ids = fields.One2many(
'res.users.role', string=u"Roles", compute='_compute_role_ids')
comodel_name='res.users.role', string="Roles",
compute='_compute_role_ids')
@api.multi
@api.depends('role_line_ids.role_id')

2
base_user_role/tests/__init__.py

@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import test_user_role

16
base_user_role/tests/test_user_role.py

@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2014 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import datetime
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo import fields
from odoo.tests.common import TransactionCase
@ -16,13 +14,13 @@ class TestUserRole(TransactionCase):
self.role_model = self.env['res.users.role']
self.user_id = self.user_model.create(
{'name': u"USER TEST (ROLES)", 'login': 'user_test_roles'})
{'name': "USER TEST (ROLES)", 'login': 'user_test_roles'})
# ROLE_1
self.group_user_id = self.env.ref('base.group_user')
self.group_no_one_id = self.env.ref('base.group_no_one')
vals = {
'name': u"ROLE_1",
'name': "ROLE_1",
'implied_ids': [
(6, 0, [self.group_user_id.id, self.group_no_one_id.id])],
}
@ -33,7 +31,7 @@ class TestUserRole(TransactionCase):
'base.group_multi_currency')
self.group_settings_id = self.env.ref('base.group_system')
vals = {
'name': u"ROLE_2",
'name': "ROLE_2",
'implied_ids': [
(6, 0, [self.group_multi_currency_id.id,
self.group_settings_id.id])],
@ -76,10 +74,10 @@ class TestUserRole(TransactionCase):
self.assertEqual(user_group_ids, role_group_ids)
def test_role_1_2_with_dates(self):
today = datetime.date.today()
today_str = today.strftime(DEFAULT_SERVER_DATE_FORMAT)
today_str = fields.Date.today()
today = fields.Date.from_string(today_str)
yesterday = today - datetime.timedelta(days=1)
yesterday_str = yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)
yesterday_str = fields.Date.to_string(yesterday)
self.user_id.write(
{'role_line_ids': [
# Role 1 should be enabled

Loading…
Cancel
Save