Skip to Content
Menu
This question has been flagged
4 Replies
6451 Views

In Odoo 9, i created a module name "library", but how i can deploy sequences for my personal module ("library").

In Settings/Sequences i created the sequence "BKS" but how i can married this sequences with the records in my module ("library").

I need to see the sequence in my module tree view, like the sequences in Sale Order tree view (SO001).

My module tree view is working fine, i just need add the sequence column field BKS001...

***Update*** 10/dic/15: WORKING !!! MODULE SAMPLE TO ADD SEQUENCES TO CUSTOM MODULE.

Thank you Axel for you help, if someone needs to add sequences to his records can use this module as a guide:

http://www.clasificadoshidalgo.com/tmp/odoo9/sequencesincustommodule.tar.gz


Avatar
Discard
Best Answer

@Carlos

You need to get the next value of the sequence and you could do it at different moments like:
-   Using a default value for a field, not recomended because will move the sequence numbers even if the record is not saved
-   On the create method, get the value and assign it to the field in the vals dict.

-   On a button like the confirm button on Sale Orders, get the value and assign it to the field in the vals dict used for call the write method.
To get the sequence value of a sequence with code(type of sequence) = library.sequence" you could do it like:

next_value = self.env['ir.sequence'].next_by_code('library.sequence') or '/'

Hope this helps

***Update***

Just put a label like in sale.order view

<h1>

<label string="Quality"/>

<field name="seq" class="oe_inline" readonly="1"/>

</h1>

Avatar
Discard
Author

i have a module name "quality" (this module is working good). models.py code:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
class myquality(models.Model):
	_name = 'myquality.myquality'
	product_sn = fields.Char(string='Serial Number', required=True,)
	date = fields.Date(string='Date')
	description = fields.Text('Notes')
templates.xml code:

    
		
		
		
		
		
        
            Quality
            myquality.myquality
            tree,form
        
		
        
 		
        
            view.quality.fdi.tree
            myquality.myquality
            
                
					
                    
                
            
        
 		
        
            view.quality.fdi.form
            myquality.myquality
            
                
                    
                        
                            
								                               
                                
								
                            
                        
                        
                            
                                
                            
                        
                    
                
            
        
    
then i have another module name "mysecuencia" inherits my quality, the sequence must be assigned up when the record is written. the module name "mysecuecia" add the sequences to settings/sequences and then i need add the sequences value to the "myquality" tree view but in this step i do not know how do that. __openerp__.py code:
...
'data': [
        # 'security/ir.model.access.csv',
        'views.xml',
        'templates.xml',
		'secuencias.xml',
    ],
...
models.py code:
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class mysecuencia(models.Model):
	_inherit = 'myquality.myquality'
	fdi_code = fields.Char ('FDI Code', size=6, readonly=True)
	def create(self, cr, uid, vals, context=None):
		vals['fdi_code']=self.pool.get('ir.sequence').get(cr, uid,'myquality.myquality')
		res=super(myquality_myquality, self).create(cr, uid, vals)
		return res
secuencias.xml code:

    
 		
        
            FDI Code
            myquality.myquality
			TRUE
			FDI
			1
			1
            3
			standard
        
        


		
			my.secuences.in.fdi.tree.inherit
			myquality.myquality
			
			
				
					
				
			
		
    

in templates.xml there are nothing.
Author

Axel, ca you donwload my modules at: http://clasificadoshidalgo.com/tmp/odoo9/modules.tar.gz The module myquality works fine The module mysecuencia must: 1.- Add a sequence "FDI" to settings/sequences

I made some changes to the code of your module mysecuencia. Basically I add a new field "seq" and override the create method to show you what I told you on my answer. You can donwload it from
http://filesftp.soltein.org/files/mysecuencia.zip Don't forget to upvote and accept the answer if was helpful to you

Author

Axel, Thank you very much :-). It works. When i save the new record, the title name is "Quality / myquality.myquality,1" Do you know how put the title like "Quality / FDI001" just like sale order "Quotation / SO001"

Just put a label, see the answer update since I cannot put html code in comments

Author

Thank you Axel, in this picture i show you what title i need to change to Quality / FDIXXX: http://clasificadoshidalgo.com/tmp/odoo9/title.jpg if i put you previus code just add a white line in the top of the form with label "Quality". Thank you for you help.

Author Best Answer

Axel, ca you donwload my modules at: http://clasificadoshidalgo.com/tmp/odoo9/modules.tar.gz

The module myquality works fine

The module mysecuencia must:

1.- Add a sequence "FDI" to settings/sequences <--works fine

2.- Add a column "hello" to the tree view myquality (this is for test only) <--works fine

3.- Add a column "FDI Number" to the tree view myquality with the sequences of the records in myquality <-- I DO NOT KNOW HOW DO THIS.

Axel, the sequence number must be assigned up after the record is written, exactly like in quotation SO001 in the case of myquality module must be after the record was created, in the myquality tree view must be something like FDI001.

***Update*** 10/dic/15: WORKING !!! MODULE SAMPLE TO ADD SEQUENCES TO CUSTOM MODULE.

Thank you Axel for you help, if someone needs to add sequences to his records can use this module as a guide:

http://www.clasificadoshidalgo.com/tmp/odoo9/sequencesincustommodule.tar.gz

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 23
497
0
Sep 23
450
3
Sep 23
1780
2
Feb 23
9253
6
Oct 23
19278