Scarlett stone
Scarlett stone

Reputation: 225

Odoo, Condition in record tag

i have a question about odoo or specific about record tag on xml odoo. Can i give a condition for record tag. example like this :

    <record id="A" model="res.groups">
        <field name="name">Record A</field>
    </record>

    <record id="B" model="res.groups">
        <field name="name">Record B</field>
    </record>

I have a two record's and i want give a condition like, if record id=A is True, i want record id=B following the record id=A, become True.

Upvotes: 2

Views: 575

Answers (1)

Charif DZ
Charif DZ

Reputation: 14721

No. Because wat odoo do is convering the record tag to an insert query or update query the id returned by the insertion is mapped with the attribute id (id="A") this why we call it xml-id. and if you want to get the id in database we do this for example: self.env.ref('xml_id_here')

But if you want complicated things like that what you should do is use python code using the function tag:

   <function model="model.name" name="method_name" />

in your model:

  class ModelName(models.Model):
        _name = 'model.name'
        ....
        ....
        @api.model
        def method_name(self):
            # and here you can use the power of python to do 
            # anything you want

Upvotes: 2

Related Questions