Hi, i want to create two different sequence in form for the same object like
field 1 : xxx/2018
field 2 : zz/C/0005
How i can achieve This please Help .
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi, i want to create two different sequence in form for the same object like
field 1 : xxx/2018
field 2 : zz/C/0005
How i can achieve This please Help .
Hi,
You can create multiple sequences for a model.
What you have to do is that,
In the XML file,
<record id="seq_student_application1" model="ir.sequence">
<field name="name">Student Application1</field>
<field name="code">education_application1</field>
<field name="prefix">SA1</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
<record id="seq_student_application2" model="ir.sequence">
<field name="name">Student Application2</field>
<field name="code">education_application2</field>
<field name="prefix">SA2</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
Then in the model, you can super the create method and assign the values for the field,
@api.model
def create(self, vals):
vals['application_no1'] = self.env['ir.sequence'].next_by_code('education_application1') or _('New')
vals['application_no2'] = self.env['ir.sequence'].next_by_code('education_application2') or _('New')
res = super(StudentApplication, self).create(vals)
return res
Fields added in the model,
application_no1 = fields.Char(string='Application No', required=True, copy=False, readonly=True,
index=True, default=lambda self: _('New'))
application_no2 = fields.Char(string='Application No2', required=True, copy=False, readonly=True,
index=True, default=lambda self: _('New'))
Thanks
Can i change invoice number sequence with the same approach?
Hello,
Can we create an auto increasing field using studio on Odoo 17?
Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!
Rekisteröidy| Aiheeseen liittyviä artikkeleita | Vastaukset | Näkymät | Toimenpide | |
|---|---|---|---|---|
|
1
maalisk. 23
|
2830 | |||
|
0
jouluk. 21
|
3853 | |||
|
0
kesäk. 24
|
2159 | |||
|
Many2many fields
Ratkaistu
|
2
maalisk. 23
|
4526 | ||
|
1
tammik. 17
|
9660 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.