Quantcast
Channel: OpenERP Help - Individual question feed
Viewing all articles
Browse latest Browse all 39

Available Serial numbers for move lines

$
0
0
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) lines={} 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) cr.execute(sql) lines=cr.fetchall() return lines _columns = { 'lineas':fields.function(_get_lines,'lineas',type="char") } product_product() and my view: product.product.formproduct.productform 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.

Viewing all articles
Browse latest Browse all 39

Trending Articles