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

How to merge several fields into a new one -using the V8 Saas environment and related tools?

Subscribe

Get notified when there's activity on this post

This question has been flagged
v8saasmergefields.function
8 Replies
8319 Views
Avatar
michel Guénard

I need to create a name for my products; this name will concatenate the values found into 2 or 3 others that already exist: product.name (standard Odoo) + personalized fields.

A solution was given for a different environment: see 


Merging fields into one

Specifically the Saas environment does't allow to create a new field with the function option.

Any direction will be appreciated

UPDATE :

(I tested the following configuration having created 2 fields x_nomcomplet and x_auteur type char on modèle product template modèle d'article)


remove previous server action and create 2 new records with values for fields of server action :


first (for field Action name you can choose what you want):

Action name : Nom complet article

Base Model : Modèle d'article

Action To Do : Execute python code

condition : True

Sequence : 5

notebook python code, add following code:


context = context or {}

for record in self.browse(cr, uid, context.get('active_ids', []), context=context):

    value = ""

    for val in [record.name, record.x_auteur]:

        if val:

            value += "%s " % val

    pool.get('product.template').write(cr, uid, record.id, {'x_nomcomplet': value[:-1]}, context=context)


at the top right of the form push button "Add in the More menu" (will add buttons to tree and form of the menu product)


second (for field Action name you can choose what you want):

Action name : Nom complet variante

Base Model : Article

Action To Do : Execute python code

condition : True

Sequence : 5

notebook python code, add following code:


context = context or {}

for record in self.browse(cr, uid, context.get('active_ids', []), context=context):

    value = ""

    for val in [record.product_tmpl_id.name, record.product_tmpl_id.x_auteur]:

        if val:

            value += "%s " % val

pool.get('product.template').write(cr, uid, record.product_tmpl_id.id, {'x_nomcomplet': value[:-1]}, context=context)


at the top right of the form push button "Add in the More menu" (will add buttons to tree and form of the menu product variant)


test in menus product and variant

1
Avatar
Discard
michel Guénard
Author

@Cyril: yes I have access to this menu and lso to technical features.

michel Guénard
Author

I am interested by an automatic behaviour which allows to store the result of the concatenation of 2 or 3 existing fields into a new one. This new field will replace the name of the variants in every views and forms where the variant name is used.

John

if you check def name_get() in product.py you will see name is concatenated with default_code, you can add any other field with '+' symbol. or are you looking for a new field storing this concatenated value in database?

Cyril Gaspard (GEM)

@John, in mode Odoo online SAAS, no possibility to modify python code or add a new module, to create a field function or related, hard ^^

michel Guénard
Author

@ John. From your comment, one can deduct that the concatenation is hard coded. This may appear as an conception error regarding the required flexibility. Many questions on this forum are showing the need to customise!

Avatar
Cyril Gaspard (GEM)
Best Answer

only solution I know for SAAS odoo version to execute new python code is to use a server action, which will add button "Update name"  (see after) to the form in mode edit at the top menu button "More" AND list view at the top menu button "More" (to perform execution to all selected lines) of the object define in your server action, buttons which will execute your python code.


my example :

I will set to the field name of product template object (menu product),  computation of fields type and default code (verify you have values for that fields else "/" will be set, because this field is required, even if there is always a value for field type, but perhaps this will be not the case for your need)


go to menu configuration/Technical/Actions/Server Actions

create a new record with values for fields of server action :

Action name : Update name

Base Model : Product template

Action To Do : Execute python code

condition : True

Sequence : 5

notebook python code, add following code:


context = context or {}

for record in self.browse(cr, uid, context.get('active_ids', []), context=context):

    name = ""

    for val in [record.type, record.default_code]:

        if val:

            name += "%s " % val

    if name:

        name = name[:-1]

    elif not record.name:

        name = "/"

    pool.get('product.template').write(cr, uid, record.id, {'name': name}, context=context)



at the top right of the server action form push button "Add in the More menu" (will add buttons to tree and form of the object)

save server action


go to menu sales/products/product variants, choose a product, open form in edit mode, at the top menu button More push "Update name", name of your product has changed as "value_field_type value_default_code" (update browser page if it was already opened)

enjoy !


bye

 


2
Avatar
Discard
Cyril Gaspard (GEM)

Hi, I tested and updated code in your first post, follow instructions step by step, tested then should work for you too, bye

michel Guénard
Author

@Cyril: many thanks; it works as expected; however -when the concatenation leads to a long string, then an error message warns that the length is too long for the field; and the field size cannot be changed because it is a base field.

Cyril Gaspard (GEM)

Hi, change lenght of youy file x_nomcomplet in menu configuration/technical/structure de la base de données/champs, search/open form of field x_nomcomplet, in field "Taille" in the form, remove the value if there is one to have a varchar (dynamic lenght), bye

Cyril Gaspard (GEM)

no news ?

michel Guénard
Author

Sorry Cyril; I had a highly busy period since you last advice and no time left to fine tune the issue as per your directions. I will do it in a few days. I have another issue to solve and I was thinking you - Cyril - could help me: I need to create a server action on the product. template object and adding it to the "more options" menu; this action will generate the Ean13 cusotmized value for a whole series of products; it needs to use the values of another field already present in the database and convert them into the EAN13. I know how to create the button itself but I am unable to code the python code to be added to the notebook. I have asked the question on this forum but no answer; therefore my call to you If you will. Regards

Avatar
yellow
Best Answer

Thank you for this process I didn't know !

1
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
Company logo in website builder Solved
v8 saas website_builder
Avatar
Avatar
Avatar
Avatar
4
Jul 16
2191
[8.0] How to translate fields.function with store to the new api
v8 api fields.function
Avatar
Avatar
1
Jul 15
8882
How can I show the Currency of a Sales Order on the printed PDF? Solved
v8 saas sales_order
Avatar
1
Jun 15
7333
How to apply website translation imported through PO file?
v8 saas translation
Avatar
0
Mar 15
4891
[FORUM] Customize (or hide) the "About This Forum" panel Solved
v8 saas forum
Avatar
Avatar
1
Mar 15
4005
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