<commit_before># -*- coding: utf-8 -*-
# © <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, fields, models


class SaleOrder(models.Model):
    _inherit = "sale.order"

    @api.multi
    def action_invoice_create(self, grouped=False, final=False):

        res = super(SaleOrder, self).action_invoice_create(
            grouped, final)
        invoice = self.env['account.invoice'].browse(res)
        for inv in invoice:
            if inv.partner_id.parent_id:
                inv.sales_channel_id = \
                    inv.partner_id.parent_id.sales_channel_id
            else:
                inv.sales_channel_id = inv.partner_id.sales_channel_id
            if inv.partner_id.parent_id:
                inv.payment_term_id = \
                    inv.partner_id.parent_id.property_payment_term_id
            else:
                inv.payment_term_id = \
                    inv.partner_id.property_payment_term_id
        return res

class SaleAdvancePaymentInv(models.TransientModel):
    _inherit = "sale.advance.payment.inv"

    @api.multi
    def _create_invoice(self, order, so_line, amount):
        res = super(SaleAdvancePaymentInv, self)._create_invoice(
            order, so_line, amount)
        for inv in res:
            if inv.partner_id.parent_id:
                inv.sales_channel_id = \
                    inv.partner_id.parent_id.sales_channel_id
            else:
                inv.sales_channel_id = inv.partner_id.sales_channel_id<commit_msg>[FIX] add payment_term field in invoices from sale order<commit_after># -*- coding: utf-8 -*-
# © <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, fields, models


class SaleOrder(models.Model):
    _inherit = "sale.order"

    @api.multi
    def action_invoice_create(self, grouped=False, final=False):

        res = super(SaleOrder, self).action_invoice_create(
            grouped, final)
        invoice = self.env['account.invoice'].browse(res)
        for inv in invoice:
            if inv.partner_id.parent_id:
                inv.sales_channel_id = \
                    inv.partner_id.parent_id.sales_channel_id
            else:
                inv.sales_channel_id = inv.partner_id.sales_channel_id
            if inv.partner_id.parent_id:
                inv.payment_term_id = \
                    inv.partner_id.parent_id.property_payment_term_id
            else:
                inv.payment_term_id = \
                    inv.partner_id.property_payment_term_id
        return res


class SaleAdvancePaymentInv(models.TransientModel):
    _inherit = "sale.advance.payment.inv"

    @api.multi
    def _create_invoice(self, order, so_line, amount):
        res = super(SaleAdvancePaymentInv, self)._create_invoice(
            order, so_line, amount)
        for inv in res:
            if inv.partner_id.parent_id:
                inv.sales_channel_id = \
                    inv.partner_id.parent_id.sales_channel_id
            else:
                inv.sales_channel_id = inv.partner_id.sales_channel_id
{'fraction_non_alphanumeric': 0.09293443666454487, 'fraction_numerical': 0.0019096117122851686, 'mean_word_length': 2.0633528265107213, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4872729', 'n_tokens_mistral': 1028, 'n_tokens_neox': 968, 'n_words': 167}