hunk.code_window:             created_invoice.action_invoice_open()
               if tx.acquirer_id.journal_id:
                   created_invoice.pay_and_reconcile(tx.acquirer_id.journal_id, pay_amount=created_invoice.amount_total)
                   if created_invoice.payment_ids:
                       created_invoice.payment_ids[0].payment_transaction_id = tx
               else:
                   _logger.warning('<%s> transaction completed, could not auto-generate payment for %s (ID %s) (no journal set on acquirer)',
                                   acquirer_name, tx.sale_order_id.name, tx.sale_order_id.id)
  
hunk.labels: keep keep keep replace keep keep keep keep keep
hunk.after_edit:                 created_invoice.with_context(tx_currency_id=tx.currency_id.id).pay_and_reconcile(tx.acquirer_id.journal_id, pay_amount=created_invoice.amount_total)
  
hunk.file_path: addons/website_portal_sale/models/payment.py
hunk.type: replace
file: # -*- coding: utf-8 -*-
  # Part of Odoo. See LICENSE file for full copyright and licensing details.
  
  from odoo import api, fields, models, _
  from odoo.exceptions import UserError
  
  
  class ProductionLot(models.Model):
      _name = 'stock.production.lot'
      _inherit = ['mail.thread']
      _description = 'Lot/Serial'
  
      name = fields.Char(
          'Lot/Serial Number', default=lambda self: self.env['ir.sequence'].next_by_code('stock.lot.serial'),
          required=True, help="Unique Lot/Serial Number")
      ref = fields.Char('Internal Reference', help="Internal reference number in case it differs from the manufacturer's lot/serial number")
      product_id = fields.Many2one(
          'product.product', 'Product',
          domain=[('type', 'in', ['product', 'consu'])], required=True)
      product_uom_id = fields.Many2one(
          'product.uom', 'Unit of Measure',
          related='product_id.uom_id', store=True)
      quant_ids = fields.One2many('stock.quant', 'lot_id', 'Quants', readonly=True)
      create_date = fields.Datetime('Creation Date')
      product_qty = fields.Float('Quantity', compute='_product_qty')
  
      _sql_constraints = [
          ('name_ref_uniq', 'unique (name, product_id)', 'The combination of serial number and product must be unique !'),
      ]
  
      @api.model
      def create(self, vals):
          pack_id = self.env.context.get('active_pack_operation', False)
          if pack_id:
              pack = self.env['stock.pack.operation'].browse(pack_id)
              if pack.picking_id and not pack.picking_id.picking_type_id.use_create_lots:
                  raise UserError(_("You are not allowed to create a lot for this picking type"))
          return super(ProductionLot, self).create(vals)
  
      @api.one
      @api.depends('quant_ids.qty')
      def _product_qty(self):
          self.product_qty = sum(self.quant_ids.mapped('qty'))
  
      @api.multi
      def action_traceability(self):
          move_ids = self.mapped('quant_ids').mapped('history_ids').ids
          if not move_ids:
              return False
          return {
              'domain': [('id', 'in', move_ids)],
              'name': _('Traceability'),
              'view_mode': 'tree,form',
              'view_type': 'form',
              'context': {'tree_view_ref': 'stock.view_move_tree'},
              'res_model': 'stock.move',
              'type': 'ir.actions.act_window'}
  