Skip to Content
Menu
This question has been flagged

So, i have 1 field (price) from transaction. The type of the field is float. I want to use that field in another model (transaction.report). How to get the value from transaction and use it in transaction.report?


from odoo import api, fields, models, tools

class Transaction(models.Model):
     _name = "transaction"


     price = fields.Float(string='Price)
Avatar
Discard
Best Answer

Hi,

In your transaction.report model you can create a Many2one field related to the transaction model first.

transaction_id = fields.Many2one(‘transaction’)

After that, you create a float field for price in transaction.report model

price = fields.Float(related=’transaction_id.price’)

In this way the price field will get the same value as the price of transaction(the record in the transaction_id field)

Regards

Avatar
Discard
Related Posts Replies Views Activity
1
Jun 24
305
1
Dec 21
3415
0
Apr 19
2056
1
Nov 22
2731
0
Oct 19
3165