18.How To Generate Sequential Value For Field In Odoo || Sequence in Odoo

  Рет қаралды 19,698

Odoo Mates

Odoo Mates

Күн бұрын

How to generate sequential value for a field in Odoo. Sequence in Odoo. How to define new sequence in Odoo for the models. Show how to define the new sequence and override the create method and assign the sequence value to the field.
Playlist: • 2. How To Create Modul...
Module: apps.odoo.com/...
Website: www.odoomates....
Github: github.com/odo...
Email : odoomates@gmail.com
Facebook: / odoomate
Twitter: / odoomates
Support Us in Ko Fi : ko-fi.com/odoo...

Пікірлер: 50
@GianmarcoContreras
@GianmarcoContreras Жыл бұрын
This is the best video of sequence in odoo 😎🤓
@OdooMates
@OdooMates Жыл бұрын
happy to hear it
@wilmerrodriguezs9306
@wilmerrodriguezs9306 2 жыл бұрын
In Colombia, "HP" is used as an abbreviation for something rude 🤣. Your videos are great, they help me a lot. Greetings.
@OdooMates
@OdooMates 2 жыл бұрын
not sure what is stands for HP in colombia :p anyway glad to know that videos are helpfull
@raphaelhuetdefroberville6452
@raphaelhuetdefroberville6452 3 жыл бұрын
Hello, Your videos are great ! It's great to show everything step by step and to show us the errors that we could have. On this course, in the model you write : vals['reference'] = self.env['ir.sequence'].next_by_code('hospital.patient') or _('New') I don't understand the utility of " or _('New')" at the end of the line.
@valentinacolautti367
@valentinacolautti367 2 жыл бұрын
Hi, i think because self.env['ir.sequ..] ecc is inside vals.get('reference') condition .... so it works after (when the code has taken the value).. after you have clicked the create button. The declaration of the default value in the table is general... it is applied before the 'get' so it is useful to show the title 'New' at the beginning of the creation
@OdooMates
@OdooMates 2 жыл бұрын
just to add along with @valentina, or _('New') will return the value as New or its translation(according to the language) when the sequence is not returning value from it, either you can give it or not, it depends on the coder
@maria.2506
@maria.2506 2 жыл бұрын
hi there and greetings, Great video on the topic. Query: can we create a sequence depending on another field, e.g. gender, separate sequence for male, female & others. if yes please guide us in doing so. Lots of thanks for yr good work, plz keep it up. Regards
@ramamadeit5280
@ramamadeit5280 Жыл бұрын
Hello, i have typed the code according to the example in your video, but i got an error : TypeError: create() missing 1 required positional argument: 'vals' (if I click the create button , that error will appear) can you help me ? Thank you.
@OdooMates
@OdooMates Жыл бұрын
can you share us the written code
@ramamadeit5280
@ramamadeit5280 Жыл бұрын
@@OdooMates my code : # -*- coding: utf-8 -*- from odoo import api, fields, models class TambahanEN(models.Model): _name = "tambahanen" _inherit = ['mail.thread', 'mail.activity.mixin'] _description = "Tambahan Eastech Nusantara" nomerseq = fields.Char(string='Nomer Sequence', required=True, copy=False, readonly=True, default=lambda self: _('New')) name = fields.Char(string='Name', tracking=True) note = fields.Text(string='Description', tracking=True) state = fields.Selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')], default='draft', string="Status", tracking=True) contohmanytoone_id = fields.Many2one('res.partner', string="Contoh Many to One") def action_draft(self): self.state = 'draft' def action_confirm(self): self.state = 'confirm' def action_done(self): self.state = 'done' def action_cancel(self): self.state = 'cancel' def create(self,vals): res = super(TambahanEN, self).create(vals) return res @api.model def create(self, vals): if not vals.get('note'): vals['note'] = 'Kosong' if vals.get('nomerseq', _('New')) == _('New'): vals['nomerseq'] = self.env['ir.sequence'].next_by_code('coba.sequences') or _('New') res = super(TambahanEN, self).create(vals) return res
@renaacer
@renaacer 2 жыл бұрын
When you receipt the purchase you can write custom lot/serial numbers. Can i add sequential value in a table(one2many lines)?
@OdooMates
@OdooMates 2 жыл бұрын
possible to achieve, something like auto lot generation ?
@renaacer
@renaacer 2 жыл бұрын
@@OdooMates You must put the sequence every time you click to add line
@OdooMates
@OdooMates 2 жыл бұрын
@@renaacer yes possible
@renaacer
@renaacer 2 жыл бұрын
@@OdooMates If i'll see you video "45. how to add one2many field" can i?
@OdooMates
@OdooMates 2 жыл бұрын
@@renaacer kzbin.info/www/bejne/eauYloBre6mgiqc
@rishalchand6935
@rishalchand6935 2 жыл бұрын
Hello. Can you tell how this can be achieved on a existing custom field which is in CRM. I want to make my existing custom field to auto generate sequence.
@OdooMates
@OdooMates 2 жыл бұрын
by inheriting the corresponding model and follow the same steps
@walidsehil9637
@walidsehil9637 2 жыл бұрын
@@OdooMates if no existing model to inherit ?? !
@hoangvunhat3600
@hoangvunhat3600 3 жыл бұрын
Hi, thank you so much for the video. I have a question. I created several patients before watching this video. So how can I re-count or set the sequential value from the first patient that I created?
@OdooMates
@OdooMates 3 жыл бұрын
either you can delete and create again or run a script to update existing record
@hoangvunhat3600
@hoangvunhat3600 3 жыл бұрын
@@OdooMates Hi thanks, do you have any video that guide to update the records?
@OdooMates
@OdooMates 3 жыл бұрын
@@hoangvunhat3600 using a server action that runs python code, you can update using the write orm method or direcly update sequence from db, may i know how many records you have ? this is test db right ?
@hoangvunhat3600
@hoangvunhat3600 3 жыл бұрын
@@OdooMates Yes this is my test db. I have only few records (about 10) and it's easy to delete and create again. But I just want to know if there is a method to update the sequential values without deleting records. Just in case for example, we don't add the sequential values at the beginning of the project.
@hoangvunhat3600
@hoangvunhat3600 3 жыл бұрын
@@OdooMates sorry I'm quite new to Odoo so it might be hard for me to catch up your ideas. Do you have any tutorials in your playlist talking about this?
@javaidkhan7410
@javaidkhan7410 2 жыл бұрын
good work
@OdooMates
@OdooMates 2 жыл бұрын
❤️❤️❤️
@engineerasmaa4658
@engineerasmaa4658 2 жыл бұрын
Your videos are great 👌👏
@OdooMates
@OdooMates 2 жыл бұрын
Thanks dear
@captainleonard123
@captainleonard123 3 жыл бұрын
can we still achieve this without coding?
@OdooMates
@OdooMates 3 жыл бұрын
yes possible. see: kzbin.info/www/bejne/eauYloBre6mgiqc
@indeveloperid6061
@indeveloperid6061 2 жыл бұрын
Is this important to add noupdate="1" ?
@OdooMates
@OdooMates 2 жыл бұрын
yes it has to add, we have missed it to specify it during its creation, we have created a separate video on no update attribute: kzbin.info/www/bejne/eGqxmpahbKihhKM shceduled it for may 17
@souravpanda3335
@souravpanda3335 2 жыл бұрын
I don't have a data folder in side my om_hospitail what to do
@OdooMates
@OdooMates 2 жыл бұрын
apps.odoo.com/apps/modules/14.0/om_hospital/
@OdooMates
@OdooMates 2 жыл бұрын
github.com/odoomates/odooapps/tree/14.0/om_hospital/data
@waleedahmed396
@waleedahmed396 3 жыл бұрын
can't I just Add Auto increment column in the database and connect it to the code?
@OdooMates
@OdooMates 3 жыл бұрын
current approach seems more easy and user friendly right ?
@arsamjunaid318
@arsamjunaid318 2 жыл бұрын
not getting sequence
@OdooMates
@OdooMates 2 жыл бұрын
can you check the db and see whether the sequence record get added in the db or not
@farseenpk9793
@farseenpk9793 2 жыл бұрын
How to reset this sequence daily??
@OdooMates
@OdooMates 2 жыл бұрын
but using code, it will be possible, then there will be a duplicated sequence number right ?
@farseenpk9793
@farseenpk9793 2 жыл бұрын
@@OdooMates no .but..is there any chance to give scheduled action for 'next_number'
@OdooMates
@OdooMates 2 жыл бұрын
@@farseenpk9793 yes inside scheduled action you can execute python code, and using orm method, search for the sequence, and then using write method update the next number
@farseenpk9793
@farseenpk9793 2 жыл бұрын
@@OdooMates thank u sir
@OdooMates
@OdooMates 2 жыл бұрын
@@farseenpk9793 welcome
@VonFixxxer
@VonFixxxer 2 жыл бұрын
Hello again, master! My teacher is asking for a similar thing, but in this case he also wants that each code number can be reused if the user (the patient in your case) is deleted. What would be your approach to this?
@OdooMates
@OdooMates 2 жыл бұрын
using sequence it will be hard to resuse the deleted sequence number, if you are forced to do it, using python code, you can find missing sequence and set it to newly creating records
Кәсіпқой бокс | Жәнібек Әлімханұлы - Андрей Михайлович
48:57
🕊️Valera🕊️
00:34
DO$HIK
Рет қаралды 3,2 МЛН
Odoo Studio: approvals and workflows
27:09
Odoo
Рет қаралды 20 М.
Think Fast, Talk Smart: Communication Techniques
58:20
Stanford Graduate School of Business
Рет қаралды 41 МЛН
Odoo Calculated Field (All Odoo Versions)
15:07
Odoo Studio Tutorials
Рет қаралды 9 М.
How Prometheus Monitoring works | Prometheus Architecture explained
21:31
TechWorld with Nana
Рет қаралды 1 МЛН
How to add sequence on Date basis in Odoo? | Odoo development
20:51
Odoo Discussions
Рет қаралды 863