Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
inheritancemodelsOdoo13.0
1 Odgovori
6433 Prikazi
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
Opusti
Avatar
Begineer
Best Answer

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
Opusti
ARJUN BAIDYA
Avtor

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

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Can't add a new field inside inherited model even with server restart
inheritance Odoo13.0
Avatar
Avatar
Avatar
2
jun. 23
5196
Setting a computed default value on a field Solved
inheritance models defaultvalues
Avatar
1
avg. 23
5111
How to show children elements in parent form view?
treeview inheritance models
Avatar
0
apr. 23
3731
Accessing a value from another model
inheritance values models
Avatar
Avatar
1
dec. 21
5788
inherit 'account.move' and creating a new object 'accouont.move.oi' Solved
inheritance account.move Odoo13.0
Avatar
Avatar
1
sep. 21
6353
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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