Odoo Help

Welcome!

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

1

How to copy field value in odoo 8 ?

By
Sankar
on 7/16/15, 7:20 AM 608 views

How to copy field value in odoo . .

Let say i have two field called name and name1

i want to show name field and hide name1 field.

if i update name field it also need to upade name1 field. . .

Any idea other than on_change

3

Solanki Shamji

--Solanki Shamji--
1293
| 5 2 6
Baroda, India
--Solanki Shamji--

Hello!

Solanki Shamji
On 7/16/15, 7:30 AM

Hello,

You can set value on create and write method when you save the record.

    @api.model
def create(self, vals):
if vals.get('name'):
vals['name1'] = vals.get('name')
your_obj = super(your_obj, self).create(vals)
return your_obj

@api.model
def write(self, vals):
if vals.get('name'):
vals['name1'] = vals.get('name')
your_obj = super(your_obj, self).write(vals)
return True
2
Lucio
On 7/16/15, 8:34 AM

Hello,

I will definetively go for a functional field (stored in base if needed).

Assuming name is a char (but it will work for any type of field)


from openerp import api

@api.depends('name')
def _mimic_name(self):
for rec in self:
rec.name1 = rec.name

name = fields.Char('Name')
name1 = fields.Char('Name1', compute='_mimic_name', store=True)

As I said, store=True is optional, it depends of wheter you want the field to be persistant in database or calculated on the fly.

Hope it helps! 

0

Axel Mendoza

--Axel Mendoza--
10203
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/16/15, 12:51 PM

Use a related field

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 7/16/15, 7:20 AM
Seen: 608 times
Last updated: 12/22/15, 8:22 AM