i have to print like as previous year and present year
For Ex: if i given today date
it should show like 2018-19
when i give the date as my selection
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
i have to print like as previous year and present year
For Ex: if i given today date
it should show like 2018-19
when i give the date as my selection
First, create a sequence for your corresponding model.
eg:
1.
<record id="seq_id_id" model="ir.sequence">
<field name="name">name</field>
<field name="code">model.name</field>
<field name="prefix">- %(y) </field>
<field name="padding">3</field>
</record>
2.
override Create function:
from datetime import datetime, date
@api.model
def create(self, vals):
res = super(batch_payment, self).create(vals)
next_year = date.today().year - 1
res.name = str(next_year) + self.env['ir.sequence'].next_by_code('model.name')
# or use str(next_year)[2:] for geting last two digits. eg 2018 -> 18, use it for the sequence.
# do the changes needed. this is the logic
return res
Thanks for your answer
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Nov 24
|
262 | ||
|
1
Oct 24
|
328 | ||
|
4
Oct 24
|
323 | ||
Connect Odoo with unopim
Solved
|
|
2
Oct 24
|
360 | |
|
2
Dec 24
|
661 |