This question has been flagged
1620 Views

hello guys, im trying to implement module func_timeout on odoo to set timeout on when process on odoo function takes time too long (about 1 hour), but im encounter some issue 

AttributeError: environments,

if i print the "picking" it works it return like this stock.picking(188013,) but if i tried to print attribute name and id on picking object it returns that error

here are my base code

```

    @api.model
    def odoo_stock_picking_process_from_external(selfvals):
        """
        Processing stock picking document. One function to handle reserve and unreserve to avoid db locking
        """
        picking = self.browse(vals.get("picking_id"))
        if vals.get("type") == "assign_picker":
            try:
                data = {
                    'vals': vals
                }
                doitReturnValue = func_timeout(5self.odoo_assign_picker, kwargs=data)
            except FunctionTimedOut:
                print ( "doit('arg1', 'arg2') could not complete within 5 seconds and was terminated.\n")
            except Exception as e:
                data = {
                    "return_failed": {
                        "model""stock.picking",
                        "method""send_email_fail_assign_picker",
                        "args": [picking.ids, vals.get("user_id")],
                        "context": {},
                        "uid": vals.get("user_id"),
                    },
                    "error_message"str(e),
                    "subject_failed""wpd.warungpintar.co",
                }
                raise Exception(json.dumps(data))

    @api.model
    def odoo_assign_picker(selfvals):
        print('Got in!!')
        picking = self.browse(vals.get("picking_id"))
        print(picking, 'Picking Object')
        print(picking.name, 'Picking Name')
        picking.write({"picked_by": vals.get("picked_by"), "checked_by": vals.get("checked_by")})
        picking.action_assign_picker()
        return "Published"
```

thanks for the help
Avatar
Discard