
from openerp import models, api


class PaymentOrderCreate(models.TransientModel):
    _inherit = 'payment.order.create'

    @api.multi
    def extend_payment_order_domain(self, payment_order, domain):
        super(PaymentOrderCreate, self).extend_payment_order_domain(
            payment_order, domain)
        if payment_order.payment_order_type == 'debit':
            # With the new system with bank.payment.line, we want
            # to be able to have payment lines linked to customer
            # invoices and payment lines linked to customer refunds
            # in order to debit the customer of the total of his
            # invoices minus his refunds
            domain += [('account_id.type', '=', 'receivable')]
        return True


from openerp import models, api


class PaymentOrderCreate(models.TransientModel):
    _inherit = 'payment.order.create'

    @api.multi
    def extend_payment_order_domain(self, payment_order, domain):
        super(PaymentOrderCreate, self).extend_payment_order_domain(
            payment_order, domain)
        if payment_order.payment_order_type == 'debit':
            # For receivables, propose all unreconciled debit lines,
            # including partially reconciled ones.
            # If they are partially reconciled with a customer refund,
            # the residual will be added to the payment order.
            #
            # For payables, normally suppliers will be the initiating party
            # for possible supplier refunds (via a transfer for example),
            # or they keep the amount for decreasing future supplier invoices,
            # so there's not too much sense for adding them to a direct debit
            # order
            domain += [
                ('debit', '>', 0),
                ('account_id.type', '=', 'receivable'),
            ]
        return True

Fix move lines domain for direct debits
[FIX] account_direct_debit: Fix move lines domain for direct debits

  
  from openerp import models, api
  
  
  class PaymentOrderCreate(models.TransientModel):
      _inherit = 'payment.order.create'
  
      @api.multi
      def extend_payment_order_domain(self, payment_order, domain):
          super(PaymentOrderCreate, self).extend_payment_order_domain(
              payment_order, domain)
          if payment_order.payment_order_type == 'debit':
-             # With the new system with bank.payment.line, we want
-             # to be able to have payment lines linked to customer
-             # invoices and payment lines linked to customer refunds
-             # in order to debit the customer of the total of his
-             # invoices minus his refunds
+             # For receivables, propose all unreconciled debit lines,
+             # including partially reconciled ones.
+             # If they are partially reconciled with a customer refund,
+             # the residual will be added to the payment order.
+             #
+             # For payables, normally suppliers will be the initiating party
+             # for possible supplier refunds (via a transfer for example),
+             # or they keep the amount for decreasing future supplier invoices,
+             # so there's not too much sense for adding them to a direct debit
+             # order
+             domain += [
+                 ('debit', '>', 0),
-             domain += [('account_id.type', '=', 'receivable')]
+                 ('account_id.type', '=', 'receivable'),
+             ]
          return True
  
Fix move lines domain for direct debits
## Code Before:

from openerp import models, api


class PaymentOrderCreate(models.TransientModel):
    _inherit = 'payment.order.create'

    @api.multi
    def extend_payment_order_domain(self, payment_order, domain):
        super(PaymentOrderCreate, self).extend_payment_order_domain(
            payment_order, domain)
        if payment_order.payment_order_type == 'debit':
            # With the new system with bank.payment.line, we want
            # to be able to have payment lines linked to customer
            # invoices and payment lines linked to customer refunds
            # in order to debit the customer of the total of his
            # invoices minus his refunds
            domain += [('account_id.type', '=', 'receivable')]
        return True

## Instruction:
Fix move lines domain for direct debits
## Code After:

from openerp import models, api


class PaymentOrderCreate(models.TransientModel):
    _inherit = 'payment.order.create'

    @api.multi
    def extend_payment_order_domain(self, payment_order, domain):
        super(PaymentOrderCreate, self).extend_payment_order_domain(
            payment_order, domain)
        if payment_order.payment_order_type == 'debit':
            # For receivables, propose all unreconciled debit lines,
            # including partially reconciled ones.
            # If they are partially reconciled with a customer refund,
            # the residual will be added to the payment order.
            #
            # For payables, normally suppliers will be the initiating party
            # for possible supplier refunds (via a transfer for example),
            # or they keep the amount for decreasing future supplier invoices,
            # so there's not too much sense for adding them to a direct debit
            # order
            domain += [
                ('debit', '>', 0),
                ('account_id.type', '=', 'receivable'),
            ]
        return True
