Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

Create Invoice from Sales Order via xmlrpc

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
invoicexmlrpcsales.order
2 Trả lời
6541 Lượt xem
Ảnh đại diện
Friedrich

I created sale order in odoo 15:

 

custom_sale_order_id = models.execute_kw(db,uid, password,'sale.order', 'create',

                                    [{

                                    'company_id': int(custom_company_id),  

                                    'create_date': custom_actual_date,

                                    'create_uid': custom_create_uid,

                                    'currency_id': custom_currency_id,

                                    'date_order': custom_actual_date,

                                    'partner_id': custom_partner_id,                                      

                                    'payment_term_id': int(custom_payment_term_id), 

                                    'pricelist_id': int(custom_pricelist_id),

                                    'team_id': int(custom_crm_team),  

                                    'state': custom_sale_order_state,

                                    'invoice_status': custom_sale_order_invoice_status,

                                    'warehouse_id': custom_warehouse_id,

                                    }])

 

and 

 

custom_sale_order_line_id = models.execute_kw(db,uid, password,'sale.order.line', 'create',

                                    [{

                                    'create_date': custom_actual_date,

                                    'create_uid': custom_create_uid,

                                    'currency_id': custom_currency_id,

                                    'order_partner_id': custom_partner_id,

                                    'product_id': custom_product_id,

                                    'product_uom': int(custom_product_uom),

                                    'product_uom_qty': custom_product_qty,

                                    'qty_delivered': custom_product_qty,

                                    'order_id': custom_sale_order_id,

                                    'state': custom_sale_order_state,

                                    'invoice_status': custom_sale_order_invoice_status,

                                    }])

 

 

I’m struggling to automatically create the corresponding invoice to that sales order via xmlrpc. From sale order there is no method to create invoices.

0
Ảnh đại diện
Huỷ bỏ
Amr Abd-Alkrim (FireBits)

There is 2 options to do it: 

1) Call the same method that Odoo uses when you press the "Create Invoice" Button on and already created sales order. (Recommend)

2) Insert the data manually through the 'env' object in 'self' (You will have to do everything by your own throw a method in your model and call it from a button)

move_dict = {
'narration': "Name",
'ref': name,
'journal_id': journal_id.id,
'date': date,
}
line_ids = []

debit_line = {
'name': "Name",
'partner_id': partner_id.id,
'account_id': debit_account_id.id,
'journal_id': journal_id.id,
'date': date,
'debit': round(amount if amount > 0.0 else -amount),
'credit': 0.0,
'analytic_account_id': analytic_account_id,
'tax_line_id': tax_account_id,
}

credit_line = {
'name': "Name",
'partner_id': partner_id.id,
'account_id': credit_account_id.id,
'journal_id': journal_id.id,
'date': date,
'debit': 0.0,
'credit': round(amount if amount > 0.0 else -amount),
'analytic_account_id': analytic_account_id.id,
'tax_line_id': tax_account_id.id,
}

line_ids.append(debit_line)
line_ids.append(credit_line)
move_dict['line_ids'] = line_ids
move = self.env['account.move'].create(move_dict)
move.post()



Happy to help :) an upvote will be awesome

Ảnh đại diện
Cédric ATANANE
Câu trả lời hay nhất

I encountered the same issue, and here's my solution.

I understand that you want to achieve the equivalent of the following code using the XML-RPC API:

payment = self.env ["sale.advance.payment.inv"].create ({})
payment.with_context (active_ids = sale_id).create_invoices ()
1) Creating the payment:
payment = models.execute_kw(db, uid, password, 'sale.advance.payment.inv', 'create', [{
    'advance_payment_method': 'delivered',
    'create_uid': custom_create_uid,
    'currency_id': int(custom_currency_id),
    'deduct_down_payments': True,
    'deposit_account_id': False,
    'fixed_amount': 0.0,
    'has_down_payments': False,
    'write_uid': custom_create_uid,
}])

2) Creating an invoice:
payment_id = 111  # Replace with the payment ID
order_id = 222  # Replace with the sale.order ID

context = {'active_ids': [order_id]}
result = models.execute_kw(db, uid, password, 'sale.advance.payment.inv', 'create_invoices', [payment_id], {'context': context})


I hope you solved your problem beforehand or that it will help other people.

0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Friedrich
Tác giả Câu trả lời hay nhất

Thanks a lot for your answer. I tried option 1, also to automatically create a reference from the invoice to the underlying sales order:


First I create a “sale_advance_payment_inv” record:


        payment = models.execute_kw(db,uid, password,'sale.advance.payment.inv', 'create',

                                    [{

                                    'advance_payment_method': 'delivered',  

                                    'create_uid': custom_create_uid,

                                    'currency_id': int(custom_currency_id),

                                    'deduct_down_payments': True,

                                    'deposit_account_id': False,

                                    'fixed_amount': 0.0,

                                    'has_down_payments': False,

                                    'write_uid': custom_create_uid,

                                    }])


  

Second I wanted to create an invoice from that record but it doesn’t work:


    models.execute_kw(db, uid, password, 'sale.advance.payment.inv', 'create_invoices', [payment],{'context': action['context']})



I got the following error message and I´m not able to fix the error:


xmlrpc.client.Fault: ...

0
Ảnh đại diện
Huỷ bỏ
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
Connect sales order with already confirmed invoice Đã xử lý
invoice sales.order
Ảnh đại diện
Ảnh đại diện
2
thg 12 22
3900
Get Orders Via XML-RPC Call Odoo 11.00
xmlrpc sales.order
Ảnh đại diện
Ảnh đại diện
1
thg 7 18
5929
stock.invoice.onshipping object has no attribute onchange_journal_id
invoice sales.order
Ảnh đại diện
0
thg 6 15
4264
merge invoice lines by product when convert from multiple sales orders
invoice invoice.line sales.order
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
4
thg 2 25
8079
Modify invoice content make it disconnect with its sales order
sales invoice sales.order
Ảnh đại diện
Ảnh đại diện
1
thg 1 25
2289
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now