Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

[11] Add button in invoice to origin sale order

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
odoo11
3796 Tampilan
Avatar
Christian Schubert

Hey there,

I'm currently working on a small tweak for the invoices from the account module.

I want to have a button in the button box of the invoice (next to the timesheet button) which points to the sale order from which the invoice was created. So basically like it's added in the sale_timesheet module, which adds a button to the sale order in the single timesheets.

Refs:

  • sale_timesheet\views\project_task_views.xml Lines 19-35

  • sale_timesheet\models\project.py Lines 102-111

What I've done until now:

  • Created a custom module

  • Created an xml which inherits from the account invoice form and added the button via xpath

  • Created an python file which inherits from AccountInvoice to add a action_view_so function

The button shows just fine in the view, shows the origin SO with the correct number (used a statinfo widget) but the function is missing the right reference. After some tries, I decided to create an account in the forums and ask directly instead of reading up old threads which doesn't solve my issue so far.

After clicking on the action this is the error message, which refers to my added function:

"res_id": self.origin.order_id.id,
AttributeError: 'str' object has no attribute 'order_id'

This is my record in the xml:

<record id="account_invoice_view_sale_order_button" model="ir.ui.view">
    <field name="name">account.invoice.form.inherit.sobutton</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form"/>
    <field name="arch" type="xml">
        <xpath expr="//div[@name='button_box'][last()]" position="inside">
            <button type="object" name="action_view_so" class="oe_stat_button" icon="fa-dollar">
                <field name="origin" widget="statinfo" string="Sales Order"/>
            </button>
        </xpath>
    </field>
</record>

This is the class extension in the python file:

class AccountInvoice(models.Model):
    _inherit = "account.invoice"
    @api.multi
    def action_view_so(self):
        self.ensure_one()
        return {
            "type": "ir.actions.act_window",
            "res_model": "sale.order",
            "views": [[False, "form"]],
            "res_id": self.origin.order_id.id,
            "context": {"create": False, "show_sale": True},
        }

So the res_id is not the correct one, but I can't figure out which one would be the correct reference path. I would really appreciate help from your side to point me to the right direction. Many thanks in advance.


EDIT:

Just after a little more research and trial&error, I've solved it for me.

If someone has the same issue or want to achieve the same functionality, the solution was to convert the string value of the sale order, which is located in the origin field of the invoice, to the correct sale order id.

So the action_view_so function from above has to be like this:

@api.multi
def action_view_so(self):
    self.ensure_one()
    sale_line_ids = self.invoice_line_ids.mapped('sale_line_ids')

    if sale_line_ids:
        sale_order = sale_line_ids[0].order_id

    return {
        "type": "ir.actions.act_window",
        "res_model": "sale.order",
        "views": [[False, "form"]],
        "res_id": sale_order.id,
        "context": {"create": False, "show_sale": True},
    }

Also the thread wasn't yet approved, but just to contribute to the knowledge base I wanted to share the solution.​



 
1
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
create backorder odoo after validate purchase shipment ? Diselesaikan
odoo11
Avatar
Avatar
1
Okt 25
12158
I can't create any sub-task
odoo11
Avatar
Avatar
Avatar
2
Jul 24
3759
odoo 11 display calendar widget in website layout
odoo11
Avatar
Avatar
1
Jun 24
6076
Get field's value from another model
odoo11
Avatar
Avatar
1
Okt 23
98
413 Request Entity Too Large Diselesaikan
odoo11
Avatar
Avatar
1
Agu 23
2194
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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