Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
1674 Weergaven

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:



Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Auteur

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

Gerelateerde posts Antwoorden Weergaven Activiteit
0
sep. 23
1308
2
aug. 22
5336
1
jul. 25
1350
2
mrt. 25
1615
0
feb. 25
1247