odoo-ide / vscode-odoo

Visual Studio Code extension for Odoo
https://marketplace.visualstudio.com/items?itemName=trinhanhngoc.vscode-odoo
48 stars 3 forks source link

Nothing in problems tab since last update #72

Closed mathisgauthey closed 5 months ago

mathisgauthey commented 7 months ago

Hey there, since last update (0.22.5), I can't see any issues under the PROBLEMS tab, even when opening files where there are functions using unknown fields and so on.

It worked fine yesterday.

Here are the logs :

[Info  - 9:16:30 AM] Pyright language server 1.1.356 starting
[Info  - 9:16:30 AM] Server root directory: file:///home/mat/.vscode-server/extensions/trinhanhngoc.vscode-odoo-0.22.5-linux-x64/dist
[Info  - 9:16:30 AM] Data storage path: /home/mat/.vscode-server/data/User/workspaceStorage/66f02000b51a8ca9724f31223ccca354/trinhanhngoc.vscode-odoo
[Info  - 9:16:30 AM] Starting service instance "odoo-dev"
Received pythonPath from Python extension: /home/mat/documents/odoo-dev/venv_odoo/bin/python
[Info  - 9:16:32 AM] Background analysis(2) root directory: file:///home/mat/.vscode-server/extensions/trinhanhngoc.vscode-odoo-0.22.5-linux-x64/dist
[Info  - 9:16:32 AM] Background analysis(2) started
[Info  - 9:16:32 AM] Setting pythonPath for service "odoo-dev": "/home/mat/documents/odoo-dev/venv_odoo/bin/python"
[Warn  - 9:16:32 AM] stubPath file:///home/mat/documents/odoo-dev/typings is not a valid directory.
[Info  - 9:16:33 AM] Assuming Python version 3.10.12.final.0
[Info  - 9:16:33 AM] Auto-excluding /home/mat/documents/odoo-dev/venv_odoo
[Info  - 9:16:33 AM] Found 6218 source files

As I was writing the post, I noticed it generated something :

image

But using PyRight and not the usual Odoo IDE Code message. The source is _generated_diagnostic_collection_name, I found this.

My project is inside WSL.

trinhanhngoc commented 7 months ago

Hello @mathisgauthey ,

I haven't seen any issues with the last update (0.22.5) yet. Do you have code samples to reproduce the issue?

mathisgauthey commented 7 months ago

Sure.

import logging
from datetime import timedelta, datetime

from odoo import fields, models, api, _
from odoo.addons.okteo_ouktuva import ride_utils
from odoo.exceptions import UserError, ValidationError
from odoo.tools import float_round
from odoo.tools import format_date

_logger = logging.getLogger(__name__)

class Ride(models.Model):

    # ---------------------------------------- Private Attributes ---------------------------------

    _inherit = ['mail.thread', 'mail.activity.mixin', 'avatar.mixin']
    _name = 'ouktuva.ride'
    _description = 'Ride'
    _rec_name = "name"

    # --------------------------------------- Fields Declaration ----------------------------------

    # Basic
    notice_driver = fields.Selection([
        ('yes', 'Yes'),
        ('no', 'No'),
        ('partial', 'Partial'),
    ], default='no', string="Notice Driver")

    # Special
    state = fields.Selection(
        selection=[
            ('1_scheduled', 'Scheduled'),
            ('2_in_progress', 'In progress'),
            ('3_done', 'Done'),
            ('4_canceled', 'Canceled'),
        ],
        string='Status',
        required=True,
        readonly=True,
        copy=False,
        tracking=True,
        default='1_scheduled',
        compute='_compute_status',
        store='True'
    )
    active = fields.Boolean('Active', default=True, tracking=True)

    # Relational
    available_vehicles_ids = fields.Many2many('fleet.vehicle', store=True,
                                              compute="_compute_available_vehicles_ids")
    participation_ids = fields.One2many('ouktuva.ride.participation',
                                        'ride_id',
                                        'CARPOOLERS', copy=False)
    departure_city_id = fields.Many2one('res.city', 'Departure City',
                                        required=True)
    arrival_city_id = fields.Many2one('res.city', 'Arrival City',
                                      required=True)
    vehicle_id = fields.Many2one('fleet.vehicle', "Vehicle", required=True,
                                 domain="[('id', 'in', available_vehicles_ids)]")
    company_id = fields.Many2one('res.company', 'Company',
                                 default=lambda self: self.env.company)
    driver_id = fields.Many2one('hr.employee', string='Driver', required=True,
                                default=lambda self: self.env.user.employee_id, copy=False)
    current_campaign_id = fields.Many2one('ouktuva.campaign', 'Campaign',
                                          compute='_compute_current_campaign_id',
                                          store=True)
    agency_id = fields.Many2one(related="vehicle_id.agency_id",
                                string="Agency Location", readonly=True)
    seats_number = fields.Integer('Seats', related="vehicle_id.seats")

    departure_date = fields.Datetime('Departure Date', required=True)
    arrival_date = fields.Datetime('Arrival Date', required=True)
    name = fields.Char("Ride Name", translate=True)
    formatted_date = fields.Char(string="Date", compute="_compute_format_date",
                                 store=True)
    carpoolers_count = fields.Char(compute='_compute_passengers_count',
                                   string='Carpoolers', readonly=True,
                                   store=True)

    # Computed
    distance = fields.Float('Distance', readonly=True,
                            compute="_compute_distance", store=True)
    total_carbon_estimated = fields.Float(string="Total Carbon Estimated (Kg CO2 / Ride)",
                                          compute='_compute_total_carbon_estimated', store=True)
    individual_carbon_estimated = fields.Float(
        string="Estimated Individual Carbon Emissions",
        compute='_compute_individual_carbon_estimated', store=True)
    earned_points = fields.Float('Earned Points', readonly=True,
                                 compute='_compute_individual_carbon_estimated',
                                 store=True)
    saved_km = fields.Float("Kilometers Saved",
                            compute="_compute_saved_km", store=True)
    total_passengers = fields.Integer(compute='_compute_passengers_count',
                                      string='Number Of Passengers',
                                      store=True)
    total_carpoolers = fields.Integer(compute='_compute_passengers_count',
                                      string='Number Of Carpoolers',
                                      store=True)
    carpooling = fields.Integer(compute='_compute_passengers_count',
                                string='Carpooling',
                                store=True)
    available_seats = fields.Integer(compute='_compute_passengers_count',
                                     string='Available Seats',
                                     store=True, default=0)

