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č

Merging fields into one

Naroči se

Get notified when there's activity on this post

This question has been flagged
fieldsmergeodooV8
11 Odgovori
12113 Prikazi
Avatar
Dr Obx

Trying to combine 3/4 fields into one in product.

For example i would like to create product name using fields I created. brand, model, size etc

So name = brand+model+size+... and paste it into <field name="name"/> then save.

How can i do it ?

1
Avatar
Opusti
Dr Obx
Avtor

Hi Empiro, still trying but all the time a'm getting some errors, once it is wrong indentation, once i fought it it gives me an error "Brand is not defined" however it is defined but in other module. so what should i do ? remove from my module and create new in this module ?

Emipro Technologies Pvt. Ltd.

@robert If you have defined "model, brand and size" then directly use those fields. Use same name as what you declared. That will work.

Cyril Gaspard (GEM)

Add the field prod_name in your view as invisible (update browser view after module update), I also modify my code to write in field name of class product template and not product product, please avoid to display email you get from odoo, thanks, let me know the result, bye

Avatar
Cyril Gaspard (GEM)
Best Answer


from openerp import models, api, fields

from openerp.tools import ustr


class ProductProduct(models.Model):

    _inherit = "product.product"


    brand = fields.Char('brand')

    model = fields.Char('model')

    size = fields.Char('size')

    prod_name = fields.Char(compute="_get_prod_name", string="Product Name")


    @api.one

    @api.depends("brand", "model", "size")

    def _get_prod_name(self):

        brand = self.brand or ''

        model = self.model or ''

        size = self.model or ''

        name = ustr(brand) + " " + ustr(model) + " " + ustr(size)

        self.product_tmpl_id.name = name

        self.prod_name = name

1
Avatar
Opusti
Dr Obx
Avtor

Hey Cyril, is it possible to add some conditions to it and for example change set of fields if required ? example: if itype = "type1": prod_name = brand + ' ' + model + ' ' + size if itype = "type2": prod_name = brand + ' ' + model + ' ' + condition if itype = "type3": prod_name = brand + ' ' + size + ' ' + connection

Dr Obx
Avtor

I don't think is possible just like that. Field itype is declared by other module so do I have to create a new itype in this module ?

Avatar
Dr Obx
Avtor Best Answer

Guys, I can't make it work, I already have brand, model and size declared. Why whilst am trying install new module it tells me brand not declared, etc.  After that i've had a message regarding indentation, now i have: " can only concatenate tuple (not "str") to tuple"

1
Avatar
Opusti
Dr Obx
Avtor

So in this case all fields I have are char type.

Dr Obx
Avtor

Great thnx Cyril, finally i got it work. Based on this example i can build something more ;) Thanx a lot.

Avatar
michel Guénard
Best Answer

@Emipro,@Cyril How would you do the equivalent solution for a Saas user who only have the developper mode.

For instance I can't create a new field with a type function, because this type is not proposed under the Saas environment.

Although I really need this capacity to combine fields to name the product with the name of its composer and opus title (music domain)!

0
Avatar
Opusti
Cyril Gaspard (GEM)

Hi, please open a new post for that, your case is not similar than this of Robert, contributors will try answer to your problem for your case (explain what configuration menus are available for saas mode => menu modules, company ... or display a picture with all menus extend, a lot of people like me don't use saas version) , bye

Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

@Robert


For this, you can create a new field as of type "Function" i.e fields.function()

from openerp import models,api,fields

class product(models.Model):

    _inherit = "product.product"

    @api.one

    @api.depends("brand","model","size")

    def get_prod_name(self):

        for product in self:

            brand = product.brand_id.name or ''

            model = product.model_id.name or ''

            size = str(product.size)

            product.prod_name= brand + "_"+model+"_"+size


   prod_name = fields.Char(compute="get_prod_name", string="Product Name",store=True)


Here you declared a new field "prod_name" which is a compute field. One more thing, product.product model has a field "name_template" which generally stores the same value as the field "name" from product.template. So you need to decide here whether to take the new field "prod_name" or not. Here I treat brand_id, model_id as many2one fields.

Hope this helps !!.

0
Avatar
Opusti
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
display field by selected model.
fields odooV8
Avatar
0
mar. 16
4065
Retrieving the keys from the selection field
fields odooV8
Avatar
0
dec. 15
5248
What is use of oldname? Solved
fields openerp7 odooV8
Avatar
Avatar
Avatar
2
avg. 22
15176
How to let a field stay editable even after save or confirm
fields editable odooV8
Avatar
Avatar
1
apr. 19
5185
How to have more than one many2one field for a method?
fields many2one odooV8
Avatar
Avatar
1
jun. 18
4643
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