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

Sales - add constraint on "Confirm Sales" button

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
salessale.order.lineodooV8odoo8.0odoo8
6 Odpowiedzi
8063 Widoki
Awatar
Salim Rahal

I need to forbid the user from confirming a sales order (action occurred when clicking on confirm sale button: Sales-> Sales Order-> choose an order). So I override the action that confirm the Sales, and add a condition which raise a validation Error, so the super wont be called in case an invalid condition(e.g. order line with product without names).
But the issue occured in S.O. - Edit mode and  when clicking on confirm SO an insert to the database(insert in sale_order_line) is executed before executing the following overwritten function.

//the inherited class
class sales_warning(models.Model):
    _inherit = "sale.order"
@api.multi  
def action_button_confirm(self):
    print "begin overwritten action_button_confirm()"
     if(ForbidCondition==True):
              raise ValidationError("You cannot confirm a S.O...")
    else:
    res = super(sales_warning, self).action_button_confirm()       
return res
Logs showing the write operation before invoking the overwritten function:
crm werkzeug: .. "POST /web/dataset/call_kw/sale.order/write HTTP/1.1" 200 begin overwritten action_button_confirm()


Question: is there a way to add a constraint the will be launched before any other action such as the write above?

thank you

0
Awatar
Odrzuć
Awatar
Salim Rahal
Autor Najlepsza odpowiedź

Since the error (i.e. calling the write function when confirming the SO in edit mode) occurs only in Edit mode, note that in read only mode and when saving the SO the write wont be called (seems Odoo consider nothing to be updated in Sales order line-read only mode), so I choose to hide the confirm button in edit mode by adding oe_read_only css class to the button:


<xpath expr="//button[@name='action_button_confirm']" position="attributes">          
          <attribute name="class">oe_read_only</attribute>            
 </xpath>


In Brief:


-SO (Sale order) in read only mode: confirm button is visible and Won't do an update (update sale_order_line) to DB once it's clicked, only the action action_button_confirm is called
-SO in Edit mode: Hide the button of confirmation in order to prevent updating the sale_order_line

0
Awatar
Odrzuć
Awatar
Qutechs, Ahmed M.Elmubarak
Najlepsza odpowiedź

Hi,

In Odoo, when you press any button it'll invoke the write function "to save the changes" then calling the desired button's function.

So it'll depends on your requirement:

1. Overriding the writing method.

2. Add a constrains function, by adding the decorator @api.constrains to your method ... so you'll be sure that this function will be called before any CRUD operation ...


Hope this could helps ...

0
Awatar
Odrzuć
Salim Rahal
Autor

I tried the @constraints but it will be called on all action on SO recordset: confirm sales, save action and on duplicate So. But I need only to handle the confirm sales action, since I don't want to forbid create a SO with invalid product names, only forbid the confirm SO. Also I tried to send a param from the button to the constraints in order to handle this specific case but it I doesn't works. I couldn't find the write method it in sale.py, Seems that the write couldn't be overridden, I didnt found the function that handle it in sale.py, I found only the create(): called on first save. 10x

Qutechs, Ahmed M.Elmubarak

If I got you, you can just override the confirmation function and raise warning if some condition is true, then the record will be saved but not going to be confirmed. Also you can use @api.onchange to raise some warnings or set values to null if you'd like to validate the user input ...

Qutechs, Ahmed M.Elmubarak

Also the create function will be called when the record is new; the write function will be called when the record is to update. If you don't find the write function in the model it will be inherited from the parent model. You can simply override it same as the create method !

Salim Rahal
Autor

Dear Ahmad, I don't want to let user confirm SO with invalid product name I need to check them before save, and in the same time I will let them save the SO but without confirm. I will try to override the write() in the parent

Salim Rahal
Autor

Dear Ahmad, check my answer and if you find it useful click on up narrow please

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ść
Error "account.analytic.account()" when invoicing
sales invoicing odooV8 odoo8.0 odoo8
Awatar
0
gru 18
3369
How to pass product_ids from old sales order to new sales order. Rozwiązane
sales sale.order.line sale.order odooV8 odoo8.0
Awatar
Awatar
2
lip 16
5680
High Availability Odoo 8.0 on Windows
odooV8 odoo8.0 odoo8
Awatar
0
lut 21
4535
Product received Administrator in Odoo 8 purchase module
odooV8 odoo8.0 odoo8
Awatar
0
lut 18
3273
blockUI requires jQuery v1.2.3 or later! You are using v1.11.1 error when installing Odoo 8 on Windows 10
odooV8 odoo8.0 odoo8
Awatar
Awatar
Awatar
3
cze 17
6634
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