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

Hi everyone, after much research I find myself asking for help for something, I think, quite simple.

I have a Many2many field, which I fill through a search in a computed one, checking the entered values ​​are correct (I also have another field which with the sum of the ids obtained from the search)

I use the Many2many field in an action to display a treeview with the records that interest me, through the domain.

But I have a problem:
when I call the action check that the Many2many field is empty.
I also tried to enter store = True but to no avail. What am I doing wrong?
Thanks in advance

compute function

    @api.multi
    def _compute_potential_customer_count(self):
        self.potential_customer_ids = self.env["res.partner"].search(
            [
                ("country_id", "=", self.city_id.country_id.id),
                ("city", "=", self.city_id.name),
                ("certification_ids", "in", self.certificate_ids.ids),
            ]
        )        
        self.potential_customer_count = len(self.potential_customer_ids)

action


    @api.multi
    def action_customer(self):
        return {
            "name": "Potential Customer",
            "type": "ir.actions.act_window",
            "res_model": "res.partner",
            "view_mode": "tree",
            "res_id": False,
            "domain": [("id", "in", self.potential_customer_ids.ids)],
            "target": "current",
        }

Avatar
Discard
Best Answer

1. set store = True on an field.

2. on compute functions need @api.depends('field_triggered')

3. try put your function below.

4 . after all this , try uninstall the module and install for store that field.


Avatar
Discard
Related Posts Replies Views Activity
0
Aug 19
1793
1
Feb 23
796
2
Feb 23
1474
0
Jun 22
1471
0
Oct 21
1863