تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (BI)
    • المستندات
    • توقيع إلكتروني
    المبيعات
    • إدارة علاقات العملاء
    • المبيعات
    • نقطة البيع للمتاجر
    • نقطة البيع للمطاعم
    • الاشتراكات
    • تأجير
    المواقع الإلكترونية
    • أداة بناء المواقع الإلكترونية
    • متاجر إلكترونية
    • مدونة
    • المنتدى
    • دردشة مباشرة
    • التعليم الإلكتروني
    سلسلة التوريد
    • المستودعات
    • التصنيع
    • إدارة دورة حياة المنتج
    • المشتريات
    • الصيانة
    • الجودة
    الموارد البشرية
    • موظفون
    • التوظيف
    • إجازة عمل
    • التقييمات
    • الإحالات
    • تطبيق الأسطول
    التسويق
    • التسويق الإجتماعي
    • التسويق عبر البريد الإلكتروني
    • التسويق عبر الرسائل النصية
    • فعاليات
    • أتمتة التسويق
    • الاستطلاعات
    الخدمات
    • المشاريع
    • الجداول الزمنية
    • الخدمة الميدانية
    • مكتب المساعدة
    • التخطيط
    • مواعيد
    اﻹنتاجية
    • مناقشة
    • الموافقات
    • إنترنت الأشياء "IoT"
    • بروتوكول ربط المحادثات الصوتية عبر الإنترنت
    • المعرفة
    • WhatsApp
    التطبيقات الخارجية ستوديو أودو منصة أودو السحابية
  • قطاعات الأعمال
    البيع بالتجزئة
    • متجر كتب
    • متجر ملابس
    • متجر أثاث
    • متجر بقالة
    • متجر معدات
    • متجر ألعاب
    الطعام والضيافة
    • بار وحانة
    • المطعم
    • مطعم للوجبات السريعة
    • نزل للضيوف
    • موزّع مشروبات
    • فندق
    العقارات
    • وكالة عقارات
    • شركة هندسة معمارية
    • البناء
    • إدارة العقارات
    • العناية بالحدائق
    • اتحاد مُلاّك العقارات
    استشارة
    • مؤسسة محاسبية
    • شريك أودو
    • وكالة تسويقية
    • منشأة قانونية
    • استقطاب المواهب
    • التدقيق والتوثيق
    التصنيع
    • الأقمشة
    • معدني
    • الأثاث
    • الطعام
    • مصنع خمور
    • هدايا الشركات
    الصحة واللياقة البدنية
    • نادي رياضي
    • متجر نظارات
    • مركز لياقة بدنية
    • الممارسون الصحيون
    • صيدلية
    • صالون تصفيف الشعر
    التجارة
    • عامل صيانة
    • الأجهزة والمعدات التقنية ودعمها
    • أنظمة الطاقة الشمسية
    • صانع أحذية
    • خدمات التنظيف
    • خدمات التكييف (HVAC)
    غير ذلك
    • منظمة غير ربحية
    • وكالة بيئية
    • تأجير لوحات إعلانية
    • تصوير
    • تأجير دراجات
    • بائع وسيط للبرمجيات
    تصفح كافة قطاعات الأعمال
  • مجتمع أودو
    تعلم
    • دروس
    • التوثيق
    • شهادات
    • التدريب
    • مدونة
    • بودكاست
    قم بتعزيز التعليم
    • برنامج تعليم
    • Scale UP! لعبة الأعمال
    • قم بزيارة أودو
    احصل على البرنامج
    • تحميل
    • قارنْ الإصدارات
    • إطلاق
    تعاون
    • جيت هاب "Github"
    • المنتدى
    • فعاليات
    • الترجمات
    • كنْ شريكاً
    • خدمات الشركاء
    • سجل مكتب المحاسبة الخاص بك
    احصل على الخدمات
    • اعثر على شريك
    • اعثر على محاسب
    • قابل أحد مرشدي الأعمال
    • خدمات التنفيذ
    • مراجع العملاء
    • الدعم
    • الترقيات
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    الحصول على عرض توضيحي
  • الأسعار
  • المساعدة

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • إدارة علاقات العملاء
  • e-Commerce
  • المحاسبة
  • المخزون
  • PoS
  • المشروع
  • MRP
All apps
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
المساعدة

Create an invoice from a sales order using XML-RPC (Python)

اشتراك

تسلم الإشعارات عندما يكون هناك نشاط في هذا المنشور

