mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
refactor: delegate to variants, use self.id
This commit is contained in:
@@ -29,15 +29,10 @@ class ProductTemplate(models.Model):
|
||||
compute='_reservation_count',
|
||||
string='# Sales')
|
||||
|
||||
@api.multi
|
||||
@api.one
|
||||
def _reservation_count(self):
|
||||
StockReservation = self.env['stock.reservation']
|
||||
product_ids = self._get_products()
|
||||
domain = [('product_id', 'in', product_ids),
|
||||
('state', 'in', ['draft', 'assigned'])]
|
||||
reservations = StockReservation.search(domain)
|
||||
self.reservation_count = sum(reserv.product_qty
|
||||
for reserv in reservations)
|
||||
self.reservation_count = sum(variant.reservation_count
|
||||
for variant in self.product_variant_ids)
|
||||
|
||||
@api.multi
|
||||
def action_view_reservations(self):
|
||||
@@ -62,11 +57,9 @@ class ProductProduct(models.Model):
|
||||
|
||||
@api.one
|
||||
def _reservation_count(self):
|
||||
StockReservation = self.env['stock.reservation']
|
||||
product_id = self._ids[0]
|
||||
domain = [('product_id', '=', product_id),
|
||||
domain = [('product_id', '=', self.id),
|
||||
('state', 'in', ['draft', 'assigned'])]
|
||||
reservations = StockReservation.search(domain)
|
||||
reservations = self.env['stock.reservation'].search(domain)
|
||||
self.reservation_count = sum(reserv.product_qty
|
||||
for reserv in reservations)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user