[REF] base_action_rule: reorganized module directory

We keep tests models in tests/ directory because
these models are not pertinents for business.
The rest of the directory follows the guidelines.
This commit is contained in:
vbh-odoo
2016-04-21 14:52:49 +02:00
committed by Jérome Maes
parent 8ddb6c23a9
commit 245f2f9101
11 changed files with 48 additions and 7 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import base_action_rule
import test_models
import models
import tests
+3 -3
View File
@@ -17,12 +17,12 @@ trigger an automatic reminder email.
""",
'depends': ['base', 'resource', 'mail'],
'data': [
'base_action_rule_data.xml',
'base_action_rule_view.xml',
'data/base_action_rule_data.xml',
'views/base_action_rule_view.xml',
'security/ir.model.access.csv',
],
'demo': [
'base_action_rule_demo.xml',
'data/base_action_rule_demo.xml',
],
'installable': True,
'auto_install': False,
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import base_action_rule
+2 -1
View File
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_base_action_rule
import test_models
import test_base_action_rule
@@ -1,6 +1,6 @@
from openerp import SUPERUSER_ID
from openerp.tests import common
from .. import test_models
@common.at_install(False)
@common.post_install(True)
+36
View File
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp.fields import Datetime
from openerp.osv import fields, osv
class base_action_rule(osv.Model):
""" Add resource and calendar for time-based conditions """
_name = 'base.action.rule'
_inherit = ['base.action.rule']
_columns = {
'trg_date_resource_field_id': fields.many2one(
'ir.model.fields', 'Use employee work schedule',
help='Use the user\'s working schedule.',
),
}
def _check_delay(self, cr, uid, action, record, record_dt, context=None):
""" Override the check of delay to try to use a user-related calendar.
If no calendar is found, fallback on the default behavior. """
if action.trg_date_calendar_id and action.trg_date_range_type == 'day' and action.trg_date_resource_field_id:
user = record[action.trg_date_resource_field_id.name]
if user.employee_ids and user.employee_ids[0].contract_id \
and user.employee_ids[0].contract_id.working_hours:
calendar = user.employee_ids[0].contract_id.working_hours
start_dt = Datetime.from_string(record_dt)
resource_id = user.employee_ids[0].resource_id.id
action_dt = self.pool['resource.calendar'].schedule_days_get_date(
cr, uid, calendar.id, action.trg_date_range,
day_date=start_dt, compute_leaves=True, resource_id=resource_id,
context=context
)
return action_dt
return super(base_action_rule, self)._check_delay(cr, uid, action, record, record_dt, context=context)