Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to generate error depending to fields ( Its URGENT PLZ)

Odoberať

Get notified when there's activity on this post

This question has been flagged
pythonodooodoo10
7 Replies
4534 Zobrazenia
Avatar
Boutaina AS

Hi community , its so urgent Plz

I had add a boolean field in 'product.product' named 'is_dmp'. so , i want that if I try to add an artcile who have this field false in purchase order , a warning message appear . 

so this what i did :

--------------------------------------------------------------------------------------------------------------------------

from odoo import api, models

from odoo import fields

from odoo.exceptions import UserError

class product_product(models.Model):

_name = 'product.product'

_inherit = 'product.product'

is_dmp = fields.Boolean(help='Est ce que cet articles doit avoir un certificat d enregistrement', string='Necessite un enregistrement')

dmp = fields.Char('Numéro de certificat')

# purchase_ok = fields.Boolean(compute='_check_dmp'),

class PurchaseOrderLineWar(models.Model):

_name = "product.product"

_inherit = "product.product"

@api.onchange('dmp')

def _check_dmp(self):

if self.is_dmp == False:

warning_mess = {

'title': _('Warnnnnning'),

'message' : _('Attention cet article ne necessite pas un certifact DMP'),

}

return {'warning': warning_mess}  

-----------------------------------------------------------------------------------------------------------------------


Plz any idea , i need help .

0
Avatar
Zrušiť
Sudhir Arya (ERP Harbor Consulting Services)

Do you want to show warning when user selects a product in purchase order line?

Sudhir Arya (ERP Harbor Consulting Services)

Now its work , thank you 


Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

You have inherited wrong object in PurchaseOrderLineWar class.

I think you should inherit "purchase.order" or "purchase.order.line" object.

If you want to show a warning message when user selects a product in purchase order line, you should use following code:

class PurchaseOrderLine(models.Model):
    _inherit = 'purchase.order.line'

    @api.onchange('product_id')
    def change_product(self):
        if self.product_id and self.product_id.is_dmp:
            msg = {
                'title': 'Warning',
                'message': 'Your warning message.'
            }
            return {'warning': msg}

This way you can show a warning message when user selects product in purchase order line and product does not have is_dmp boolean if False.

Sudhir Arya
ERP Harbor Consulting Services
s:sudhir@erpharbor.com  w: http://www.erpharbor.com
5
Avatar
Zrušiť
Boutaina AS
Autor

Yes, exectly , I want to show warning when user selects a product that have is_dmp True in purchase order line?

Boutaina AS
Autor

Im sorry i past a wrong code in my question hhh , i will edit it with the right one

Boutaina AS
Autor

Hi community , its so urgent Plz

I had add a boolean field in 'product.product' named 'is_dmp'. so , i want that if I try to add an artcile who have this field false in purchase order , a warning message appear .

so this what i did :

--------------------------------------------------------------------------------------------------------------------------

from odoo import api, models

from odoo import fields

from odoo.exceptions import UserError

class product_product(models.Model):

_name = 'product.product'

_inherit = 'product.product'

is_dmp = fields.Boolean(help='Est ce que cet articles doit avoir un certificat d enregistrement', string='Necessite un enregistrement')

dmp = fields.Char('Numéro de certificat')

class PurchaseOrderLineWar(models.Model):

_name = 'purchase.order.line'

_inherit = 'purchase.order.line'

@api.onchange('order_line.product_id')

def _check_dmp(self):

print 'HHHHHHHHHHHHHHHHHHHHHHHHHHHH'

for a in self.order_line:

if a.product_id.is_dmp == True:

raise UserError(_("Please Select Goods your mesage"))

-----------------------------------------------------------------------------------------------------------------------

Plz any idea , i need help .

Sudhir Arya (ERP Harbor Consulting Services)

Just try the code which is in my answer. It will work for you.

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

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
When department is changed employee rule is not working without restarting server in odoo Solved
python odoo odoo10
Avatar
Avatar
1
aug 20
3501
How to set "email_to" in email template dynamically
python odoo odoo10
Avatar
Avatar
Avatar
5
dec 19
12690
[Solved] Make One2many readonly when session is over Solved
python odoo odoo10
Avatar
Avatar
Avatar
4
jan 19
5178
[Solved]How to calculate the value of float field in one2many field Solved
python odoo odoo10
Avatar
Avatar
1
jan 19
8617
[SOLVED] Invisible Button After Clicked Solved
python odoo odoo10
Avatar
Avatar
Avatar
2
jan 19
11278
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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