콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3967 화면

I have selected field in table one2many.

can i make selection field it to auto increment when i click add item or change selected field to Char ?

in my case i want make position tire being increment

iam using odoo 11


my py code :

class FleetOperations(models.Model):
_inherit = 'fleet.vehicle'

tire_detail = fields.One2many('tire.detail','tire_detail_id',string='Tire Detail')

class TireDetail(models.Model):
_name = 'tire.detail'

tire_detail_id = fields.Many2one('fleet.vehicle', string='Tire Detil')
tire_kmdi = fields.Char(string='KMDI Tire S/N', size=64)
is_tire_kmdi_set = fields.Boolean(string='Is KMDI Tire Srno set?')
position_tire = fields.Selection([('pos_1', 'Posisi 1'), ('pos2', 'Posisi 2'), ('pos3', 'Posisi 3'),
('pos4', 'Posisi 4'), ('pos5', 'Posisi 5'), ('pos6', 'Posisi 6'),
('pos7', 'Posisi 7'), ('posa', 'Posisi A'), ('posb', 'Posisi B'),
('posc', 'Posisi C'), ('posd', 'Posisi D'), ('pose', 'Posisi E'),
('posf', 'Posisi F'), ('posg', 'Posisi G'), ('posh', 'Posisi H'),
('posi', 'Posisi I'), ('posj', 'Posisi J'), ('posk', 'Posisi K'),
('posl', 'Posisi L'), ('posm', 'Posisi M')], string='Posisi Ban')
tire_size = fields.Char(string='Tire Size', size=64)
tire_srno = fields.Char(string='Tire S/N', size=64)
tire_issuance_date = fields.Date(string='Tire Issuance Date')

and xml

<xpath expr="///notebook/page[2]/notebook/page[2]" position="after">
<page string="Tire Detail">
<field name="tire_detail">
<tree editable="top">
<field name="position_tire"/>
<field name="tire_size"/>
<field name="tire_srno"/>
<field name="tire_kmdi"/>
<field name="tire_issuance_date"/>
</tree>
</field>
</page>
</xpath>

can anyone help me

아바타
취소
베스트 답변

You can create a list variable for selection field and on create / write method append your list in that variable which will add the value to the selection field.

Try following code:

POSITION_TIRE = [('pos_1', 'Posisi 1'), ('pos2', 'Posisi 2'), ('pos3', 'Posisi 3'),
('pos4', 'Posisi 4'), ('pos5', 'Posisi 5'), ('pos6', 'Posisi 6'),
('pos7', 'Posisi 7'), ('posa', 'Posisi A'), ('posb', 'Posisi B'),
('posc', 'Posisi C'), ('posd', 'Posisi D'), ('pose', 'Posisi E'),
('posf', 'Posisi F'), ('posg', 'Posisi G'), ('posh', 'Posisi H'),
('posi', 'Posisi I'), ('posj', 'Posisi J'), ('posk', 'Posisi K'),
('posl', 'Posisi L'), ('posm', 'Posisi M')]

class TireDetail(models.Model):
...
position_tire = fields.Selection(POSITION_TIRE, string='Posisi Ban')

POSITION_TIRE.append(('xyz', '123')) # append the value to the selection field in create / write method


아바타
취소
관련 게시물 답글 화면 활동
0
10월 19
2338
1
8월 18
8146
0
11월 17
38
3
12월 24
4388
5
7월 22
6160