@api.model
    def write(self, vals):
        for rec in self:
            old_driver_id = rec.driver_id
            old_driver_partner_id = rec.driver_id.user_partner_id.id
        result = super(Ride, self).write(vals)
        for ride in self:
            if 'participation_ids' in vals:
                for participation in ride.participation_ids:
                    if participation.carpooler_id:
                        ride.message_subscribe(
                            [participation.carpooler_id.user_partner_id.id])

            if 'driver_id' in vals:
                new_driver_id = vals.get('driver_id')
                if new_driver_id and old_driver_id != new_driver_id:
                    new_driver_partner_id = ride.driver_id.user_partner_id.id
                    ride.message_unsubscribe([old_driver_partner_id])
                    ride.message_subscribe([new_driver_partner_id])

        return result

Yesterday, I had an issue on the old_driver_id which I was going to fix today, but now the Odoo IDE doesn't generate any PROBLEMS and my WSL RAM usage is skyrocketting.

mathisgauthey commented 7 months ago

Update :

Rolling back to yesterday extension settings and version seems to fix it.

image

But I'm having monstrous VRAM usage :

image

Can't seem to find out why yet

mathisgauthey commented 7 months ago

Hey there. I got back from my workspace state of yesterday.

At launch, I have an Intellicode error as well, output is on the screenshot. Pylance seems to get disabled by itself I don't know exactly why.

And the RAM usage was linked to Intellicode API Usage Examples.

image

I can't have Pylance activated and working with Intellicode, I think the issue might be situated somewhere around here.

I'm pretty sure I used to be able to have both extensions

mathisgauthey commented 7 months ago

Usage with API Usage Examples activated :

image

/home/mat/.vscode-server/bin/863d2581ecda6849923a2118d93a088b0745d9d6/node /home/mat/.vscode-server/extensions/visualstudioexptteam.intellicode-api-usage-examples-0.2.8/dist/server/server.js --node-ipc --clientProcessId=19110

After disabling API Usage Examples :

image

Hope it helps. I'll stay here and happy to help.

trinhanhngoc commented 7 months ago

Sure.

import logging
from datetime import timedelta, datetime

from odoo import fields, models, api, _
from odoo.addons.okteo_ouktuva import ride_utils
from odoo.exceptions import UserError, ValidationError
from odoo.tools import float_round
from odoo.tools import format_date

_logger = logging.getLogger(__name__)

