Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to create product odoo V15 sale.order

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
productsalesale.order.line
2390 Widoki
Awatar
Romain Frucco

Hello,

I'm trying to create product on sale_order_line but I'm facing a problem.


Here you will find the module code, I put in bold what have a problem.


This is my problem, I have a button on sale\.order\.line\ form,\ when\ I\ click\ on\ it\ I\ want\ to\ create\ a\ new\ product\ from\ the\ one\ selected\ and\ define\ on\ it\ a\ bom,\ then\ remplace\ the\ old\ product\ by\ the\ new\ one\ in\ product_id\ field\ selection\.

It's\ working\ if\ the\ line\ exist\ in\ sale_order,\ but\ if\ the\ line\ doesn't\ exist\ I'm\ getting\ this\ error\ :


Error:


2021\-12\-07\ 05:04:55,166\ 22400\ 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\ 05:04:55\.153771',\ 7,\ 0\.0,\ '234',\ '0\.00',\ NULL,\ 'no',\ false,\ '0',\ '\[TGF0308\.8\]\ TIGE\ \ FILETEE\ \ M30\ CLASS\ 8\.8',\ '0\.00',\ 240,\ NULL,\ 0\.0,\ 6,\ '1\.00',\ '0\.00',\ '0\.00',\ '0\.00',\ NULL,\ 12,\ '2021\-12\-07\ 05:04:55\.153771',\ 7\)\ RETURNING\ id
ERROR:\ null\ value\ in\ column\ "order_id"\ of\ relation\ "sale_order_line"\ violates\ not\-null\ constraint
DETAIL:\ \ Failing\ row\ contains\ \(109,\ null,\ \[TGF0308\.8\]\ TIGE\ \ FILETEE\ \ M30\ CLASS\ 8\.8,\ 12,\ no,\ 0\.00,\ null,\ null,\ null,\ null,\ null,\ null,\ 0\.00,\ 240,\ 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\ 05:04:55\.153771,\ 7,\ 2021\-12\-07\ 05:04:55\.153771,\ null,\ null,\ null,\ 0\.00,\ f,\ 234,\ 0\)\.
\
2021\-12\-07\ 05:04:55,199\ 22400\ 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\)\


Code:

\#\ \-\*\-\ coding:\ utf\-8\ \-\*\-
\#\ Copyright\ 2021\ NUprod

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\)
\ \ \ \ \ \ \ \ return\ True

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"
 \ \ \ 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



Can you help me to find a solution, thanks
0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Sale order copy problem in Odoo V15
product sale sale.order.line sale.order
Awatar
0
gru 21
3158
How to generate line numbers on quotes Rozwiązane
sale sale.order.line
Awatar
Awatar
1
sty 25
4371
How to add freight charges to product cost in sale quoatation
sale sale.order.line
Awatar
Awatar
2
sie 24
6417
What's the use of Allotment Partner in sale order line? Rozwiązane
sale sale.order.line
Awatar
Awatar
Awatar
Awatar
Awatar
6
gru 22
9774
Change Sale Quotation Form so Product is Not Required?
product sale.order.line
Awatar
Awatar
Awatar
2
mar 18
4149
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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