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:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Nov 24
|
18020 | ||
|
1
Sep 23
|
1203 | ||
|
3
May 23
|
4092 | ||
|
7
Apr 23
|
47093 | ||
Barcode scanner from mobile
Solved
|
|
1
Dec 22
|
6435 |
Use meaningful titles for the questions