Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

how to store data in a table temporarily but manually

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
modelscreatesale.order.linesale.order
2 Antworten
3460 Ansichten
Avatar
random_mai

How do i store a temporary (NewId) in sale.order.line table? Here is my scenario:

Before converting a quotation to sales order, i need to insert a default product id manually in sales order line upon creation of a quotation. However, it is returning an error: "Missing required field". I checked it and it was "order_id" field from sale.order.line. 


Sample code:

# Create SO line - from sales.order (this function will be called when there are changes in default product line)

@api.onchange('default_product_line')

def .....(self):

for line in record.default_product_line:

      params = {

            'order_id': self.id, # causing error because quotation is not saved yet, still in draft

            'name': line.name,

            'product_uom_qty': line.qty,

            'price_unit': line.price_unit,

            'product_id': line.product_id.id

      }

      self.env['sale.order.line'].create(params)




How can i store sale order line temporarily if a quotation state is still draft?

0
Avatar
Verwerfen
Axel Mendoza

Please provide more details, I don't see clear exactly what you are doing that have the missing order_id field, how and where? post some code...

random_mai
Autor

Updated the details

Axel Mendoza

I'm sure that I will get errors if I try to run the code you post, why did you put it like that? what it's the value of the record variable?

Avatar
shubham shiroya
Beste Antwort
  1. Add a One2many field in the sale.order model to store the temporary sale order lines.

  2. Modify the onchange method to add the temporary sale order lines to the One2many field.

  3. When converting the quotation to a sales order, copy the temporary sale order lines from the One2many field to the actual sale order lines.

Here's the updated code:

  1. Add a One2many field in the sale.order model:

class SaleOrder(models.Model):

_inherit = 'sale.order'


temp_order_lines = fields.One2many('sale.order.line', 'order_id_temp', string='Temporary Order Lines')


Modify the onchange method to add the temporary sale order lines to the temp_order_lines field:

@api.onchange('default_product_line')

def add_temp_order_lines(self):

temp_lines = []

for line in self.default_product_line:

temp_lines.append((0, 0, {

'name': line.name,

'product_uom_qty': line.qty,

'price_unit': line.price_unit,

'product_id': line.product_id.id

}))

self.temp_order_lines = temp_lines


When converting the quotation to a sales order, copy the temporary sale order lines to the actual sale order lines:

def convert_to_sales_order(self):

# Create the sales order

sale_order_vals = {

# Add other required fields for the sales order

}

sale_order = self.env['sale.order'].create(sale_order_vals)


# Copy temporary sale order lines to actual sale order lines

for temp_line in self.temp_order_lines:

sale_order_line_vals = {

'order_id': sale_order.id,

'name': temp_line.name,

'product_uom_qty': temp_line.product_uom_qty,

'price_unit': temp_line.price_unit,

'product_id': temp_line.product_id.id,

# Add other required fields for the sales order line

}

self.env['sale.order.line'].create(sale_order_line_vals)


# Optionally, you can remove the temporary sale order lines from the quotation

self.temp_order_lines = [(5, 0, 0)]


return sale_order


0
Avatar
Verwerfen
Avatar
Axel Mendoza
Beste Antwort

Here is how you could do it

      self.write({'order_line': [(0,0, {

            'name': line.name,

            'product_uom_qty': line.qty,

            'price_unit': line.price_unit,

            'product_id': line.product_id.id

      })]})

The idea it's that you don't need to create anything in the database, since it's an onchange you need to return the change of the data. In this case you are adding a new line to the sale order that will be showing in the browser and saved into the database once you save the sale order form

0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
Merge Same Item in Sale Order Line Gelöst
sale.order.line sale.order
Avatar
Avatar
Avatar
2
Jan. 24
6260
Combine inline editing with more detailed form view
sale.order.line sale.order
Avatar
0
Juni 23
2748
ValueError: <class 'ValueError'>: "Expected singleton: sale.order.line(<NewId ref='virtual_117'>, <NewId ref='virtual_131'>)"
sale.order.line sale.order
Avatar
Avatar
1
Dez. 22
4185
How to update a custom field as "Margin" default from sale.order does, when some product of sale.order.line is updated/deleted.
sale.order.line sale.order
Avatar
0
Apr. 22
3218
How to count stockable product in orderline in Quotations Gelöst
sale.order.line sale.order
Avatar
Avatar
1
Apr. 19
6816
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Ausbildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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