İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

How to auto merge ?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
2 Cevaplar
1030 Görünümler
Avatar
Benoit

Hi guy's,


Could you tell me how to auto merge orders with the same product please ?

I would like make it with an automated action on studio.


Thank you :)

0
Avatar
Vazgeç
Avatar
Sujata
En İyi Yanıt

Hello  Benoit,

I understand that you want to merge sales orders based on similar products. Below is an approach using Odoo Studio's Automated Actions. If this solution fits your requirements, let me know; otherwise, we can adjust the logic as needed.

Steps to Implement:

1. Create an Automated Action

  • Navigate to Odoo Studio → Automated Actions
  • Click Create to add a new action

2. Configure the Action

  • Model: Sales Order (sale.order)
  • Trigger: On Creation & Update
  • Conditions:
    • State = Draft (state = 'draft')
    • (Optional) Filter by partner_id to ensure it's a customer order
  • Action to Execute: Python Code

3. Python Code for Order Merging

# Get current sales order
so = record

# Proceed only if the order is in draft state
if so.state == 'draft':
    customer = so.partner_id
   
    # Fetch other draft sales orders for the same customer
    existing_orders = env['sale.order'].search([
        ('partner_id', '=', customer.id),
        ('state', '=', 'draft'),
        ('id', '!=', so.id)  # Exclude the current order
    ])
   
    if existing_orders:
        # Select the first existing draft order for merging
        target_so = existing_orders[0]

        for line in so.order_line:
            product = line.product_id
            qty = line.product_uom_qty

            # Check if the product exists in the target SO
            existing_line = target_so.order_line.filtered(lambda l: l.product_id == product)
           
            if existing_line:
                # Update quantity in the existing order line
                existing_line.product_uom_qty += qty
            else:
                # Move the line to the existing order
                line.write({'order_id': target_so.id})

        # Delete the original SO if it's empty after merging
        if not so.order_line:
            so.unlink()

Use Cases Covered:

✅ If a new Draft Sales Order (SO) is created for a customer and contains a product already present in another Draft SO, the product is merged into the existing order.

✅ If the original SO is empty after merging, it is automatically deleted.

Let me know if this approach works for you! 😊


1
Avatar
Vazgeç
Alec

Can something like this be done on contacts too?

Sujata

yes, sure you replace sale order to contacts in place of model and then update logic according to the case

Sujata

Alec, If this helps, please upvote the answer!

Benoit
Üretici

I've test it and I cant' save the automated rule due to this message :

forbidden opcode(s) in "# Available variables:\n# - env: environment on which the action is triggered\n# - model: model of the record on which the action is triggered; is a void recordset\n# - record: record on which the action is triggered; may be void\n# - records: recordset of all records on which the action is triggered in multi-mode; may be void\n# - time, datetime, dateutil, timezone: useful Python libraries\n# - float_compare: utility function to compare floats based on specific precision\n# - b64encode, b64decode: functions to encode/decode binary data\n# - log: log(message, level='info'): logging function to record debug information in ir.logging table\n# - _logger: _logger.info(message): logger to emit messages in server logs\n# - UserError: exception class for raising user-facing warning messages\n# - Command: x2many commands namespace\n# To return an action, assign: action = {...}\n\n# Get current sales order\nso = record\n\n# Proceed only if the order is in draft state\nif so.state == 'draft':\n customer = so.partner_id\n \n # Fetch other draft sales orders for the same customer\n existing_orders = env['sale.order'].search([\n ('partner_id', '=', customer.id),\n ('state', '=', 'draft'),\n ('id', '!=', so.id) # Exclude the current order\n ])\n \n if existing_orders:\n # Select the first existing draft order for merging\n target_so = existing_orders[0]\n\n for line in so.order_line:\n product = line.product_id\n qty = line.product_uom_qty\n\n # Check if the product exists in the target SO\n existing_line = target_so.order_line.filtered(lambda l: l.product_id == product)\n \n if existing_line:\n # Update quantity in the existing order line\n existing_line.product_uom_qty += qty\n else:\n # Move the line to the existing order\n line.write({'order_id': target_so.id})\n\n # Delete the original SO if it's empty after merging\n if not so.order_line:\n so.unlink()": STORE_ATTR

Avatar
Benoit
Üretici En İyi Yanıt

Thanks Sujata.


To Begin I've test to put in on the model mrp.production.


Here is the result, but it doesn't work :


# Get current manufacturing order

mo = record


# Proceed only if in confirmed state

if mo.state == 'confirmed':

   

    # Fetch other confirmed manufacturing orders excluding the current one

    existing_orders = env['mrp.production'].sudo().search([

        ('state', '=', 'confirmed'),

        ('id', '!=', target_mo.id})


        # Invalidate cache uniquement avant la suppression

        if not mo.sudo().move_finished_ids:

            mo.invalidate_cache()

            mo.sudo().unlink()


0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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