Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Merging fields into one

Subscribe

Get notified when there's activity on this post

This question has been flagged
fieldsmergeodooV8
11 Replies
12088 Views
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
Discard
Dr Obx
Author

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
Discard
Dr Obx
Author

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
Author

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
Author 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
Discard
Dr Obx
Author

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

Dr Obx
Author

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
Discard
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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
display field by selected model.
fields odooV8
Avatar
0
Mar 16
4059
Retrieving the keys from the selection field
fields odooV8
Avatar
0
Dec 15
5242
What is use of oldname? Solved
fields openerp7 odooV8
Avatar
Avatar
Avatar
2
Aug 22
15170
How to let a field stay editable even after save or confirm
fields editable odooV8
Avatar
Avatar
1
Apr 19
5181
How to have more than one many2one field for a method?
fields many2one odooV8
Avatar
Avatar
1
Jun 18
4638
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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