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

Update record in tables

By
Trai Doan
on 11/20/14, 10:53 AM 479 views

My codes :

  

      class stock(osv.osv):
        _name = "tt_stock" 
        _columns = {
            'name': fields.char('Code',size=20,required=True), 
            'ten': fields.char('Name',size=100,required=True),
            'loai': fields.char('Kind',size=100,required=True),
            'sl': fields.integer('Number',required=True),
            'ds':fields.many2one('tt_phieunhap','Danh sách'),
        }
    stock()
    
        class material(osv.osv):
        _name = "tt_material" 
        _columns = {
            'name': fields.many2one('tt_stock','Code',required=True), 
            'ten': fields.char('Name',size=100),
            'loai': fields.char('Kind',size=100),
            'sl': fields.integer('Number',required=True),
            'ds':fields.many2one('tt_bill','List'),
    }
        def onchange_nhap(self,cr,uid,ids,name,context=None):
            value={}
            if name:
                record=self.pool.get('tt_stock').browse(cr,uid,name,context=context)
                value['ten']=record.ten
                value['loai']=record.loai
                value['sl']=record.sl
            else:
                value['ten']=None
                value['loai']=None
                value['sl']=0
            return {'value':value}
    material()
     class bill(osv.osv):
        _name = "tt_bill" 
        _columns = {
            'name': fields.char('Code',size=20,required=True),
            'ngay':fields.date('Date'),
            'danhsach': fields.one2many('tt_material','ds','Material List'),
             }
     bill()


When i create a new bill , i will create a list of material needed and after that i have a button to update my number  in stock likes this:

Stock - begin
    
    Code  ||  Name  ||  Kind  ||  Number 
    1         fish      food      100
    2        ice-cream  food      50
    3         candy     candy    250


Bill 
    
     Code : 1a
     Date :1/1/2015
     List of Material
     Code  ||  Name  ||  Kind  ||  Number 
        1       fish      food      10
        3       candy     candy    500

 

and after i save its ,it will auto update the number in Stock

Stock - After
        
        Code  ||  Name  ||  Kind  ||  Number 
        1         fish      food      110
        2        ice-cream  food      50
        3         candy     candy     750

I'm new in Openerp .Please help me to solve this ,thanks for your help .

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: 11/20/14, 10:53 AM
Seen: 479 times
Last updated: 3/16/15, 8:10 AM