لقد تم الإبلاغ عن هذا السؤال
many2manysales.orderjournal_entry
2 الردود
9942 أدوات العرض
الصورة الرمزية
Ahmad S

Hi, I'm following the external APIs documentation : https://www.odoo.com/documentation/13.0/webservices/odoo.html

to implement our companies requirements. I'm required to create a sales order and automatically create an invoice after that. The sales order part is done but I cant seem to be able to attach the Invoice to the Sales order

I've tried linking it via the 'invoice_ids' field but the documentation does not mention how to provide a many2many field in it. here is the code:


    many2manyInvoice =  [(4, invoice_id)]   

    common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
    print(common)

    #Admin user Id
    uid = common.authenticate(db, username, password, {})
    
    models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))

    models.execute_kw(db, uid, password, 'sale.order', 'write', [[sales_order_id],     {'invoice_ids':many2manyInvoice}])


The response returned is 200 , but nothing is happening on the sales order level. I think its the way. I think its the way that I defined the field that might be incorrect.

Can someone help with this issue ? Thanks in advance




0
الصورة الرمزية
إهمال
الصورة الرمزية
Aditya Irri
أفضل إجابة

This might help you

@app.route('/createInvoice', methods=['POST'])
def createInvoice():
    try:
        models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
        data = request.get_json()
        if not data:
            return jsonify({'message': 'No data received.'}), 400
        
        sale_order_id = int(data.get('sale_order_id'))
        product_id = int(data.get('product_variant_id'))
        
        if not sale_order_id or not product_id:
            return jsonify({'message': 'Invalid input data.'}), 400
        
        # Fetch data related to the sale order
        sale_order_data = models.execute_kw(db, uid, password, 'sale.order', 'read', 
                                            [sale_order_id], 
                                            {'fields': ['partner_id', 'invoice_status', 'name', 'order_line', 'picking_ids']})
        
        if not sale_order_data:
            return jsonify({'message': 'Sale order not found.'}), 404
        
        invoice_id = None
        
        # Iterate through each picking related to the sale order
        for picking_line in sale_order_data[0].get('picking_ids', []):
            picking_line_data = models.execute_kw(db, uid, password, 'stock.picking', 'search_read', 
                                                [[['id', '=', int(picking_line)],['product_id','=', int(product_id)]]], {})
            # If picking data is found
            if picking_line_data:
                stock_picking_validate = models.execute_kw(db, uid, password, 'stock.picking', 'button_validate', [[picking_line]])
        
        # Iterate through each line of the sale order
        for lineId in sale_order_data[0].get('order_line', []):
            sale_order_line = models.execute_kw(db, uid, password, 'sale.order.line', 'search_read', 
                                                [[["id", "=", lineId],['product_id','=', product_id]]], {})
            if sale_order_line:
                # Generate invoice for the sale order line
                current_date = datetime.now().strftime('%Y-%m-%d')
                context = {
                    'move_type': 'out_invoice',
                    'partner_id': sale_order_data[0]['partner_id'][0],
                    'invoice_origin': sale_order_data[0]['name'],
                    'invoice_date': current_date,
                    'partner_bank_id': 164, #Keep your bank ID
                    'l10n_in_gst_treatment': 'consumer', #Keep your GST treatment (Consumer or Supplier)
                    'ref': '',
                    'l10n_in_type_id': 1, #Eway Bill Document type - ID
                    'l10n_in_mode': '1', #Mode Of Transport - ID
                    'l10n_in_distance': 11, #Distance travelled by vehicle
                    'l10n_in_vehicle_type': 'R', #Vehicle Type - Char
                    'l10n_in_vehicle_no': 'AP00AA0000' #Vehicle Number - Char
                }
                # Create invoice in the system
                invoice_id = models.execute_kw(db, uid, password, 'account.move', 'create', [context])
                invoice_lines = []
                # Populate invoice lines
                for lineId in sale_order_data[0].get('order_line', []):
                    sale_order_line = models.execute_kw(db, uid, password, 'sale.order.line', 'read', [lineId], {})
                    invoice_lines.append((0, 0, {
                        'move_id': int(invoice_id),
                        'product_id': int(sale_order_line[0]['product_id'][0]),
                        'quantity': float(sale_order_line[0]['product_uom_qty']),
                        'price_unit': float(sale_order_line[0]['price_unit']),
                        'name': sale_order_line[0]['name']
                    }))
                # Write invoice lines to the invoice
                models.execute_kw(db, uid, password, 'account.move', 'write', [invoice_id, {'invoice_line_ids': invoice_lines}])
                # Post the invoice
                models.execute_kw(db, uid, password, 'account.move', 'action_post', [invoice_id])
                # Find the invoice line ID
                inv_line_id = models.execute_kw(db, uid, password, 'account.move.line', 'search', 
                                                 [[['product_id', '=', sale_order_line[0]['product_id'][0]], 
                                                   ['move_id', '=', invoice_id], 
                                                   ['quantity', '=', sale_order_line[0]['product_uom_qty']]]])
                # Update sale order line with invoice line and invoice status
                models.execute_kw(db, uid, password, 'sale.order.line', 'write', 
                                  [lineId, {'invoice_lines': [(4, inv_line_id[0])], 'invoice_status': 'invoiced'}])
                # Update sale order with invoice ID and invoice status
                models.execute_kw(db, uid, password, 'sale.order', 'write', 
                                  [[sale_order_id], {'invoice_ids': [(4, invoice_id)], 'invoice_status': 'invoiced'}])
                # Return response based on whether invoice was created or not
                if invoice_id:
                    return jsonify({'invoice_id': invoice_id, 'message':'Invoice created successfully.'}), 200
                else:
                    return jsonify({'message': 'No invoice created for the given conditions.'}), 200
        
        # If no invoice was created
        return jsonify({'message': 'No invoice created.'}), 404
        
    except Exception as e:
        print(f"An error occurred: {e}")
        return jsonify({'message': 'An error occurred while processing the request.'}), 500