class Ride(models.Model):

    # ---------------------------------------- Private Attributes ---------------------------------

    _inherit = ['mail.thread', 'mail.activity.mixin', 'avatar.mixin']
    _name = 'ouktuva.ride'
    _description = 'Ride'
    _rec_name = "name"

    # --------------------------------------- Fields Declaration ----------------------------------

    # Basic
    notice_driver = fields.Selection([
        ('yes', 'Yes'),
        ('no', 'No'),
        ('partial', 'Partial'),
    ], default='no', string="Notice Driver")

    # Special
    state = fields.Selection(
        selection=[
            ('1_scheduled', 'Scheduled'),
            ('2_in_progress', 'In progress'),
            ('3_done', 'Done'),
            ('4_canceled', 'Canceled'),
        ],
        string='Status',
        required=True,
        readonly=True,
        copy=False,
        tracking=True,
        default='1_scheduled',
        compute='_compute_status',
        store='True'
    )
    active = fields.Boolean('Active', default=True, tracking=True)

    # Relational
    available_vehicles_ids = fields.Many2many('fleet.vehicle', store=True,
                                              compute="_compute_available_vehicles_ids")
    participation_ids = fields.One2many('ouktuva.ride.participation',
                                        'ride_id',
                                        'CARPOOLERS', copy=False)
    departure_city_id = fields.Many2one('res.city', 'Departure City',
                                        required=True)
    arrival_city_id = fields.Many2one('res.city', 'Arrival City',
                                      required=True)
    vehicle_id = fields.Many2one('fleet.vehicle', "Vehicle", required=True,
                                 domain="[('id', 'in', available_vehicles_ids)]")
    company_id = fields.Many2one('res.company', 'Company',
                                 default=lambda self: self.env.company)
    driver_id = fields.Many2one('hr.employee', string='Driver', required=True,
                                default=lambda self: self.env.user.employee_id, copy=False)
    current_campaign_id = fields.Many2one('ouktuva.campaign', 'Campaign',
                                          compute='_compute_current_campaign_id',
                                          store=True)
    agency_id = fields.Many2one(related="vehicle_id.agency_id",
                                string="Agency Location", readonly=True)
    seats_number = fields.Integer('Seats', related="vehicle_id.seats")

    departure_date = fields.Datetime('Departure Date', required=True)
    arrival_date = fields.Datetime('Arrival Date', required=True)
    name = fields.Char("Ride Name", translate=True)
    formatted_date = fields.Char(string="Date", compute="_compute_format_date",
                                 store=True)
    carpoolers_count = fields.Char(compute='_compute_passengers_count',
                                   string='Carpoolers', readonly=True,
                                   store=True)

    # Computed
    distance = fields.Float('Distance', readonly=True,
                            compute="_compute_distance", store=True)
    total_carbon_estimated = fields.Float(string="Total Carbon Estimated (Kg CO2 / Ride)",
                                          compute='_compute_total_carbon_estimated', store=True)
    individual_carbon_estimated = fields.Float(
        string="Estimated Individual Carbon Emissions",
        compute='_compute_individual_carbon_estimated', store=True)
    earned_points = fields.Float('Earned Points', readonly=True,
                                 compute='_compute_individual_carbon_estimated',
                                 store=True)
    saved_km = fields.Float("Kilometers Saved",
                            compute="_compute_saved_km", store=True)
    total_passengers = fields.Integer(compute='_compute_passengers_count',
                                      string='Number Of Passengers',
                                      store=True)
    total_carpoolers = fields.Integer(compute='_compute_passengers_count',
                                      string='Number Of Carpoolers',
                                      store=True)
    carpooling = fields.Integer(compute='_compute_passengers_count',
                                string='Carpooling',
                                store=True)
    available_seats = fields.Integer(compute='_compute_passengers_count',
                                     string='Available Seats',
                                     store=True, default=0)

@api.model
    def write(self, vals):
        for rec in self:
            old_driver_id = rec.driver_id
            old_driver_partner_id = rec.driver_id.user_partner_id.id
        result = super(Ride, self).write(vals)
        for ride in self:
            if 'participation_ids' in vals:
                for participation in ride.participation_ids:
                    if participation.carpooler_id:
                        ride.message_subscribe(
                            [participation.carpooler_id.user_partner_id.id])

            if 'driver_id' in vals:
                new_driver_id = vals.get('driver_id')
                if new_driver_id and old_driver_id != new_driver_id:
                    new_driver_partner_id = ride.driver_id.user_partner_id.id
                    ride.message_unsubscribe([old_driver_partner_id])
                    ride.message_subscribe([new_driver_partner_id])

        return result

Yesterday, I had an issue on the old_driver_id which I was going to fix today, but now the Odoo IDE doesn't generate any PROBLEMS and my WSL RAM usage is skyrocketting.

@mathisgauthey ,

With your code sample, I also haven't seen any issues yet.

image
mathisgauthey commented 7 months ago

It works like you when I disable Pylance extension, but it used to work even with both.

And I still don't get what's going on now with the RAM usage, mystery on my end.

trinhanhngoc commented 7 months ago

It works like you when I disable Pylance extension, but it used to work even with both.

And I still don't get what's going on now with the RAM usage, mystery on my end.

I also have Pylance and IntelliCode API Usage Examples installed. Everything seems to work fine.

image