Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Sale order copy problem in Odoo V15

Subscribe

Get notified when there's activity on this post

This question has been flagged
productsalesale.order.linesale.order
3163 Views
Avatar
Romain Frucco

Hello,

I'm trying to create a product from Form sale\.order\.line,\ from\ an\ other\ existant\ product\.

If\ i'm\ taking\ a\ sale\.order\.line\ that\ exist\ it\ works,\ but\ if\ i'm\ trying\ to\ Add\ a\ new\ product\ i'm\ taking\ an\ error\.

Following\ you\ will\ find\ my\ code\ :


Code

/\#\ \-\*\-\ coding:\ utf\-8\ \-\*\-

from\ odoo\ import\ api,\ fields,\ models,\ tools,\ _,\ SUPERUSER_ID
from\ odoo\.exceptions\ import\ ValidationError,\ RedirectWarning,\ UserError
from\ odoo\.osv\ import\ expression
import\ logging

_logger\ =\ logging\.getLogger\(__name__\)

class\ SaleOrderLineNU\(models\.Model\):
\ \ \ \ \#\ \ Bug\ At\ least\ one\ model\ cache\ has\ been\ invalidated,\ signaling\ through\ the\ database
\ \ \ \ cutLength\ =\ fields\.Float\(string='Cut\ Length',\ digits=\(2,\ 0\)\)
\ \ \ \ length\ =\ fields\.Float\(string='Length',\ digits=\(2,\ 0\)\)

\ \ \ \ _inherit\ =\ "sale\.order\.line"

