Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
1677 Переглядів

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

Related Posts Відповіді Переглядів Дія
0
вер. 23
1308
2
серп. 22
5337
1
лип. 25
1350
2
бер. 25
1616
0
лют. 25
1249