Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how deploy sequences to the records in my particular module...

By
Carlos
on 12/9/15, 1:42 PM 588 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


1

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 12/9/15, 2:08 PM

@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>

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.
Carlos
on 12/9/15, 7:15 PM

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

Carlos
on 12/9/15, 7:50 PM

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

Axel Mendoza
on 12/9/15, 9:19 PM

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"

Carlos
on 12/10/15, 1:14 PM

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

Axel Mendoza
on 12/10/15, 1:36 PM

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.

Carlos
on 12/10/15, 3:51 PM
0
Carlos
On 12/9/15, 7:51 PM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/9/15, 1:42 PM
Seen: 588 times
Last updated: 12/10/15, 5:44 PM