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
    • Diskusi
    • 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

How to duplicate a line in a sale order?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
objectduplicate
1 Balas
19408 Tampilan
Avatar
Pascal Tremblay

Hello guys!

We are in Odoo 10. I have created a button on each sale order line. We want to duplicate the sale order line in the same sale order when the button is clicked. See image below, the new duplicate icon at the right.

I think that we have to retrieve all the values of the current clicked line and after create the new line.

My skills are too limited to achieve this kind of thing.

COuld you guide me just a little please?

This is not really what we want to achieve, but this would give me a great beginning to achieve the rest.


Our actual code (empty!!!)

def dup_line(self):
        _logger.error("dup_line BEGIN")
        _logger.error("    self :: %s", str(self))
       
        return True


In image :



EDIT #1

I have now this code for my button :

@api.one
def dup_line(self):
     self.copy()

But I get this error :

The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it- creation/update: a mandatory field is not correctly set
[object with reference: order_id - order.id]


EDIT #2

It is clear that the problem is the order_id field.

With this code, I can easily see the self.order_id in the debug. But the copy() function doesn't include the order_id field.

@api.one
def dup_line(self):
    logger.error("    self.order_id :: %s", str(self.order_id))
    self.copy()





1
Avatar
Buang
Avatar
Akhil P Sivan
Jawaban Terbai

Hi,

You may try like this:

class SaleOrderLine(models.Model):
    _inherit = "sale.order.line"
     

    @api.multi
    def dup_line(self):
         self.copy(default={'order_id':self.order_id.id})

If you want to pass some values to the newly created record, you can pass on the default arguement of copy()

order_id is not copied by default because copy=False attribute set on the field definition, if you check in sale.order.line model.

order_id = fields.Many2one('sale.order', string='Order Reference', required=True, ondelete='cascade', index=True, copy=False)
9
Avatar
Buang
Pascal Tremblay
Penulis

Thanks for your answer. COuld you explain why the order_id is not already copied with other values? Why do you we have to give it to copy() function?

Pascal Tremblay
Penulis

Your line works well. Thanks for this. But, I have to refresh the sale order to see the new line. Not a problem for the moment.

Akhil P Sivan

check updated answer for why its not copied by default

Pascal Tremblay
Penulis

I learn a lot with your answers! Big thanks!

Ankit H Gandhi(AHG)

Thanks @ Akhil P.

+1

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
How can I hide the 'duplicate' option in the 'more' button for a specific object Diselesaikan
duplicate
Avatar
Avatar
Avatar
Avatar
Avatar
4
Okt 25
16610
How to implement custom version of "Duplicate" for products ?
duplicate
Avatar
Avatar
Avatar
2
Jun 23
5002
Trace which odoo database that duplicated from
duplicate
Avatar
0
Okt 17
3158
How to resolve ParseError: duplicate key value violates unique constraint
duplicate
Avatar
Avatar
1
Jul 16
11656
How to find objects of a particular module?
object
Avatar
Avatar
Avatar
Avatar
3
Mar 15
6944
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