[IMP]CRM Action : change date from date to datetime (handling data migration)
This commit is contained in:
parent
7904c0f996
commit
98a83a2f6c
@ -18,7 +18,7 @@
|
|||||||
{
|
{
|
||||||
'name': 'CRM Actions',
|
'name': 'CRM Actions',
|
||||||
'summary': 'Action management, instead of new activity, in CRM',
|
'summary': 'Action management, instead of new activity, in CRM',
|
||||||
'version': '10.0.1.0.0',
|
'version': '10.0.1.1.0',
|
||||||
'category': 'Sales',
|
'category': 'Sales',
|
||||||
'author': 'Fabien BOURGEOIS - Yaltik',
|
'author': 'Fabien BOURGEOIS - Yaltik',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
27
yaltik_crm_action/migrations/10.0.1.1.0/post-migrate.py
Normal file
27
yaltik_crm_action/migrations/10.0.1.1.0/post-migrate.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2017 Fabien Bourgeois <fabien@yaltik.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/>.
|
||||||
|
|
||||||
|
""" Migration script """
|
||||||
|
|
||||||
|
from openupgradelib import openupgrade
|
||||||
|
|
||||||
|
@openupgrade.migrate(use_env=True)
|
||||||
|
def migrate(env, version):
|
||||||
|
""" Migration function : migrate Date date to datetime """
|
||||||
|
openupgrade.date_to_datetime_tz(env.cr, 'crm_action', 'user_id',
|
||||||
|
'date_bak', 'date')
|
||||||
|
openupgrade.drop_columns(env.cr, [('crm_action', 'date_bak')])
|
25
yaltik_crm_action/migrations/10.0.1.1.0/pre-migrate.py
Normal file
25
yaltik_crm_action/migrations/10.0.1.1.0/pre-migrate.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2017 Fabien Bourgeois <fabien@yaltik.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/>.
|
||||||
|
|
||||||
|
""" Migration script """
|
||||||
|
|
||||||
|
from openupgradelib import openupgrade
|
||||||
|
|
||||||
|
@openupgrade.migrate()
|
||||||
|
def migrate(env, version):
|
||||||
|
""" Migration function : copy old Date date to legacy column """
|
||||||
|
openupgrade.copy_columns(env.cr, {'crm_action': [('date', 'date_bak', None)]})
|
@ -39,13 +39,14 @@ class CrmAction(models.Model):
|
|||||||
details = fields.Text()
|
details = fields.Text()
|
||||||
|
|
||||||
partner_id = fields.Many2one('res.partner', string='Customer', index=True)
|
partner_id = fields.Many2one('res.partner', string='Customer', index=True)
|
||||||
date = fields.Date('Date', required=True, default=fields.Date.context_today)
|
date = fields.Datetime('Date', required=True, default=fields.Date.context_today)
|
||||||
user_id = fields.Many2one('res.users', string='User', required=True,
|
user_id = fields.Many2one('res.users', string='User', required=True,
|
||||||
default=lambda self: self.env.user)
|
default=lambda self: self.env.user)
|
||||||
lead_id = fields.Many2one('crm.lead', string='Lead', ondelete='cascade')
|
lead_id = fields.Many2one('crm.lead', string='Lead', ondelete='cascade')
|
||||||
event_id = fields.Many2one('calendar.event', 'Calendar event', ondelete='cascade')
|
event_id = fields.Many2one('calendar.event', 'Calendar event', ondelete='cascade')
|
||||||
action_type_id = fields.Many2one('crm.action.type', string='Type', required=True,
|
action_type_id = fields.Many2one(
|
||||||
default=lambda self: self.env['crm.action.type'].search([], limit=1))
|
'crm.action.type', string='Type', required=True,
|
||||||
|
default=lambda self: self.env['crm.action.type'].search([], limit=1))
|
||||||
action_type_name = fields.Char(related='action_type_id.name')
|
action_type_name = fields.Char(related='action_type_id.name')
|
||||||
|
|
||||||
@api.onchange('lead_id')
|
@api.onchange('lead_id')
|
||||||
|
@ -29,7 +29,7 @@ class CrmLead(models.Model):
|
|||||||
action_ids = fields.One2many('crm.action', 'lead_id', string='Actions')
|
action_ids = fields.One2many('crm.action', 'lead_id', string='Actions')
|
||||||
next_action_id = fields.Many2one('crm.action', string='Next Action',
|
next_action_id = fields.Many2one('crm.action', string='Next Action',
|
||||||
compute='compute_next_action', store=True)
|
compute='compute_next_action', store=True)
|
||||||
next_action_date = fields.Date(related='next_action_id.date', store=True)
|
next_action_date = fields.Datetime(related='next_action_id.date', store=True)
|
||||||
next_action_title = fields.Char(related='next_action_id.display_name', store=True)
|
next_action_title = fields.Char(related='next_action_id.display_name', store=True)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user