Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
6299 มุมมอง

I have this object project.task that has many situations project.task.situation . In project.task.situation model I want to create a sequence so I added this record:

<record id="sequence_project_task_situation_seq" model="ir.sequence">
    <field name="name">Project Task Situation Sequence</field>
    <field name="code">project.task.situation</field>
    <field name="prefix">Situation N°</field>
    <field eval="1" name="number_next"/>
    <field eval="1" name="number_increment"/>
    <field eval="False" name="company_id"/>
</record>

In python code I added this:

name = fields.Char(string='Situation Number', readonly=True)
@api.model
def create(self, vals):
    seq = self.env['ir.sequence'].next_by_code('project.task.situation') or '/'
    vals['name'] = seq
    return super(ProjectTaskSituation, self).create(vals)

what I want is each task has its own situation sequence. For example for task1 I create 2 situations so I have Situation N°1 and Situation N°2 after that I want to create situations for task2 so I'll get Situation N°3 and Situation N°4 . Which is not good cause I want for each task to start count sequence from the start. Is this possible? How is that?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Did you find solution for this?

อวตาร
ละทิ้ง
ผู้เขียน

No

คำตอบที่ดีที่สุด

Hi Tessnim,
you can not create 2 sequences for one model (project.task.situation)

อวตาร
ละทิ้ง
ผู้เขียน

It's the same sequence, but I want it to start over again for each task.

Related Posts ตอบกลับ มุมมอง กิจกรรม
Showing many2one fields in other modules แก้ไขแล้ว
2
ก.พ. 18
12307
value from Many2one is None แก้ไขแล้ว
1
ก.ค. 23
2258
1
ก.ค. 19
6272
2
ก.ค. 18
8111
1
เม.ย. 15
4144