<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


class account_invoice_line(orm.Model):
    """ We add a field for gift instructions. """
    _inherit = "account.invoice.line"

    def _get_gift_info(self, cr, uid, ids, field_name, args, context=None):
        res = dict()
        for inv_line in self.browse(cr, uid, ids, context):
            if field_name == 'need_key':
                need_key = inv_line.contract_id.child_code
                if inv_line.product_id.gmc_name == 'ProjectGift':
                    need_key = need_key[:5]
                res[inv_line.id] = need_key
        return res

    def get_gift_details(self, cr, uid, line_id, context=None):
        # TODO : See with Stuart if we can remove this method
        inv_line = self.browse(cr, uid, line_id, context)
        need_key = inv_line.contract_id.child_code
        if inv_line.product_id.gmc_name == 'ProjectGift':
            need_key = need_key[:5]
        res = {
            'ConstituentId': inv_line.partner_id.id,
            'NeedKey': inv_line.contract_id.child_code,
            'GiftType': inv_line.product_id.gmc_name,
            'GiftAmount': inv_line.price_subtotal,
            'GiftInstructions': inv_line.gift_instructions,
            'TransactionDate': inv_line.invoice_id.date_invoice
        }
        return res

    def _get_instructions(self, cr, uid, ids, field, args, context=None):
        res = dict()
        ctx = context.copy()
        for inv_line in self.browse(cr, uid, ids, {'lang': 'en_US'}):
            ctx['lang'] = inv_line.partner_id.lang<commit_msg>Removed useless method for CreateGift.<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


class account_invoice_line(orm.Model):
    """ We add a field for gift instructions. """
    _inherit = "account.invoice.line"

    def _get_gift_info(self, cr, uid, ids, field_name, args, context=None):
        res = dict()
        for inv_line in self.browse(cr, uid, ids, context):
            if field_name == 'need_key':
                need_key = inv_line.contract_id.child_code
                if inv_line.product_id.gmc_name == 'ProjectGift':
                    need_key = need_key[:5]
                res[inv_line.id] = need_key
        return res

    def _get_instructions(self, cr, uid, ids, field, args, context=None):
        res = dict()
        ctx = context.copy()
        for inv_line in self.browse(cr, uid, ids, {'lang': 'en_US'}):
            ctx['lang'] = inv_line.partner_id.lang
{'fraction_non_alphanumeric': 0.20147420147420148, 'fraction_numerical': 0.006449631449631449, 'mean_word_length': 2.8317647058823527, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '246238', 'n_tokens_mistral': 1023, 'n_tokens_neox': 970, 'n_words': 236}