[Python] How to create a virtual record of a variable?

Discussão em 'Python' iniciado por Stack, Abril 17, 2025.

  1. Stack

    Stack Membro Participativo

    I have this defined in my equipment:

    class AssetEquipment(model.Models):
    _name = "asset.tracking"
    _description = "Module to track asset movement"

    scrap_date = fields.Date('Scrap date')
    owner_id = fields.Many2one('res.users', string='Owner', default=False, tracking=True)
    status_id = fields.Selection([
    ('0', 'Inactive'),
    ('1', 'Active'),
    ('2', 'Under Repair'),
    ('3', 'Scrap'),
    ], string='Status', default='0', store=False, compute='_compute_status')


    The rule as follows:

    1. If the owner_id is blank, then the item status is inactive, otherwise it is active
    2. If the scrap_date is set, then status is Scrap or 3, and ignore owner_id field.
    3. This one is unimportant for this question, but if the computer check that this equipment has a pending maintenance progress, then the status is Under Repair.

    Now, _compute_status is not a problem, since I can make it myself.

    The problem is, I want to make something like owner_history that contains whole list of owner_id tracking value, with fields as date, owner_id, and status, gathered from tracking value and display them in tabular way, something like:

    <field name="owner_history">
    <list>
    <field name="date" />
    <field name="owner_id" />
    <field name="status" />
    </list>
    </field>


    How do I do that?

    Thank you

    Continue reading...

Compartilhe esta Página