oca-ocb-core/odoo-bringout-oca-ocb-repair/repair/models/product.py
2025-08-29 15:20:45 +02:00

25 lines
892 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class Product(models.Model):
_inherit = "product.product"
def _count_returned_sn_products(self, sn_lot):
remove_count = self.env['repair.line'].search_count([
('type', '=', 'remove'),
('product_uom_qty', '=', 1),
('lot_id', '=', sn_lot.id),
('state', '=', 'done'),
('location_dest_id.usage', '=', 'internal'),
])
add_count = self.env['repair.line'].search_count([
('type', '=', 'add'),
('product_uom_qty', '=', 1),
('lot_id', '=', sn_lot.id),
('state', '=', 'done'),
('location_dest_id.usage', '=', 'production'),
])
return super()._count_returned_sn_products(sn_lot) + (remove_count - add_count)