mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
fix reservation_count computation
1. Make it float, because quantity is float. 2. Respect unit of measure (instead of adding apples and pears). 3. Do that for both product and template. 4. Test the above.
This commit is contained in:
@@ -25,7 +25,7 @@ from openerp import models, fields, api
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
reservation_count = fields.Integer(
|
||||
reservation_count = fields.Float(
|
||||
compute='_reservation_count',
|
||||
string='# Sales')
|
||||
|
||||
@@ -36,7 +36,7 @@ class ProductTemplate(models.Model):
|
||||
domain = [('product_id', 'in', product_ids),
|
||||
('state', 'in', ['draft', 'assigned'])]
|
||||
reservations = StockReservation.search(domain)
|
||||
self.reservation_count = sum(reserv.product_uom_qty
|
||||
self.reservation_count = sum(reserv.product_qty
|
||||
for reserv in reservations)
|
||||
|
||||
@api.multi
|
||||
@@ -56,7 +56,7 @@ class ProductTemplate(models.Model):
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
reservation_count = fields.Integer(
|
||||
reservation_count = fields.Float(
|
||||
compute='_reservation_count',
|
||||
string='# Sales')
|
||||
|
||||
@@ -67,7 +67,7 @@ class ProductProduct(models.Model):
|
||||
domain = [('product_id', '=', product_id),
|
||||
('state', 'in', ['draft', 'assigned'])]
|
||||
reservations = StockReservation.search(domain)
|
||||
self.reservation_count = sum(reserv.product_uom_qty
|
||||
self.reservation_count = sum(reserv.product_qty
|
||||
for reserv in reservations)
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -62,6 +62,13 @@
|
||||
-
|
||||
!python {model: stock.reservation}: |
|
||||
self.reserve(cr, uid, [ref('reserv_sorbet2')], context=context)
|
||||
-
|
||||
I check the reserved amount of the product and the template
|
||||
-
|
||||
!python {model: product.product, id: product_sorbet}: |
|
||||
from nose.tools import *
|
||||
assert_almost_equal(6.5, self.reservation_count)
|
||||
assert_almost_equal(6.5, self.product_tmpl_id.reservation_count)
|
||||
-
|
||||
Then the reservation should be assigned and have reserved a quant
|
||||
-
|
||||
|
||||
Reference in New Issue
Block a user