Skip to Content
Menu
This question has been flagged
1 Reply
1994 Views

I'm running Odoo v13 Community Edition and I am trying to create a field in Purchase Order that changes its label and appears depending on the currency chosen in a many2one. I've overriden the purchase.order model and created the field. The following is the code I've written.

from odoo import api, fields, models

class PurchaseOrder (models.Model):

    _inherit = "purchase.order"

    rate = fields.Float(  )

    cur = fields.Boolean(compute="currency_rate", default=False)


    @api.depends("currency_id")

    def currency_rate(self):

        for po in self:

            if po['currency_id']:

                if po['currency_id'].name == "USD" or po['currency_id'].name == "EUR":

                    po.cur = True

                else:

                    po.cur = False 

I added this line to the field rate in the xml:

<field name="rate" attrs="{'invisible':[('cur', '=', False)]}"/>

The field rate does not appear as a default (as it should) but when I change the Currency field to USD or EUR this error pops up:

Avatar
Discard
Related Posts Replies Views Activity
3
Sep 20
3861
3
Dec 24
2362
1
Jul 24
705
1
Jun 24
774
2
Jun 24
897