Note that there are some explanatory texts on larger screens.

plurals
  1. POSequence number in field - OpenErp
    primarykey
    data
    text
    <p>I need to load a sequence number in a specific field.</p> <p>For this i'm using the <code>ir.sequence</code> model, as i have seen in other modules.</p> <p>Problem is , it is not working yet, i don't know what i'm doing wrong here, perhaps the examples i'm using just work for a "title" field?</p> <p>This is my code:</p> <pre><code>... _name = "product.product" _description = "Product" _table = "product_product" _inherits = {'product.template': 'product_tmpl_id'} _inherit = ['mail.thread'] _order = 'default_code,name_template' _columns = { 'codigo_n' : fields.char('Codigo Arancelario', size=64), 'tec_esp' : fields.char('Especificaciones tecnicas', size=72), 'qty_available': fields.function(_product_qty_available, type='float', string='Quantity On Hand'), 'virtual_available': fields.function(_product_virtual_available, type='float', string='Quantity Available'), 'incoming_qty': fields.function(_product_incoming_qty, type='float', string='Incoming'), 'outgoing_qty': fields.function(_product_outgoing_qty, type='float', string='Outgoing'), ... code keeps going... </code></pre> <p>Here the interesting field is <code>codigo_n</code> whic is of type <code>char</code>i added the <code>_defaults</code> statement for this to work with <code>ir.sequence</code> as follows:</p> <pre><code>_defaults = { 'codigo_n': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid,'product.product'), } </code></pre> <p>Obviously i created the .xml sequence file, added to the <code>data</code> dependencies in the <code>__openerp__.py</code> file, and this is the code of the <code>custom_sequence.xml</code>:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;openerp&gt; &lt;data noupdate="1"&gt; &lt;!-- Secuencias para product.product --&gt; &lt;record id="seq_type_product_product" model="ir.sequence.type"&gt; &lt;field name="name"&gt;Product&lt;/field&gt; &lt;field name="code"&gt;product.product&lt;/field&gt; &lt;/record&gt; &lt;record id="seq_product_product" model="ir.sequence"&gt; &lt;field name="name"&gt;Product&lt;/field&gt; &lt;field name="code"&gt;product.product&lt;/field&gt; &lt;field name="prefix"&gt;NG&lt;/field&gt; &lt;field name="padding"&gt;5&lt;/field&gt; &lt;field name="company_id" eval="False"/&gt; &lt;/record&gt; &lt;/data&gt; &lt;/openerp&gt; </code></pre> <p>I think this is the correct way to setup this, i just need to make <code>codigo_n</code> to work with this sequence, any ideas of why it is not working?</p> <p>I hope i've explained myself.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload