mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
Merge pull request #44 from lepistone/fix-expected-singleton
fix crash: excepted singleton
This commit is contained in:
@@ -25,19 +25,14 @@ 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')
|
||||
|
||||
@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_uom_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):
|
||||
@@ -56,18 +51,16 @@ class ProductTemplate(models.Model):
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
reservation_count = fields.Integer(
|
||||
reservation_count = fields.Float(
|
||||
compute='_reservation_count',
|
||||
string='# Sales')
|
||||
|
||||
@api.multi
|
||||
@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)
|
||||
self.reservation_count = sum(reserv.product_uom_qty
|
||||
reservations = self.env['stock.reservation'].search(domain)
|
||||
self.reservation_count = sum(reserv.product_qty
|
||||
for reserv in reservations)
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -60,8 +60,15 @@
|
||||
-
|
||||
I confirm the reservation
|
||||
-
|
||||
!python {model: stock.reservation}: |
|
||||
self.reserve(cr, uid, [ref('reserv_sorbet2')], context=context)
|
||||
!python {model: stock.reservation, id: reserv_sorbet2}: |
|
||||
self.reserve()
|
||||
-
|
||||
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
|
||||
-
|
||||
@@ -73,9 +80,9 @@
|
||||
-
|
||||
I check Virtual stock of Sorbet after update reservation
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('stock_reserve.product_sorbet'), context=context)
|
||||
assert product.virtual_available == 3.5, "Stock is not updated."
|
||||
!python {model: product.product, id: product_sorbet}: |
|
||||
from nose.tools import *
|
||||
assert_almost_equal(3.5, self.virtual_available)
|
||||
-
|
||||
I run the scheduler
|
||||
-
|
||||
|
||||
Reference in New Issue
Block a user