跳至内容
菜单
此问题已终结
3 回复
419 查看

Hello Odoo Community,


I’m implementing a *Customer to Cash* workflow in Odoo, and I want to streamline the process. Specifically, when I create a customer invoice, I would like it to be **automatically marked as paid** (without going through the payment registration manually).


Is there a standard configuration or automation (like a server action or Studio rule) that allows the invoice to be posted and paid immediately upon creation?


I am using Odoo **Enterprise SaaS**.


Thanks in advance for your support!

形象
丢弃
最佳答案

What about using POS?

形象
丢弃
编写者

solved i add check box in customer page and i add domain filter and this code

[('move_type', '=', 'out_invoice'),
('partner_id.commercial_partner_id.x_studio_cash_customer', '=', True)]

automation action

def _get_payment_journal(inv):
# Prefer Bank, then Cash, in the same company
return env['account.journal'].search([
('type', 'in', ['bank', 'cash']),
('company_id', '=', inv.company_id.id),
('active', '=', True),
], limit=1)

for inv in records:
# Only for cash customers (use commercial partner to cover child contacts)
if not inv.partner_id.commercial_partner_id.x_studio_cash_customer:
continue

if inv.move_type != 'out_invoice':
continue
if inv.state != 'draft':
continue
if not inv.amount_total or inv.amount_total <= 0:
continue

# 1) Post the invoice
inv.action_post()

# Already paid/in payment? Skip
if inv.payment_state in ('paid', 'in_payment'):
continue

# 2) Pick a payment journal
journal = _get_payment_journal(inv)
if not journal:
raise UserError("Auto Pay: No Bank/Cash journal in company %s." % inv.company_id.display_name)

# Need an inbound payment method line
pml = journal.inbound_payment_method_line_ids[:1]
if not pml:
raise UserError("Auto Pay: Journal %s has no inbound payment method lines." % journal.display_name)

# 3) Build the Payment Register wizard with proper context
wiz = env['account.payment.register'].with_context(
active_model='account.move',
active_ids=inv.ids,
active_id=inv.id,
).create({
'journal_id': journal.id,
'payment_method_line_id': pml.id,
'amount': inv.amount_residual, # pay what's left
'communication': inv.name or inv.ref or '',
})

# 4) Create & post payment and reconcile
wiz.action_create_payments()

最佳答案

Yes, it’s possible, but not with a standard Odoo setting — you’ll need a small customization. Studio alone can’t fully handle it because marking an invoice as paid triggers accounting entries, which is done through the “Register Payment” logic in code.

形象
丢弃
最佳答案

Hi,


Changing the Outstanding Receipts Account in your customer payment journal to your Bank Account in the Chart of Accounts is a valid method if you want invoices to be marked as Paid immediately upon payment registration. In this setup, when you receive a payment from a customer, the system posts it directly against your bank account instead of the default temporary Outstanding Receipts account. This bypasses the “In Payment” stage and fully reconciles the invoice in one step, making it ideal for cases where funds are received instantly (like cash sales or immediate bank transfers). However, it should only be used when payment and deposit happen at the same time, since it removes the interim reconciliation step used in standard accounting workflows.





Hope it helps

形象
丢弃
编写者

I understand the Outstanding Receipts method, but my question is different.

I want Odoo to automatically create and register a payment when a customer invoice is created — so the invoice is marked as paid immediately, without manually clicking “Register Payment.”

Is this possible via Studio, a server action, or another method ?

Thanks,