计算字段未在one2many_list小部件的<tree>中显示值

时间:2017-09-23 16:32:31

标签: python-3.x odoo-10

#start    
    from odoo import fields, models, api
    class projo(models.Model):
        _name='projo'
        project = fields.Many2one('project', 'Project')
        engineer = fields.Many2one('engineer', 'Engineer')
        item_id = fields.One2many('book','item_id2')
    #compute function 1 and it is working.

-

        @api.one
        @api.depends('item_id')
        def _calcamount(self):
            currentamount = 0
            for projo in self.item_id:
                currentamount = currentamount+(projo.qty * projo.unitprice)
                self.totalam = currentamount
        totalam = fields.Integer(string='Total Amount', store=True, compute='_calcamount')

#product many2onefield
    class producta(models.Model):
        _name='producta'

        name = fields.Char('Name', required='true')

    class Book(models.Model):
        _name='book'

        item_id2 = fields.Many2one('projo')
        cr_date = fields.Date('Date')
        prod = fields.Many2one('producta', 'Product')
    Compute function 2 and it is not working.
        @api.one
        @api.depends('item_id')
        def _calccost(self):
            currenttotal = 0
            for book in self.item_id:
                currenttotal = currenttotal+(projo.qty * projo.unitprice)
                self.costtotal = currenttotal
        costtotal = fields.Integer(string='Total', store=True, readonly= False, compute='_calccost')

-

        qty = fields.Integer('Quantity')
        unitprice = fields.Integer('Unit Price')
        item_id = fields.One2many('book', 'item_id2')

0 个答案:

没有答案