コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • 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:

  • CRM
  • 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 返信
15831 ビュー
アバター
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
2月 23
3426
Change invoice footer per country
invoice odoo8.0
アバター
アバター
アバター
3
7月 17
5196
How to make a new field and being integrated in 2 modules
invoice quotation
アバター
アバター
1
5月 16
4227
How can modify the N° or the source of document for the quotation 解決済
invoice quotation
アバター
アバター
2
4月 16
5000
How can I edit Sales Tax so that it doesn't show the rate, just the word "Tax"? 解決済
invoice tax quotation
アバター
アバター
1
10月 25
3740
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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