I have created an invoice from code which is posted now i want to register its payment to paid on a button click from my code. What should I do to pay the invoice from python code?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
You can create a payment by directly calling the create method of the account.payment model and passing the invoice_id in the context. See this example,
Payment = self.env['account.payment'].with_context(default_invoice_ids=[(4, inv1.id, False)])
payment = Payment.create({
'payment_date': time.strftime('%Y') + '-07-15',
'payment_method_id': self.inbound_payment_method.id,
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': inv1.partner_id.id,
'amount': 314.07,
'journal_id': self.bank_journal_euro.id,
'company_id': company.id,
'currency_id': self.currency_euro_id,
'payment_difference_handling': 'reconcile',
'writeoff_account_id': self.diff_income_account.id,
})
payment.post()
Thanks
Thanks. Let me try this
File "/home/syedhamza/custom/programming/enviornments/odoo/odoo13/src/odoo/odoo/addons/base/models/res_currency.py", line 192, in _convert
assert company, "convert amount from unknown company"
AssertionError: convert amount from unknown company
i m receiving this error here's my code:
def create_token_fees(self):
token = self.env.ref('real_estate.token_money')
settings = self.env['res.config.settings'].search([])
company = self.env.user.company_id.id
prod = [(0, 0, {
'product_id': token.id,
'name': token.name,
'account_id': token.property_account_income_id.id or False,
'quantity': 1,
'price_unit': self.token_fees
})]
invoice = self.env['account.move'].create({
# 'name': rec.property_registration_id.name,
# 'user_id': rec.manager_id.id,
'partner_id': settings.token_partner_id.id,
'type': 'out_invoice',
'journal_id': settings.account_journal_id.id,
'crm_id': self.crm_id.id,
'token_partner': self.crm_id.contact_name,
'invoice_date': fields.Date.today(),
'invoice_line_ids': prod
})
print("Token Fee")
invoice.action_post()
Payment = self.env['account.payment'].with_context(default_invoice_ids=[(4, invoice.id, False)])
payment = Payment.create({
'payment_date': fields.Date.today(),
# 'payment_method_id': self.inbound_payment_method.id,
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': settings.token_partner_id.id,
'amount': 314.07,
' journal_id ': settings.account_journal_id.id,
'company_id': company.id,
'currency_id': company.currency_id.id,
'payment_difference_handling': 'reconcile',
# 'writeoff_account_id': self.diff_income_account.id,
})
payment.post()
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 10 20
|
3169 | ||
|
3
thg 4 25
|
827 | ||
|
3
thg 4 25
|
1495 | ||
Delete PDF Invoice
Đã xử lý
|
|
1
thg 3 25
|
892 | |
|
2
thg 1 25
|
816 |