this is my code
py file:
@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['sequence_id']=self.env['ir.sequence'].next_by_code('seq.attendance') or '/'
return super(attendance, self).create(vals)
xml file:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="seq_atttendance" model="ir.sequence">
<field name="name">General Files proceedings Sequence</field>
<field name="code">seq.attendance</field>
<field name="prefix">File/%(year)s/%(month)s/%(day)s/</field>
<field name="padding">5</field>
<field eval="1" name="number_increment"/>
</record>
</data>
</odoo>
where is the problem could you please give me the solution
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
Bu soru işaretlendi
Hi,
If you are looking to create a sequence for your model, please see the below code for the sale order sequence.
In XML, define the sequence,
<record id="seq_sale_order" model="ir.sequence">
<field name="name">Sales Order</field>
<field name="code">sale.order</field>
<field name="prefix">SO</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
Then In the Python define a field to which the sequence has to be given,
name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, index=True, default=lambda self: _('New'))
Then override the create method and assign the sequence,
@api.model
def create(self, vals):
if vals.get('name', _('New')) == _('New'):
vals['name'] = self.env['ir.sequence'].next_by_code('sale.order') or _('New')
result = super(SaleOrder, self).create(vals)
return result
Thanks
Hello,
Have you given proper inheritance for attendance model?
Have you added .py in __init__.py and xml file in __manifest__.py?
Logged in user having permission to read ir.sequence?
hey your are missed the below line in xml
<field name="use_date_range">True</field>
Try this
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="seq_atttendance" model="ir.sequence">
<field name="name">General Files proceedings Sequence</field>
<field name="code">seq.attendance</field>
<field name="prefix">File/%(year)s/%(month)s/%(day)s/</field>
<field name="padding">5</field>
<field name="use_date_range">True</field>
<field eval="1" name="number_increment"/>
</record>
</data>
</odoo>
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Olİlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
---|---|---|---|---|
|
1
Kas 24
|
20215 | ||
|
1
Eyl 23
|
3029 | ||
|
3
May 23
|
5634 | ||
|
7
Nis 23
|
49007 | ||
Barcode scanner from mobile
Çözüldü
|
|
1
Ara 22
|
7874 |
Use meaningful titles for the questions