<commit_before># -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in module root
# directory
##############################################################################


from openerp.osv import fields, osv
from openerp import _


class contract_cancelled_wizard(osv.osv_memory):
    _name = 'contract_cancelled_wizard'
    _description = 'Wizard to cancel contract'

    _columns = {
        'end_date': fields.date(string='Cancellation Date', required=True),
        'end_code': fields.char(string='Cancellation Number', required=True),
        'cancellation_note': fields.text(string='Cancellation Notes'),
    }

    _defaults = {
    }

    def contract_cancelled_wizard(self, cr, uid, ids, context=None):
        wizard = self.browse(cr, uid, ids)[0]
        active_id = context.get('active_id', False)
        contract_obj = self.pool.get('nautical.contract')
        craft_obj = self.pool.get('nautical.craft')
        contract_id = contract_obj.search(
            cr, uid, [('craft_id', '=', active_id), ('state', '=', 'contracted')],
            order='id desc',
            context=context)[0]
        if active_id:
            end_date = wizard.end_date
            end_code = wizard.end_code
            cancellation_note = wizard.cancellation_note
            contract_vals = {'end_date': end_date, 'end_code': end_code,
                             'cancellation_note': cancellation_note, 'state': 'permanent_cancellation'}
            contract_obj.write(
                cr, uid, contract_id, contract_vals, context=context)
            # Empty locations
            craft_obj.write(cr, uid, active_id, {
                            'location_ids': [(5, 0)], 'state': 'permanent_cancellation'}, context=context)


        return True<commit_msg>FIX search funtion<commit_after># -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in module root
# directory
##############################################################################


from openerp.osv import fields, osv
from openerp import _


class contract_cancelled_wizard(osv.osv_memory):
    _name = 'contract_cancelled_wizard'
    _description = 'Wizard to cancel contract'

    _columns = {
        'end_date': fields.date(string='Cancellation Date', required=True),
        'end_code': fields.char(string='Cancellation Number', required=True),
        'cancellation_note': fields.text(string='Cancellation Notes'),
    }

    _defaults = {
    }

    def contract_cancelled_wizard(self, cr, uid, ids, context=None):
        wizard = self.browse(cr, uid, ids)[0]
        active_id = context.get('active_id', False)
        contract_obj = self.pool.get('nautical.contract')
        craft_obj = self.pool.get('nautical.craft')
        contract_id = contract_obj.search(
            cr, uid, [('craft_id', '=', active_id),
                      ('state', '=', 'contracted')],
            order='id desc',
            context=context, limit=1)
        if active_id:
            end_date = wizard.end_date
            end_code = wizard.end_code
            cancellation_note = wizard.cancellation_note
            contract_vals = {
                'end_date': end_date, 'end_code': end_code,
                'cancellation_note': cancellation_note,
                'state': 'permanent_cancellation'}
            contract_obj.write(
                cr, uid, contract_id, contract_vals, context=context)
            # Empty locations
            craft_obj.write(cr, uid, active_id,
                            {'location_ids': [(5, 0)],
                             'state': 'permanent_cancellation'},
                            context=context)

        return True
{'fraction_non_alphanumeric': 0.18633540372670807, 'fraction_numerical': 0.002587991718426501, 'mean_word_length': 2.7056567593480345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2642532', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1062, 'n_words': 220}