<commit_before># -*- encoding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2014-2015 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __openerp__.py
#
##############################################################################

from openerp.osv import orm, fields
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DF
from openerp.tools.translate import _

from datetime import datetime


class project_compassion(orm.Model):
    _inherit = 'compassion.project'

    def suspend_funds(self, cr, uid, project_id, context=None,
                      date_start=None, date_end=None):
        """ When a project is suspended, We update all contracts of
        sponsored children in the project, so that we don't create invoices
        during the period of suspension.
        We also remove the children on internet.
        """
        project = self.browse(cr, uid, project_id, context)
        contract_obj = self.pool.get('recurring.contract')
        contract_ids = contract_obj.search(cr, uid, [
            ('child_code', 'like', project.code),
            ('state', 'in', ('active', 'waiting', 'mandate'))],
            context=context)
        contract_obj.suspend_contract(cr, uid, contract_ids, context,
                                      date_start, date_end)
        return True


class suspension_wizard(orm.TransientModel):
    """ Wizard to extend suspensions of projects. """
    _name = 'compassion.project.suspension.wizard'

    _columns = {
        'date_start': fields.date(_('Start of suspension')),
        'date_end': fields.date(_('End of suspension'),
                                help=_("will add 3 months if empty")),
    }

    _defaults = {
        'date_start': datetime.today().strftime(DF)<commit_msg>Set start_date by default to last status update in suspension wizard.<commit_after># -*- encoding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2014-2015 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __openerp__.py
#
##############################################################################

from openerp.osv import orm, fields
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as DF
from openerp.tools.translate import _

from datetime import datetime


class project_compassion(orm.Model):
    _inherit = 'compassion.project'

    def suspend_funds(self, cr, uid, project_id, context=None,
                      date_start=None, date_end=None):
        """ When a project is suspended, We update all contracts of
        sponsored children in the project, so that we don't create invoices
        during the period of suspension.
        We also remove the children on internet.
        """
        project = self.browse(cr, uid, project_id, context)
        contract_obj = self.pool.get('recurring.contract')
        contract_ids = contract_obj.search(cr, uid, [
            ('child_code', 'like', project.code),
            ('state', 'in', ('active', 'waiting', 'mandate'))],
            context=context)
        contract_obj.suspend_contract(cr, uid, contract_ids, context,
                                      date_start, date_end)
        return True


class suspension_wizard(orm.TransientModel):
    """ Wizard to extend suspensions of projects. """
    _name = 'compassion.project.suspension.wizard'

    _columns = {
        'date_start': fields.date(_('Start of suspension')),
        'date_end': fields.date(_('End of suspension'),
                                help=_("will add 3 months if empty")),
    }

    def _get_start_date(self, cr, uid, context=None):
        project = self.pool.get('compassion.project').browse(
            cr, uid, context.get('active_id'), context)
        if project:
            return project.status_date
        else:
            return datetime.today().strftime(DF)

    _defaults = {
        'date_start': _get_start_date
{'fraction_non_alphanumeric': 0.17507773259985648, 'fraction_numerical': 0.004783544606553456, 'mean_word_length': 2.893854748603352, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3220500', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1095, 'n_words': 315}