تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (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
حول هذا المنتدى
المساعدة

How to transfer data from sale order to invoice when clicking on 'Create Invoice'?

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
wizardinvoicequotationact_windowodoo8.0
3 الردود
15819 أدوات العرض
الصورة الرمزية
Yenthe Van Ginneken (Mainframe Monkey)

Hi guys,

I'm extending the sale and account module and added my custom fields in a custom module. I've added fields in both the sale.order.line model and the account.invoice.line model:

class custom_sale_order_line_fields(models.Model):
    _inherit = 'sale.order.line'
    hoogte = fields.Integer()
    breedte = fields.Integer()
    aantal = fields.Integer()
    #Checkboxes
    links = fields.Boolean()
    rechts = fields.Boolean()
    boven = fields.Boolean()
    onder = fields.Boolean()
    kleur = fields.Selection((('w','Wit'), ('z','Zwart'), ('g','Groen'),('r','Rood')))

class aa_invoice_custom_lines(models.Model):
    _inherit = 'account.invoice.line'
    hoogte = fields.Integer()
    breedte = fields.Integer()
    aantal = fields.Integer()
    #Checkboxes
    links = fields.Boolean()
    rechts = fields.Boolean()
    boven = fields.Boolean()
    onder = fields.Boolean()
    kleur = fields.Selection((('w','wit'), ('z','zwart'), ('g','groen'),('r','rood')))

The fields are added in both the view for a new sale order and the view for an invoice:

 <openerp>
    <data>
        <record id="sale.view_order_form_inherit" model="ir.ui.view">
            <field name="name">sale.order.form.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
 	    <field name="arch" type="xml">
	        <xpath expr="//tree[@string='Sales Order Lines']/field[@name='name']" position="after">
		    <field name="links"/>
		    <field name="rechts"/>
		    <field name="boven"/>
		    <field name="onder"/>
		    <field name="kleur"/>
                    <field name="hoogte" on_change="on_change_hoeveelheid_berekenen(hoogte,breedte,aantal)"/>
		    <field name="breedte" on_change="on_change_hoeveelheid_berekenen(hoogte,breedte,aantal)"/>
                    <field name="aantal" on_change="on_change_hoeveelheid_berekenen(hoogte,breedte,aantal)"/>
		</xpath>
	    </field>
        </record>

        <record id="account.invoice_form_inherit3" model="ir.ui.view">
            <field name="name">account.invoice.form.inherit3</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
 	    <field name="arch" type="xml">
	        <xpath expr="//tree[@string='Invoice Lines']/field[@name='name']" position="after">
		    <field name="links"/>
		    <field name="rechts"/>
		    <field name="boven"/>
		    <field name="onder"/>
		    <field name="kleur"/>
                    <field name="hoogte" on_change="on_change_hoeveelheid_factuur_berekenen(hoogte,breedte,aantal)"/>
		    <field name="breedte" on_change="on_change_hoeveelheid_factuur_berekenen(hoogte,breedte,aantal)"/>
                    <field name="aantal" on_change="on_change_hoeveelheid_factuur_berekenen(hoogte,breedte,aantal)"/>
		</xpath>
	    </field>
        </record>
    </data>
</openerp>

The next thing that I need is that when the user opens up a sales order and clicks on the button 'Create Invoice' that the filled in data from the sales order gets passed on to the invoice that is automatically generated.
The button 'Create Invoice' seems to come from /sale/wizard/sale_line_invoice.xml from this record:

 <record id="action_view_sale_order_line_make_invoice" model="ir.actions.act_window">
            <field name="name">Create Invoice</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.order.line.make.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_sale_order_line_make_invoice"/>
            <field name="target">new</field>
        </record>

What I don't understand now is where I should add the logic to transfer data from my custom fields from a sales order to an invoice. How do I know which code this action triggers and how should I transfer the data from the sale order to the invoice? It looks like the data is transferred in the method make_invoice (addons/sale/wizard/sale_line_invoice.py in the following lines:

 #TODO: merge with sale.py/make_invoice
        def make_invoice(order, lines):
            """
                 To make invoices.

                 @param order:
                 @param lines:

                 @return:

            """
            a = order.partner_id.property_account_receivable.id
            if order.partner_id and order.partner_id.property_payment_term.id:
                pay_term = order.partner_id.property_payment_term.id
            else:
                pay_term = False
            inv = {
                'name': order.client_order_ref or '',
                'origin': order.name,
                'type': 'out_invoice',
                'reference': "P%dSO%d" % (order.partner_id.id, order.id),
                'account_id': a,
                'partner_id': order.partner_invoice_id.id,
                'invoice_line': [(6, 0, lines)],
                'currency_id' : order.pricelist_id.currency_id.id,
                'comment': order.note,
                'payment_term': pay_term,
          
                'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
                'user_id': order.user_id and order.user_id.id or False,
                'company_id': order.company_id and order.company_id.id or False,
                'date_invoice': fields.date.today(),
            }
            inv_id = self.pool.get('account.invoice').create(cr, uid, inv)
            return inv_id
But how can I add my custom fields to be added on the invoice lines too?

Thanks,
Yenthe
1
الصورة الرمزية
إهمال
الصورة الرمزية
Peter Alabaster
أفضل إجابة

I have done this before when adding lots to all sale, purchase, and invoice lines. I had to pipe the data across all these forms.

You have to do a certain amount of rooting around in the source code to find the right place to hook in, but for your situation this should work:

class sale_order_line_your_extension(osv.osv):
_inherit = "sale.order.line"

def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
    ret = super(sale_order_line_your_extension, self)._prepare_order_line_invoice_line(cr, uid, line, account_id=False, context=context)
    if line.product_id:
        if line.field_name:
            ret['field_name'] = line.field_name
    return ret

Note: super has been used here to reduce impact on source code.

All we are doing is assigning all the default returned values in the source code to the variable `ret`.

We are then checking if line.product_id exists on the sale order.

Then checking if anything has been set on your field, and then appending your field name (as defined in account.invoice.line) to ret, and assigning the value stored in the field to it.

Finally the appended value is returned, along with all other values.

This can be used in many places when piping data across forms, and can be quite a useful template.

You can easily add more than one value:

ret['field_name2'] = line.field_name2

ret['field_name3'] = line.field_name3

Hope this helps

6
الصورة الرمزية
إهمال
Yenthe Van Ginneken (Mainframe Monkey)
الكاتب

Thanks Peter! This is a really great answer which is also usuable for other cases. Upvoted & accepted, again thanks! :)

