<commit_before>from openerp import api, models, fields, SUPERUSER_ID
import re

class PaymentAcquirer(models.Model):
    _inherit = 'payment.acquirer'

    journal_id = fields.Many2one('account.journal', 'Payment method', help='This journal is used to auto pay invoice when online payment is received')

class sale_order(models.Model):

    _inherit = 'sale.order'

    def action_button_confirm(self, cr, uid, ids, context=None):
        super(sale_order, self).action_button_confirm(cr, uid, ids, context=context)
        r = self.browse(cr, uid, ids[0], context=context)
        if r.payment_tx_id and r.payment_tx_id == 'done' and r.payment_acquirer_id and r.payment_acquirer_id.journal_id:
            journal_id = r.payment_acquirer_id.journal_id

            # [create invoice]
            res = self.pool['sale.order'].manual_invoice(cr, uid, [r.id], context)
            invoice_id = res['res_id']

            # [validate]
            self.pool['account.invoice'].signal_workflow(cr, uid, [invoice_id], 'invoice_open')

            # [register payment]
            res = self.pool['account.invoice'].invoice_pay_customer(cr, uid, [invoice_id], context=context)
            voucher_context = res['context']

            update = {}
            for dkey in voucher_context:
                if not dkey.startswith('default_'):
                    continue
                key = re.sub(r'^default_', '', dkey)
                if voucher_context.get(key):
                    continue
                update[key] = voucher_context[dkey]
            voucher_context.update(update)


            field_list = ["comment","line_cr_ids","is_multi_currency","paid_amount_in_company_currency","line_dr_ids","journal_id","currency_id","narration","partner_id","payment_rate_currency_id","reference","writeoff_acc_id","state","pre_line","type","payment_option","account_id","company_id","period_id","date","payment_rate","name","writeoff_amount","analytic_id","amount"]
            voucher_values = self.pool['account.voucher'].default_get(cr, uid, field_list, context=voucher_context)

            res = self.pool['account.voucher'].onchange_journal(
                cr, uid, False,<commit_msg>[FIX]<commit_after>from openerp import api, models, fields, SUPERUSER_ID
import re

class PaymentAcquirer(models.Model):
    _inherit = 'payment.acquirer'

    journal_id = fields.Many2one('account.journal', 'Payment method', help='This journal is used to auto pay invoice when online payment is received')

class sale_order(models.Model):

    _inherit = 'sale.order'

    def action_button_confirm(self, cr, uid, ids, context=None):
        super(sale_order, self).action_button_confirm(cr, uid, ids, context=context)
        r = self.browse(cr, uid, ids[0], context=context)
        if r.payment_tx_id and r.payment_tx_id.state == 'done' and r.payment_acquirer_id and r.payment_acquirer_id.journal_id:
            journal_id = r.payment_acquirer_id.journal_id

            # [create invoice]
            res = self.pool['sale.order'].manual_invoice(cr, uid, [r.id], context)
            invoice_id = res['res_id']

            # [validate]
            self.pool['account.invoice'].signal_workflow(cr, uid, [invoice_id], 'invoice_open')

            # [register payment]
            res = self.pool['account.invoice'].invoice_pay_customer(cr, uid, [invoice_id], context=context)
            voucher_context = res['context']

            update = {}
            for dkey in voucher_context:
                if not dkey.startswith('default_'):
                    continue
                key = re.sub(r'^default_', '', dkey)
                if voucher_context.get(key):
                    continue
                update[key] = voucher_context[dkey]
            voucher_context.update(update)


            field_list = ["comment","line_cr_ids","is_multi_currency","paid_amount_in_company_currency","line_dr_ids","journal_id","currency_id","narration","partner_id","payment_rate_currency_id","reference","writeoff_acc_id","state","pre_line","type","payment_option","account_id","company_id","period_id","date","payment_rate","name","writeoff_amount","analytic_id","amount"]
            voucher_values = self.pool['account.voucher'].default_get(cr, uid, field_list, context=voucher_context)

            res = self.pool['account.voucher'].onchange_journal(
                cr, uid, False,
{'fraction_non_alphanumeric': 0.12853881278538812, 'fraction_numerical': 0.0009132420091324201, 'mean_word_length': 3.196360153256705, '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': '6641694', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1302, 'n_words': 227}