コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
2802 ビュー

class ArticleArticle(models.Model):

    _name = 'article.article'

     

    name = fields.Char(string='Lib :', required=True)

    price_unit = fields.Float(string='Prix :')

    q_int_en_stock = fields.Integer(string='Stock initiale :')

    img_article = fields.Binary("Image", attachment=True )


class IndexxLineline(models.Model):



 _name = 'indexx.lineline'

 

 

 name = fields.Char(string='Reference', index=True)

 releve_id = fields.Many2one('indexx.indexx', string='Releve')

 article_id = fields.Many2one('article.article', string='Article')

 p = fields.Float(string='Unit Price', readonly=True)

 index_ancien = fields.Float(string='Ancien Index')

 index_nouvel = fields.Float(string='Nouvel Index')

 price_subtotal = fields.Float(compute='_get_lecalcul')


when i select an Article  i need to get his price_unit and put it in the field p, how can i write the onchange function ?!

アバター
破棄
最善の回答

Hi,

Either you can onchange here or you can use the concept of the related field.


Thanks

アバター
破棄
最善の回答

Hi,

Try above: 

@api.onchange('article_id')
 def set_val(self):
    if article_id:
        self.p = self.article_id.price_unit 
アバター
破棄
関連投稿 返信 ビュー 活動
3
4月 19
3689
1
3月 19
4820
0
4月 24
963
2
12月 22
21615
2
2月 20
3963