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

Hi,

I'm trying to create a simple field that totals the Labour Cost and Material Cost fields shown on this screenshot. All fields are 'float', but no matter what I do, I keep getting error messages.

All Field names are shown within the XML view on the left.

In the example given, I would like the Total Cost field to show '7' (2+5), but without needing to manually input the number.

In an ideal world, I would also like these fields displayed as a monetary value.

Any ideas:



アバター
破棄
最善の回答

Hi, 


you could create a field in your model and create a compute method to do this, but you need it in python:



class MyModel(models.Model):
    _name = 'my.model'

    field1 = fields.Float(string='Field 1')
    field2 = fields.Float(string='Field 2')
    computed_field = fields.Float(string='Computed Field', compute='_compute_computed_field')

    @api.depends('field1', 'field2')
    def _compute_computed_field(self):
        for record in self:
            record.computed_field = record.field1 + record.field2


I hope these code help to you

Bye

アバター
破棄
著作者

Hi, I don't have access to the Python code, as our server is hosted externally
Is there any way I can do this via Studio/XML?

As far as I know you can't make a compute field via XML. I don't know if it is possible via Studio. Sorry

関連投稿 返信 ビュー 活動
0
9月 23
1308
2
8月 22
5340
1
7月 25
1352
2
3月 25
1617
0
2月 25
1251