<commit_before># -*- coding: utf-8 -*-
#########################################################################
#                                                                       #
#                                                                       #
#########################################################################
#                                                                       #
# Copyright (C) 2009-2011  Akretion, <NAME>, <NAME>, 	#
# <NAME>, <NAME>                                        #
#                                                                       #
#This program is free software: you can redistribute it and/or modify   #
#it under the terms of the GNU 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 General Public License for more details.                           #
#                                                                       #
#You should have received a copy of the GNU General Public License      #
#along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
#########################################################################

from osv import fields, osv

class account_invoice(osv.osv):

    _inherit = "account.invoice"


    _columns = {
        'claim_id': fields.many2one('crm.claim', 'Claim'),
    }

    def _get_cleanup_fields(self, cr, uid, context=None):
        fields = super(account_invoice, self)._get_cleanup_fields(cr, uid, context=context)
        list_fields = list(fields)
        list_fields.append('claim_line_id')
        fields = tuple(list_fields)
        return fields

    def _refund_cleanup_lines(self, cr, uid, lines, context=None):
        new_lines = []
        if context.get('claim_line_ids') and lines and 'product_id' in lines[0]:#check if is an invoice_line
            for claim_line_id in context.get('claim_line_ids'):
                claim_info = self.pool.get('claim.line').read(cr, uid, claim_line_id[1], ['invoice_line_id', 'product_returned_quantity'], context=context)
                invoice_line_info = self.pool.get('account.invoice.line').read(cr, uid, claim_info['invoice_line_id'][0], context=context)
                invoice_line_info['quantity'] = claim_info['product_returned_quantity']
                invoice_line_info['claim_line_id'] = claim_line_id
                new_lines.append(invoice_line_info)
            lines = new_lines
        result = super(account_invoice, self)._refund_cleanup_lines(cr, uid, lines, context=context)
        return result

    def _prepare_refund(self, cr, uid, *args, **kwargs):
        result = super(account_invoice, self)._prepare_refund(cr, uid, *args, **kwargs)
        if kwargs.get('context') and kwargs['context'].get('claim_id'):
            result['claim_id'] = kwargs['context']['claim_id']
        return result

class account_invoice_line(osv.osv):<commit_msg>[FIX] remove useless code <commit_after># -*- coding: utf-8 -*-
#########################################################################
#                                                                       #
#                                                                       #
#########################################################################
#                                                                       #
# Copyright (C) 2009-2011  Akretion, <NAME>, <NAME>, 	#
# <NAME>, <NAME>                                        #
#                                                                       #
#This program is free software: you can redistribute it and/or modify   #
#it under the terms of the GNU 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 General Public License for more details.                           #
#                                                                       #
#You should have received a copy of the GNU General Public License      #
#along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
#########################################################################

from osv import fields, osv

class account_invoice(osv.osv):

    _inherit = "account.invoice"


    _columns = {
        'claim_id': fields.many2one('crm.claim', 'Claim'),
    }

    def _get_cleanup_fields(self, cr, uid, context=None):
        fields = super(account_invoice, self)._get_cleanup_fields(cr, uid, context=context)
        fields = fields + ('claim_line_id',)
        return fields

    def _refund_cleanup_lines(self, cr, uid, lines, context=None):
        if context is None ; context = {}
        new_lines = []
        if context.get('claim_line_ids') and lines and 'product_id' in lines[0]:#check if is an invoice_line
            for claim_line_id in context.get('claim_line_ids'):
                claim_info = self.pool.get('claim.line').read(cr, uid, claim_line_id[1], ['invoice_line_id', 'product_returned_quantity'], context=context)
                invoice_line_info = self.pool.get('account.invoice.line').read(cr, uid, claim_info['invoice_line_id'][0], context=context)
                invoice_line_info['quantity'] = claim_info['product_returned_quantity']
                invoice_line_info['claim_line_id'] = claim_line_id
                new_lines.append(invoice_line_info)
            lines = new_lines
        result = super(account_invoice, self)._refund_cleanup_lines(cr, uid, lines, context=context)
        return result

    def _prepare_refund(self, cr, uid, *args, **kwargs):
        result = super(account_invoice, self)._prepare_refund(cr, uid, *args, **kwargs)
        if kwargs.get('context') and kwargs['context'].get('claim_id'):
            result['claim_id'] = kwargs['context']['claim_id']
        return result

class account_invoice_line(osv.osv):
{'fraction_non_alphanumeric': 0.1574228840601732, 'fraction_numerical': 0.004254672542166844, 'mean_word_length': 1.946284691136974, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6696885', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1574, 'n_words': 430}