الصورة الرمزية
Tintumon
أفضل إجابة

 For creating "account.invoice" from "sale.order" there is four selection option

  • delivered

  • all

  • percentage

  • fixed

I tried a function "def action_invoice_create(self, grouped=False, final=False): " using super in inherited sale.order.

It works fine for sending a field value from sale.order to account.invoice, when the selection field is "delivered" or "all".

But it doesn't work for "percentage" and "fixed" selections.

So I used another function "def _create_invoice(self, order, so_line, amount):"  using super in inherited wizard/sale_make_invoice_advance.py

It propagated the field value from sale.order to account.invoice successfully.

I have tested it in debug also.

Does it right way to achieve? or any other way?

Note: I worked on ODOO9

0
الصورة الرمزية
إهمال
Coralie Cardon

Hello ! I did exactely what you say :-) but i have a problem So, I have a rate in my sale order and i would like take it to multiply to the amount of my invoice. (I put it in a field) But the amount doesn't take the down payment

هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Enlarge or change width of text in invoice/quotation reports تم الحل
invoice quotation
الصورة الرمزية
الصورة الرمزية
2
فبراير 23
3409
Change invoice footer per country
invoice odoo8.0
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
3
يوليو 17
5163
How to make a new field and being integrated in 2 modules
invoice quotation
الصورة الرمزية
الصورة الرمزية
1
مايو 16
4200
How can modify the N° or the source of document for the quotation تم الحل
invoice quotation
الصورة الرمزية
الصورة الرمزية
2
أبريل 16
4983
How can I edit Sales Tax so that it doesn't show the rate, just the word "Tax"? تم الحل
invoice tax quotation
الصورة الرمزية
الصورة الرمزية
1
أكتوبر 25
3722
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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