Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to autofill sale.order.line from linked purchase.order(.line)?

Odebírat

Get notified when there's activity on this post

This question has been flagged
purchasesalesale.order.lineonchange
1 Odpovědět
8540 Zobrazení
Avatar
Christian Spitzl

Hi, I've created two modules.
The first one "Sale Quotation 2 Purchase Quotation" links a Sale Order with a Purchase Order and autofills the PO Lines with the values of the linked SO Lines.
So far, so good.
The second one "Purchase Order 2 Sale Order" gives me a lot of trouble. 
It should do nearly the same like the first one, only in the other direction. It should autofill the SO Lines with the values of the linked PO Lines.
The problem is the "product_id_change" method. It checks whether a customer is defined before you can chose a product.
How can I solve it and get it work?

Many thanks for an adivce.

 


FIRST:
Sale Quotation 2 Purchase Quotation

 

<code></p>

class purchase_order(osv.osv):

    _inherit = 'purchase.order'
    _name = 'purchase.order'
    
    STATE_SELECTION = [
        ('draft', 'Draft PO'),
        ('sent', 'RFQ Sent'),
        ('received', 'RFQ Received'),
        ('confirmed', 'Waiting Approval'),
        ('approved', 'Purchase Order'),
        ('except_picking', 'Shipping Exception'),
        ('except_invoice', 'Invoice Exception'),
        ('done', 'Done'),
        ('cancel', 'Cancelled')
    ]
    
    _columns = {
       'state': fields.selection(STATE_SELECTION, 'Status', readonly=True, select=True),
       'purchase_quotation_id': fields.many2one('sale.order', 'Sale Quotation', domain=[('state','in',('draft','sent'))]),
    }
    _defaults = {
        'state': 'draft',
        'purchase_quotation_id': lambda self, cr, uid, context: context.get('purchase_quotation_id', False),
    }

    def onchange_purchase_order(self, cr, uid, id, purchase_quotation_id, partner_id, pricelist_id):
        domain = []
        value = []
        if purchase_quotation_id:
            sale = self.pool.get('sale.order').browse(cr,uid,purchase_quotation_id)
            for line in sale.order_line:
                vals = self.pool.get('purchase.order.line').onchange_product_id(cr, uid, id, pricelist_id, line.product_id.id, line.product_uom_qty, line.product_uom.id, partner_id)
                vals['value'].update({
                    'product_id': line.product_id.id, 
                    'state':'draft', 
                    'move_ids':[], 
                    'invoiced':0,
                    'invoice_lines':[],
                })
            value.append(vals['value'])
            domain.append(vals['domain'])
        return {'value': {'order_line': value}, 'domain': {'order_line': domain}}    

 

class sale_order(osv.osv):
    _inherit = "sale.order"
    _name = "sale.order"

    _columns = {
        'sale_quotation': fields.one2many('purchase.order', 'purchase_quotation_id', 'Purchase Quotation'),
    }
    
sale_order()

</code></p>

 

SECOND:

Purchase Quotation 2 Sale Quotation

<code><p>

class sale_order(osv.osv):

    _inherit = 'sale.order'
    _name = 'sale.order'
    
    STATE_SELECTION = [
        ('draft', 'Draft Quotation'),
        ('sent', 'Quotation Sent'),
        ('cancel', 'Cancelled'),
        ('waiting_date', 'Waiting Schedule'),
        ('progress', 'Sale Order'),
        ('manual', 'Sale to Invoice'),
        ('invoice_except', 'Invoice Exception'),
        ('done', 'Done'),
    ]
    
    _columns = {
       'state': fields.selection(STATE_SELECTION, 'Status', readonly=True, select=True),
       'sale_quotation_id': fields.many2one('purchase.order', 'Purchase Quotation', domain=[('state','in',('draft','sent'))]),
    }
    _defaults = {
        'state': 'draft',
        'sale_quotation_id': lambda self, cr, uid, context: context.get('sale_quotation_id', False),
    }

    def onchange_sale_order(self, cr, uid, id, sale_quotation_id, partner_id, pricelist_id):
        domain = []
        value = []
        if sale_quotation_id:
            purchase = self.pool.get('purchase.order').browse(cr,uid,sale_quotation_id)
            for line in purchase.order_line:
>>>??            vals = self.pool.get('sale.order.line').product_id_change(cr, uid, id, pricelist_id, line.product_id.id, line.product_qty, line.product_uom.id, partner_id)
                vals['value'].update({
                    'product_id': line.product_id.id, 
                    'state':'draft', 
                    'move_ids':[], 
                    'invoiced':0,
                    'invoice_lines':[],
                })
            value.append(vals['value'])
            domain.append(vals['domain'])
        return {'value': {'order_line': value}, 'domain': {'order_line': domain}}    

 

class purchase_order(osv.osv):
    _inherit = "purchase.order"
    _name = "purchase.order"

    _columns = {
        'purchase_quotation': fields.one2many('sale.order', 'sale_quotation_id', 'Sale Quotation'),
    }
    
purchase_order()

</code></p>

0
Avatar
Zrušit
Avatar
Ludo - 21South
Nejlepší odpověď

Do not be offended by my remarks, but I was wondering why you went through all this effort instead of using Odoo regular procurement system for the previous work (from sale to purchase)? Is it because you did not want to confirm the sale before creating the purchase?

Other than that, I think its much simpler that the sketched situation. Create a wizard that takes the current sale order (usually in context under "active id") and use it to read the order line for line (assuming you already know where the purchase order goes), sending the product_id and qty to the on_change method for purchase order line. If configured correctly. You should first create a purchase order, but since that can practically be empty, you should have no trouble creating an order line for the PO based on its id.

Alternatively, you can check the system of procurements (procurement.order in Odoo) and write a method on that. Procurements already have links to both sales as well as purchase orders. Writing a simple method that converts it to purchase orders should do the trick. Then all you have to do is make sure the SO generates a procurement at a point you see fit.

0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to generate line numbers on quotes Vyřešeno
sale sale.order.line
Avatar
Avatar
1
led 25
4399
How can enter freight charges and transporting Charges in sale order? Vyřešeno
purchase sale
Avatar
Avatar
1
srp 24
6358
How to add freight charges to product cost in sale quoatation
sale sale.order.line
Avatar
Avatar
2
srp 24
6428
What's the use of Allotment Partner in sale order line? Vyřešeno
sale sale.order.line
Avatar
Avatar
Avatar
Avatar
Avatar
6
pro 22
9785
Sale order line description to purchase order line.
purchase sale sale.order.line purchase_order purchase.order
Avatar
Avatar
1
říj 22
5159
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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