i want to add field and value just year with code python and xml..
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Maybe you can use: 'year': fields.selection([(y, str(y)) for y in range(1970, (datetime.now().year + 30)+1 )], 'Year'),
Range from 1970 to 2044 (Adjust your range as you want)
and in the .xml file just add your field somewhere in your view: <field name="year" />
easiest way is to add :
'year':fields.char('Year', size="4")
aternative can be fields.integer('"Year")
both would need with some validity check on write
adding field of type date will add full date format, and on view it will be shown as calendat widget...
in your python file it seems this :
class model_name(osv.osv)
_name = "model.name"
_description = "description for model"
_columns = {
'year':fields.char('Year', size="4"),
}
model_name()
in your xml form view description it seems this :
<!-- form -->
<record model="ir.ui.view" id="id_model_form">
<field name="name">model.name.form</field>
<field name="model">model.name</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="descripti" version="7.0" >
<group>
<field name="year" />
</group>
</form>
</field>
</record>
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký
ok thank you