[IMP] base_action_rule: when using a timed condition on days, allow to use a working calendar to compute days.
bzr revid: tde@openerp.com-20130821105127-182i9f7mzkoo4cf0
This commit is contained in:
parent
a67459018c
commit
4923499534
|
@ -35,7 +35,7 @@ trigger an automatic reminder email.
|
||||||
""",
|
""",
|
||||||
'author': 'OpenERP SA',
|
'author': 'OpenERP SA',
|
||||||
'website': 'http://www.openerp.com',
|
'website': 'http://www.openerp.com',
|
||||||
'depends': ['base', 'mail'],
|
'depends': ['base', 'resource', 'mail'],
|
||||||
'data': [
|
'data': [
|
||||||
'base_action_rule_view.xml',
|
'base_action_rule_view.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
|
|
@ -74,6 +74,11 @@ class base_action_rule(osv.osv):
|
||||||
"trigger date, like sending a reminder 15 minutes before a meeting."),
|
"trigger date, like sending a reminder 15 minutes before a meeting."),
|
||||||
'trg_date_range_type': fields.selection([('minutes', 'Minutes'), ('hour', 'Hours'),
|
'trg_date_range_type': fields.selection([('minutes', 'Minutes'), ('hour', 'Hours'),
|
||||||
('day', 'Days'), ('month', 'Months')], 'Delay type'),
|
('day', 'Days'), ('month', 'Months')], 'Delay type'),
|
||||||
|
'trg_date_calendar_id': fields.many2one(
|
||||||
|
'resource.calendar', 'Use Calendar',
|
||||||
|
help='When calculating a day-based timed condition, it is possible to use a calendar to compute the date based on working days.',
|
||||||
|
ondelete='set null',
|
||||||
|
),
|
||||||
'act_user_id': fields.many2one('res.users', 'Set Responsible'),
|
'act_user_id': fields.many2one('res.users', 'Set Responsible'),
|
||||||
'act_followers': fields.many2many("res.partner", string="Add Followers"),
|
'act_followers': fields.many2many("res.partner", string="Add Followers"),
|
||||||
'server_action_ids': fields.many2many('ir.actions.server', string='Server Actions',
|
'server_action_ids': fields.many2many('ir.actions.server', string='Server Actions',
|
||||||
|
@ -268,7 +273,14 @@ class base_action_rule(osv.osv):
|
||||||
record_dt = get_record_dt(record)
|
record_dt = get_record_dt(record)
|
||||||
if not record_dt:
|
if not record_dt:
|
||||||
continue
|
continue
|
||||||
action_dt = get_datetime(record_dt) + delay
|
if action.trg_date_calendar_id and action.trg_date_range_type == 'day':
|
||||||
|
start_dt = get_datetime(record_dt)
|
||||||
|
action_dt = self.pool['resource.calendar'].schedule_days(
|
||||||
|
cr, uid, action.trg_date_calendar_id.id, action.trg_date_range,
|
||||||
|
date=start_dt, compute_leaves=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
action_dt = get_datetime(record_dt) + delay
|
||||||
if last_run and (last_run <= action_dt < now) or (action_dt < now):
|
if last_run and (last_run <= action_dt < now) or (action_dt < now):
|
||||||
try:
|
try:
|
||||||
self._process(cr, uid, action, [record.id], context=context)
|
self._process(cr, uid, action, [record.id], context=context)
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
<field name="trg_date_range" class="oe_inline"/>
|
<field name="trg_date_range" class="oe_inline"/>
|
||||||
<field name="trg_date_range_type" class="oe_inline" attrs="{'required': [('trg_date_id','!=',False)]}"/>
|
<field name="trg_date_range_type" class="oe_inline" attrs="{'required': [('trg_date_id','!=',False)]}"/>
|
||||||
</div>
|
</div>
|
||||||
|
<field name="trg_date_calendar_id" class="oe_inline"
|
||||||
|
attrs="{'invisible': ['|', ('trg_date_id','=',False), ('trg_date_range_type', '!=', 'day')]}"/>
|
||||||
</group>
|
</group>
|
||||||
<p>
|
<p>
|
||||||
Select when the action must be run, and add filters and/or timing conditions.
|
Select when the action must be run, and add filters and/or timing conditions.
|
||||||
|
|
Loading…
Reference in New Issue