Odoo Help


Merging fields into one

Dr Obx
on 4/4/15, 5:21 PM 1,869 views

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 ?

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 ?

Dr Obx
on 4/5/15, 9:48 AM

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

Emipro Technologies Pvt. Ltd.
on 4/5/15, 2:12 PM

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

Cyril Gaspard (GEM)
on 4/5/15, 3:37 PM

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 4/5/15, 2:10 PM

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.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

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
on 4/7/15, 7:54 AM

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 ?

Dr Obx
on 4/7/15, 8:27 AM
Dr Obx
On 4/5/15, 10:28 AM

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"

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

Dr Obx
on 4/5/15, 11:58 AM

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

Dr Obx
on 4/5/15, 4:22 PM

michel Guénard

--michel Guénard--

| 5 5 8
--michel Guénard--

VP operations & finance Social entrepreneur Certified Public Accountant Past Chief internal auditor

michel Guénard
On 4/5/15, 9:14 AM

@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)!

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

Cyril Gaspard (GEM)
on 4/5/15, 10:35 AM

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.


Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 


We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :


  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 4/5/15, 3:18 AM


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"



    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 !!.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 4/4/15, 5:21 PM
Seen: 1869 times
Last updated: 4/5/15, 8:33 PM