Odoo Help


How to create an incremental field (sequence) that is validated with a method (def).

on 2/25/16, 10:07 AM 842 views

Hello, i've one doubt:

I created a field called ' niu ' to increase its value for each product type stockable.

niu = fields.Char(string="NIU", compute="_niu_validation", defalut=" ", readonly=True)

With the attribute compute = "_ niu_validation " I call the method of the same name . In this , I want to validate that the product type is stockable type .


def _niu_validation(self):

if 'product_id.product_tmpl_id.type' == 'product':

niu = lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'sale.order.line')

return super(SaleOrderLine,self)

<?xml version="1.0" encoding="utf-8"?>


<data noupdate="1">

On the other hand I created the render sequence for ' niu ' field in sale.order.line model.

<!-- Sequence for sale.order.line -->

<record id="seq_sale_order_line" model="ir.sequence">

<field name="name">NIU Sequence</field>

<field name="code">sale.order.line</field>

<field name="prefix">00</field>

<field name="padding">3</field>




And in the view , I want for each product type stockable, the field 'niu' increase its value.

Image: http://en.zimagez.com/zimage/viewsequenceniu.php

Please I need help because I 've been a long time on this and I can't do it on my own. I hope your help , advice , recommendations. Thank you very much to all.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/25/16, 10:07 AM
Seen: 842 times
Last updated: 2/25/16, 4:27 PM