Odoo Help


Available Serial numbers for move lines

Pablo Gomez
on 9/11/13, 3:41 PM 1,065 views

Hi, Im triying to get from stock_moves the serial numbers that are available (( in + internal) not in (out)). the serial number is the name from the table stock.production.lot. I added two variables too needed for some pourposes (numero_ticket, numero_series)

well, I created one page in the product_normal_form_view, and inside this one, I want to show the serial numbers available (internal + in)-out. This is my class:

The problem is that I have no idea how to get the active product_id from view to use it on a query. Heres my poor code :):

class product_product(osv.osv):
    _name = "product.product"
    _inherit = "product.product"

    def _get_lines(self, cr, uid, ids,fields, arg, context):

        product = self.browse(cr,uid,id)
        sql = '''
            SELECT DISTINCT c.name, b.numero_ticket, b.numero_guia
                        FROM stock_move b, stock_picking a,stock_production_lot c
                        WHERE (a.id=b.picking_id)AND ((a.type='internal') OR (a.type='in'))AND(b.prodlot_id=c.id) AND (b.product_id=%s) AND c.name NOT IN
                            (SELECT c.name
                            FROM stock_move b, stock_picking a, stock_production_lot c
                            WHERE (a.id=b.picking_id)AND(a.type='out') AND (b.prodlot_id=c.id) AND (b.product_id=%s))''' % (product,product)


        return lines

    _columns = {



and my view:

 <record model="ir.ui.view" id="product_normal_form_view">
            <field name="name">product.product.form</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
                <field name="type">form</field>
                <field name="arch" type="xml">
                        <notebook position="inside">
                            <page string="N serie">
                                <field colspan="4" name="lineas"/><!-- nolabel="1" widget="one2many_list" > -->
                                    <!--<tree string="Lineas">
                                        <field name="prodlot_id"/>
                                        <field name="numero_ticket"/>
                                        <field name="numero_guia"/>


As you can see I have some troubles trying to fetch the result of the query and using it on the view. Every help will be so much appreciated. I think many people has the same problems as me, and I was searching for so long via google, so I think it can be useful for the rest of the comunity.

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

0 follower(s)


Asked: 9/11/13, 3:41 PM
Seen: 1065 times
Last updated: 3/16/15, 8:10 AM