Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

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

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
pythonodooodoo10
7 Besvarelser
4537 Visninger
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
Kassér
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)
Bedste svar

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
Kassér
Boutaina AS
Forfatter

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

Boutaina AS
Forfatter

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

Boutaina AS
Forfatter

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!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
When department is changed employee rule is not working without restarting server in odoo Løst
python odoo odoo10
Avatar
Avatar
1
aug. 20
3504
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 Løst
python odoo odoo10
Avatar
Avatar
Avatar
4
jan. 19
5179
[Solved]How to calculate the value of float field in one2many field Løst
python odoo odoo10
Avatar
Avatar
1
jan. 19
8620
[SOLVED] Invisible Button After Clicked Løst
python odoo odoo10
Avatar
Avatar
Avatar
2
jan. 19
11279
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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