0
الصورة الرمزية
إهمال
الصورة الرمزية
Jainesh Shah(Aktiv Software)
أفضل إجابة

Hi Ahmad,

invoice_id = 279777

sale_id = 16


sale_id = models.execute_kw(db, uid, password, 'sale.order', 'search_read', [[

['id', '=', 16]]], {'fields': ['order_line']})



for line in sale_id[0]['order_line']:


sale_line_id = models.execute_kw(db, uid, password, 'sale.order.line', 'search_read', [[

['id', '=', line]]], {'fields': ['product_template_id', 'product_uom_qty']})


product_id = models.execute_kw(db, uid, password, 'product.product', 'search', [[

['product_tmpl_id', '=', sale_line_id[0]['product_template_id'][0]]]])


inv_line_id = models.execute_kw(db, uid, password, 'account.move.line', 'search', [[

['product_id', '=', product_id[0]], 

['move_id', '=', 279777], 

['quantity', '=', sale_line_id[0]['product_uom_qty']]]])

if inv_line_id:

models.execute_kw(db, uid, password, 'sale.order.line', 'write', [line,

{'invoice_lines':[(4, inv_line_id[0])]}])

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

0
الصورة الرمزية
إهمال
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Adding Multiple products in Sales order line?
many2many sales.order
الصورة الرمزية
2
ديسمبر 18
10454
(((Oficial~ C.O.P.A!@!Ecuador)))¿Cómo puedo llamar a Copa Airlines desde Ecuador?
sales.order
الصورة الرمزية
0
ديسمبر 25
43
Best Way To Journal Employee Capital Investment
journal_entry
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
يوليو 25
2308
Transform Quotations to sales orders or invoices in a bulk action
sales.order
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
3
فبراير 25
3539
Orden de venta borrada por error
sales.order
الصورة الرمزية
الصورة الرمزية
1
ديسمبر 24
2951
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "Github"
  • المشغل الآلي رنبوت
  • الترجمات
خدماتنا
  • استضافة أودو إس إتش
  • الدعم
  • الترقية
  • التطويرات المخصصة
  • التعليم
  • اعثر على محاسب
  • اعثر على شريك
  • كنْ شريكاً
معلومات عنا
  • شركتنا
  • أصول العلامة التجارية
  • اتصلْ بنا
  • الوظائف
  • فعاليات
  • بودكاست
  • مدونة
  • عملاء
  • قانوني • الخصوصية
  • الحماية
الْعَرَبيّة 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

أودو هو عبارة عن مجموعة من تطبيقات الأعمال مفتوحة المصدر التي تغطي جميع احتياجات شركتك، مثل: إدارة علاقات العملاء والتجارة الإلكترونية والمحاسبة والمخزون ونقاط البيع وإدارة المشاريع وما إلى ذلك.

ما يجعل من أودو مميزاً هو هدفه بأن يكون سهل الاستخدام للغاية ومتكاملاً تمامًا في الوقت ذاته.

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