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

Adding custom field in Sale order line to show values into Purchase order line

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
purchasesalesfunction
3 Replies
2466 Tampilan
Avatar
Usama

I want to add a custom field in sale order line and want to show its value in purchase order line. It cannot get value from sale order line because when I apply debugger on 

def _prepare_procurement_values(self, group_id=False):
     res = super()._prepare_procurement_values(group_id) 

it will go only there then break but not execute  

def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, company_id, values, po):
    res = super()._prepare_purchase_order_line(product_id, product_qty, product_uom, company_id, values, po)

that function.

What's the solution anyone suggest me?

0
Avatar
Buang
Christoph Farnleitner

Next time please use punctuation in your sentences and format your code so your question is actually readable.

Avatar
D Enterprise
Jawaban Terbai

Hii,

please try this 
models/stock_rule.py

from odoo import models


class StockRule(models.Model):

    _inherit = 'stock.rule'


    def _prepare_purchase_order_line(

        self, product_id, product_qty, product_uom, company_id, values, po

    ):

        res = super()._prepare_purchase_order_line(

            product_id, product_qty, product_uom, company_id, values, po

        )

        # Pass custom field to PO line

        if values.get('x_custom_ref'):

            res['x_custom_ref'] = values['x_custom_ref']

        return res


i hope it is usefull

0
Avatar
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

Hi,


You're trying to pass a custom field from the Sales Order Line to the corresponding Purchase Order Line, but during the procurement process, your custom value isn’t flowing through—even though you extended _prepare_procurement_values() and _prepare_purchase_order_line().


Try with the following.

1- Add field to sale.order.line

x_reference_code = fields.Char("Reference Code")


2-Extend _prepare_procurement_values() in sale.order.line

def _prepare_procurement_values(self, group_id=False):

    res = super()._prepare_procurement_values(group_id)

    res.update({

        'x_reference_code': self.x_reference_code,

    })

    return res


3- Extend _prepare_purchase_order_line() in purchase.order


def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, company_id, values, po):

    res = super()._prepare_purchase_order_line(product_id, product_qty, product_uom, company_id, values, po)

   

    if 'x_reference_code' in values:

        res.update({

            'x_reference_code': values['x_reference_code'],

        })

    return res


Also, make sure purchase.order.line has this custom field.

x_reference_code = fields.Char("Reference Code")


Follow the three-step override above, and ensure the correct routes (Make To Order, Dropship, etc.) are active on your sale order line.


Hope it helps



0
Avatar
Buang
Avatar
Christoph Farnleitner
Jawaban Terbai

See for example https://github.com/odoo/odoo/blob/18.0/addons/sale/models/sale_order_line.py#L1445 and https://github.com/odoo/odoo/blob/18.0/addons/sale_project/models/sale_order_line.py#L474, i.e.

def _prepare_procurement_values(self, group_id=False):
    """ Prepare specific key for moves or other components that will be created from a stock rule
        coming from a sale order line. This method could be override in order to add other custom key that could
        be used in move/po creation.
        """
        return {}


_prepare_procurement_values() must have a return value (dict). Same goes for _prepare_purchase_order_line().

0
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
How to add products up to the available stock quantity in my store?
purchase sales
Avatar
Avatar
Avatar
2
Agu 25
2488
Multi Company Transfer Diselesaikan
purchase sales
Avatar
Avatar
1
Jul 25
1504
Report for Sold Product Quantities & Sizes in Sales Orders
purchase sales
Avatar
Avatar
1
Feb 25
2280
adapting selling prices based on the cost of THE products sold and the public cost that could be the selling price referred into the product characteristic Diselesaikan
purchase sales
Avatar
Avatar
Avatar
2
Jun 23
3876
Can I config selected default vendor for customer
purchase sales
Avatar
Avatar
1
Agu 19
4076
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