Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to get a field value from another model in odoo 13?

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
inheritancemodelsOdoo13.0
1 Antworten
6450 Ansichten
Avatar
ARJUN BAIDYA

I have two model and code is given below 


class SellProduct (models.Model):
_name = 'sell.product'
_rec_name = 'product_seq'
# def product (self): # name = self.env ['product.create']. search ([]) # print (name ) product_seq = fields.Many2one ( comodel_name = "product.create" , string = "Product ID" , required = False ,) product_name = fields.Char ( related = 'product_seq.product_name' , string = "Product Name" ,required = False ,)






sell_product_quantity = fields.Integer ( string = "Product Quantity" , required = True ,)
gold_price_new = fields.Integer ( string = "Total Price" , compute = 'compute_price' , store = True ,)

payment = fields.Integer ( string = "Payment" )
due_amount = fields.Integer (string = "Due" , compute = 'due_compute' , store = True )
company_id = fields.Many2one ( 'res.company' , 'Company' , required = True , index = True ,
default = lambda self: self.env.company .id)
currency_id = fields.Many2one ( "res.currency" , string = "Currency" , readonly = True ,
default = lambdaself: self.env.company.currency_id.id, required = True )

sell_line = fields.Many2one ( comodel_name = "product.create" , string = "Sell Line" , required = False ,)





class ProductCreate (models.Model):
_name = 'product.create'
_inherit = [ 'mail.thread' , 'mail.activity.mixin' ,]
_rec_name = 'product_seq'
@ api.depends ( 'create_sell_line' , 'create_sell_line. sell_product_quantity ' ) def update_value ( self ): for rec in self : rec.product_quantity_new = rec.create_sell_line.sell_product_quantity product_seq = fields.Char ( string = ' PID ' ,required =





True , copy = False ,
randomly = True , index = True ,
default = lambda self: _ ( 'New' ))
product_name = fields.Char ( string = "Product Name" )
product_image = fields.Binary ( string = "Product Image " )
product_quantity_new = fields.Integer ( compute = 'update_value' )
product_quantity = fields.Integer ( string = "Product Quantity" ,)
gold_quality = fields.Selection ( string = "Gold Quality" , selection = [( '18k' , '18K' ), ( '21k' , '21K' ), ( '22k' , '22K' )],
required = True ,)
gold_rate = fields.Integer ( string = "Gold Rate" )
gold_weight = fields.Float ( string = "Weight / Gram" , required = True )
making_cost = fields.Integer ( string = " Making Cost")
gold_price = fields.Integer ( string = "Sub-total Price" , compute = 'compute_sub_total_price' , store = True )
tax = fields.Integer ( string = "Tax" , )
tax_cal = fields.Integer ( string = "tax Calculation" , compute = 'compute_tax' , store = True )
total_cost = fields.Integer ( string= "Total Price" , compute = 'compute_total_price' , store = True )

create_sell_line = fields.One2many ( comodel_name = "sell.product" , inverse_name = "sell_line" , string = "create sell line" ,
required = False ,)


Fom  sell.product model, sell_product_quantity field's value will be store product.create model's prouct_quantity_new field
How to solve this problem?

0
Avatar
Verwerfen
Avatar
Begineer
Beste Antwort

Hi Arjun,

        I guess  "sell.product"  model is given as one2many  to  "product.create",  so you must take the sum of the values of sell_product_quantity  and store it in  "prouct_quantity_new" .

So just try,

class ProductCreate(models.Model): 

    _name = 'product.create' 

    @api.multi

    @api.depends('create_sell_line', 'create_sell_line.sell_product_quantity')

    def update_value(self):

        for each in self:

            each.product_quantity_new = sum(line.sell_product_quantity for line in each.create_sell_line)

 Hope it helps,

Thanks





0
Avatar
Verwerfen
ARJUN BAIDYA
Autor

Thank you sir for your answer.

But it is not working.

Actually Firstly I create a product in product.create model here has a unique ID for each product.

After that in the sell.product model here I will sell that product by selecting product ID and here I give product quantity. Suppose when I created product product quantity was 30 now I will sell 20 after that my product is 10?

Kindly see this and if you can solve this problem kindly

Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
Can't add a new field inside inherited model even with server restart
inheritance Odoo13.0
Avatar
Avatar
Avatar
2
Juni 23
5211
Setting a computed default value on a field Gelöst
inheritance models defaultvalues
Avatar
1
Aug. 23
5133
How to show children elements in parent form view?
treeview inheritance models
Avatar
0
Apr. 23
3752
Accessing a value from another model
inheritance values models
Avatar
Avatar
1
Dez. 21
5804
inherit 'account.move' and creating a new object 'accouont.move.oi' Gelöst
inheritance account.move Odoo13.0
Avatar
Avatar
1
Sept. 21
6383
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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