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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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
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
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!
| 관련 게시물 | 답글 | 화면 | 활동 | |
|---|---|---|---|---|
|
|
4
1월 24
|
24481 | ||
|
Attrs attribute
해결 완료
|
2
1월 24
|
3337 | ||
|
0
8월 23
|
3115 | |||
|
5
9월 21
|
18650 | |||
|
3
1월 21
|
19975 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.