<commit_before># Copyright 2013-2017 Agile Business Group sagl
#     (<http://www.agilebg.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class AccountInvoiceLine(models.Model):
    _inherit = 'account.invoice.line'

    @api.multi
    def _get_product_customer_code(self):
        product_supplierinfo_obj = self.env['product.supplierinfo']
        for line in self.filtered(lambda il: il.product_id.supplier_ids):
            product = line.product_id
            code_id = product_supplierinfo_obj.search([
                ('product_tmpl_id', '=', product.product_tmpl_id.id),
            ], limit=1)
            line.product_customer_code = code_id.product_code or ''

    product_customer_code = fields.Char(
        compute='_get_product_customer_code',
        string='Product Customer Code',
        size=64
    )
<commit_msg>[FIX] get product_customer_code correctly<commit_after># Copyright 2013-2017 Agile Business Group sagl
#     (<http://www.agilebg.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class AccountInvoiceLine(models.Model):
    _inherit = 'account.invoice.line'

    @api.multi
    def _get_product_customer_code(self):
        product_supplierinfo_obj = self.env['product.supplierinfo']
        for line in self.filtered(lambda il: il.product_id.supplier_ids):
            product = line.product_id
            code_id = product_supplierinfo_obj.search([
                ('supplierinfo_type', '=', 'customer'),
                ('product_tmpl_id', '=', product.product_tmpl_id.id),
                ('name', '=', line.invoice_id.partner_id.id)
            ], limit=1)
            line.product_customer_code = code_id.product_code or ''

    product_customer_code = fields.Char(
        compute='_get_product_customer_code',
        string='Product Customer Code',
        size=64
    )

{'fraction_non_alphanumeric': 0.1150487930148947, 'fraction_numerical': 0.01335387776065742, 'mean_word_length': 2.903807615230461, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '982108', 'n_tokens_mistral': 631, 'n_tokens_neox': 599, 'n_words': 109}