\ \ \ \ def\ majPrice\(self,\ line,\ qty=False\):
\ \ \ \ \ \ \ \ mrp_bom\ =\ self\.env\['mrp\.bom'\]\ \ \#\ recuperation\ fichier\ python
\ \ \ \ \ \ \ \ bom_report\ =\ self\.env\['report\.mrp\.report_bom_structure'\]\ \ \#\ recuperation\ fichier\ python
\ \ \ \ \ \ \ \ if\ line\.product_id\ and\ line\.product_uom_qty:\ \ \#\ si\ un\ produit\ avec\ identifiant\ et\ qty
\ \ \ \ \ \ \ \ \ \ \ \ bom\ =\ mrp_bom\._bom_find\(products=line\.product_id\)\ \ \#\ recuperation\ du\ resultat\ de\ la\ fonction\ _bom_find
\ \ \ \ \ \ \ \ \ \ \ \ if\ bom:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ price\ =\ bom_report\._get_bom\(
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ bom_id=bom\[line\.product_id\]\.id,\ product_id=str\(line\.product_id\.id\),
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ line_qty=line\.product_uom_qty,\ line_id=False,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ level=False\)\['total'\]\ /\ line\.product_uom_qty\ \ \#\ Recuperation\ du\ resultat\ de\ la\ fonction\ _get_bom\['total'\]/qty
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\ \ _logger\.warning\("MAJ\ %s:\ %s",\ line\.product_uom_qty,\ price\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\ price

\ \ \ \ @api\.onchange\('product_uom_qty'\)
\ \ \ \ def\ _compute_so_line_bom_price\(self,\ qty=False\):
\ \ \ \ \ \ \ \ """Compute:\ Product\ BoM\ Cost\ Price\.
\ \ \ \ \ \ \ \ \ \ \ \ Compute\ the\ BoM\ Cost\ Price\ using\ _bom_find\ method\ of\ MRP\ BoM\ object\ and
\ \ \ \ \ \ \ \ \ \ \ \ _get_bom\ method\ of\ BoM\ Structure\ and\ Cost\ Report
\ \ \ \ \ \ \ \ \ \ \ \ \(BoM\ >\ Smart\ Button:\ Structure\ \&\ Cost\)\.
\ \ \ \ \ \ \ \ \ \ \ \ put\ this\ price\ in\ purchase_price\ in\ order_line\ and\ standard_price\ in\ product
\ \ \ \ \ \ \ \ \ \ \ \ for\ pricelist\ calculation
\ \ \ \ \ \ \ \ \ \ \ \ :return:\ None
\ \ \ \ \ \ \ \ \ \ \ \ """

\ \ \ \ \ \ \ \ for\ res\ in\ self:\ \ \#\ pour\ chaque\ ligne
\ \ \ \ \ \ \ \ \ \ \ \ price\ =\ 0
\ \ \ \ \ \ \ \ \ \ \ \ price\ =\ SaleOrderLineNU\.majPrice\(self,\ res\)
\ \ \ \ \ \ \ \ \ \ \ \ self\.purchase_price\ =\ price\ \ \#\ Pousse\ le\ tarif\ dans\ le\ prix\ d'achat\ du\ devis
\ \ \ \ \ \ \ \ \ \ \ \ res\.product_id\.standard_price\ =\ price\ \ \#\ Pousse\ le\ tarif\ dans\ la\ fiche\ produit\ en\ coût\ pour\ calcul\ du\ prix\ de\ vente\ basé\ sur\ le\ coût

\ \ \ \ @api\.onchange\('product_id'\)
\ \ \ \ def\ recupBomInfoSale\(self\):
\ \ \ \ \ \ \ \ mrp_bom\ =\ self\.env\['mrp\.bom'\]\ \ \#\ recuperation\ fichier\ python
\ \ \ \ \ \ \ \ if\ self\.product_id\ and\ '5'\ in\ self\.product_id\.route_ids:\ \#\ a\ Verifier
\ \ \ \ \ \ \ \ \ \ \ \ bom\ =\ mrp_bom\._bom_find\(products=self\.product_id\)
\ \ \ \ \ \ \ \ \ \ \ \ if\ bom:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ len\(bom\[self\.product_id\]\.bom_line_ids\)\ ==\ 1:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ self\.length\ =\ bom\[self\.product_id\]\.bom_line_ids\.product_qty\ \*\ 1000\ \ \#\ ok

\ \ \ \ def\ cut_article\(self\):
\ \ \ \ \ \ \ \ DuplicateArticleNUprod\.createArticle\(self\)

class\ SaleOrder\(models\.Model\):

\ \ \ \ _inherit\ =\ "sale\.order"

\ \ \ \ @api\.onchange\('order_line'\)
\ \ \ \ def\ calculationQty1OnCreate\(self\):
\ \ \ \ \ \ \ \ sale_order_line\ =\ self\.env\['sale\.order\.line'\]\ \ \#\ recuperation\ fichier\ python
\ \ \ \ \ \ \ \ if\ self\.order_line\ !=\ 0:
\ \ \ \ \ \ \ \ \ \ \ \ for\ res\ in\ self\.order_line:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if\ res\.product_uom_qty\ ==\ 1:

\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ price\ =\ SaleOrderLineNU\.majPrice\(self\.order_line,\ res\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ res\.purchase_price\ =\ price\ \ \#\ Pousse\ le\ tarif\ dans\ le\ prix\ d'achat\ du\ devis
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ res\.product_id\.standard_price\ =\ price\ \ \#\ Pousse\ le\ tarif\ dans\ la\ fiche\ produit\ en\ coût\ pour\ calcul\ du\ prix\ de\ vente\ basé\ sur\ le\ coût
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sale_order_line\._onchange_discount\(\)\ \ \#\ MAJ\ du\ tarif

class\ DuplicateArticleNUprod\(models\.Model\):

\ \ \ \ _inherit\ =\ "product\.product"
\ \ \ \ \#\ \ Bug\ si\ order_line\ n'existe\ pas\ il\ faut\ donc\ ajouter\ un\ article\ au\ devis\ le\ sauvegarder\ et\ aprés\ modifier\ cet\ article
\ \ \ \ def\ createArticle\(self\):

\ \ \ \ \ \ \ \ productModule\ =\ self\.env\['product\.template'\]
\ \ \ \ \ \ \ \ newProduct\ =\ productModule\.create\(\[\{
\ \ \ \ \ \ \ \ \ \ \ \ 'name':\ _\('Coupe\ de\ %s\ L:%s',\ self\.product_id\.name,\ int\(self\.cutLength\)\),
\ \ \ \ \ \ \ \ \ \ \ \ 'sale_ok':\ True,
\ \ \ \ \ \ \ \ \ \ \ \ 'detailed_type':\ 'product',
\ \ \ \ \ \ \ \ \ \ \ \ 'default_code':\ self\.product_id\.default_code\ \+\ '/'\ \+\ str\(int\(self\.cutLength\)\),
\ \ \ \ \ \ \ \ \ \ \ \ 'route_ids':\ \[5\],
\ \ \ \ \ \ \ \ \ \ \ \ 'uom_id':\ 1,
\ \ \ \ \ \ \ \ \ \ \ \ 'purchase_ok':\ False,
\ \ \ \ \ \ \ \ \ \ \ \ 'categ_id':self\.product_id\.categ_id\.id,
\ \ \ \ \ \ \ \ \}\]\)

\ \ \ \ \ \ \ \ bomModule\ =\ self\.env\['mrp\.bom'\]
\ \ \ \ \ \ \ \ bomId\ =\ bomModule\.create\(\[\{
\ \ \ \ \ \ \ \ \ \ \ \ 'product_tmpl_id':\ newProduct\.id,
\ \ \ \ \ \ \ \ \ \ \ \ 'product_qty':\ 1,
\ \ \ \ \ \ \ \ \ \ \ \ 'code':\ newProduct\.name,
\ \ \ \ \ \ \ \ \ \ \ \ 'type':\ 'normal',
\ \ \ \ \ \ \ \ \ \ \ \ 'operation_ids':\ \[
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(0,\ 0,\ \{
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'name':\ 'Sciage',
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'workcenter_id':\ 1,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'time_cycle_manual':\ 3,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'sequence':\ 1,
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \),
\ \ \ \ \ \ \ \ \ \ \ \ \]
\ \ \ \ \ \ \ \ \}\]\)

\ \ \ \ \ \ \ \ bomLineModule\ =\ self\.env\['mrp\.bom\.line'\]
\ \ \ \ \ \ \ \ bomLineModule\.create\(\[\{
\ \ \ \ \ \ \ \ \ \ \ \ 'bom_id':\ bomId\.id,
\ \ \ \ \ \ \ \ \ \ \ \ 'product_id':\ self\.product_id\.id,
\ \ \ \ \ \ \ \ \ \ \ \ 'product_tmpl_id':\ self\.product_id\.product_tmpl_id\.id,
\ \ \ \ \ \ \ \ \ \ \ \ 'product_qty':\ self\.cutLength\ /\ 1000,
\ \ \ \ \ \ \ \ \}\]\)

\ \ \ \ \ \ \ \ return\ True


Error

2021\-12\-07\ 23:00:38,125\ 28644\ ERROR\ FMB011221\ odoo\.sql_db:\ bad\ query:\ INSERT\ INTO\ "sale_order_line"\ \("id",\ "create_date",\ "create_uid",\ "customer_lead",\ "cutLength",\ "discount",\ "display_type",\ "invoice_status",\ "is_delivery",\ "length",\ "name",\ "price_unit",\ "product_id",\ "product_packaging_id",\ "product_packaging_qty",\ "product_uom",\ "product_uom_qty",\ "purchase_price",\ "qty_delivered",\ "qty_delivered_manual",\ "route_id",\ "sequence",\ "write_date",\ "write_uid"\)\ VALUES\ \(nextval\('sale_order_line_id_seq'\),\ '2021\-12\-07\ 23:00:38\.114232',\ 7,\ 0\.0,\ '567',\ '0\.00',\ NULL,\ 'no',\ false,\ '0',\ '\[TGF0208\.8\]\ TIGE\ \ FILETEE\ \ M20\ CLASS\ 8\.8',\ '0\.00',\ 234,\ NULL,\ 0\.0,\ 6,\ '1\.00',\ '0\.00',\ '0\.00',\ '0\.00',\ NULL,\ 12,\ '2021\-12\-07\ 23:00:38\.114232',\ 7\)\ RETURNING\ id
ERROR:\ null\ value\ in\ column\ "order_id"\ of\ relation\ "sale_order_line"\ violates\ not\-null\ constraint
DETAIL:\ \ Failing\ row\ contains\ \(110,\ null,\ \[TGF0208\.8\]\ TIGE\ \ FILETEE\ \ M20\ CLASS\ 8\.8,\ 12,\ no,\ 0\.00,\ null,\ null,\ null,\ null,\ null,\ null,\ 0\.00,\ 234,\ 1\.00,\ 6,\ null,\ 0\.00,\ 0\.00,\ null,\ null,\ null,\ null,\ null,\ null,\ null,\ null,\ null,\ null,\ null,\ 0,\ null,\ null,\ 0,\ 7,\ 2021\-12\-07\ 23:00:38\.114232,\ 7,\ 2021\-12\-07\ 23:00:38\.114232,\ null,\ null,\ null,\ 0\.00,\ f,\ 567,\ 0\)\.
\
2021\-12\-07\ 23:00:38,150\ 28644\ WARNING\ FMB011221\ odoo\.http:\ L'opération\ ne\ peut\ pas\ être\ terminée:
\-\ Créer\ /\ mettre\ à\ jour:\ un\ champ\ obligatoire\ n'est\ pas\ défini\.
\-\ Supprimer:\ un\ autre\ modèle\ nécessite\ la\ suppression\ de\ l'enregistrement\.\ Si\ possible,\ archivez\-le\.

Modèle:\ Sales\ Order\ Line\ \(sale.order.line), Champ : Order Reference (order_id) 


Can you help me?


Sincerely

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

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

Sign up
Related Posts Replies Views Activity
Odoo 19 - how does rounding work on Sales Order Lines? The Total isn't the sum of the order line totals Solved
sale sale.order.line sale.order
Avatar
Avatar
1
नव॰ 25
377
How can I sell products with bundled usage and bill for excess consumption
product sale sale.order
Avatar
0
जुल॰ 24
1859
how to create sale order line on create of sale order
sale sale.order.line sale.order
Avatar
Avatar
1
अप्रैल 23
14378
How to create product odoo V15 sale.order
product sale sale.order.line
Avatar
0
दिस॰ 21
2395
How to get related field value from database ? Solved
product sale sale.order
Avatar
Avatar
1
मार्च 24
15546
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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