from odoo import models, api

class StockQuant(models.Model):
    _inherit = 'stock.quant'

    @api.model
    def _update_available_quantity(self, product_id, location_id, quantity, lot_id=None, package_id=None, owner_id=None, in_date=None):
        res = super(StockQuant, self)._update_available_quantity(
            product_id=product_id,
            location_id=location_id,
            quantity=quantity,
            lot_id=lot_id,
            package_id=package_id,
            owner_id=owner_id,
            in_date=in_date
        )

        if product_id.shopify_inventory_item_id:
            config = self.env['shopify.config'].sudo().search([('state', '=', 'confirmed')], limit=1)
            if config and config.auto_sync_products:
                self.env['shopify.stock.queue'].sudo().enqueue_product(product_id.id)
                
        return res
