mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
fix #42: reserve location should be outside WH
This has always been wrong on v8, but because of the very obscure odoo/odoo#5797, this seemed to work every time we had single-step reception. Please note that this block of XML is noupdate, so for existing installations you need to change the parent of the reservation location to something outside your warehouses manually. Incidentally, this makes the branch green independently of odoo/odoo#5797.
This commit is contained in:
committed by
Víctor Martínez
parent
07e6be5375
commit
5b77b0c9c5
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
{'name': 'Stock Reservation',
|
{'name': 'Stock Reservation',
|
||||||
'summary': 'Stock reservations on products',
|
'summary': 'Stock reservations on products',
|
||||||
'version': '0.1',
|
'version': '0.2',
|
||||||
'author': "Camptocamp,Odoo Community Association (OCA)",
|
'author': "Camptocamp,Odoo Community Association (OCA)",
|
||||||
'category': 'Warehouse',
|
'category': 'Warehouse',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
@@ -43,11 +43,15 @@ stock below the minimum, the orderpoint will be triggered and new
|
|||||||
purchase orders will be generated. It also implies that the max may be
|
purchase orders will be generated. It also implies that the max may be
|
||||||
exceeded if the reservations are canceled.
|
exceeded if the reservations are canceled.
|
||||||
|
|
||||||
|
If ownership of stock is active in the stock settings, you can specify the
|
||||||
|
owner on the reservation.
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
||||||
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
|
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
|
||||||
|
* Leonardo Pistone <leonardo.pistone@camptocamp.com>
|
||||||
|
|
||||||
""",
|
""",
|
||||||
'depends': ['stock',
|
'depends': ['stock',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<data noupdate="1">
|
<data noupdate="1">
|
||||||
<record id="stock_location_reservation" model="stock.location">
|
<record id="stock_location_reservation" model="stock.location">
|
||||||
<field name="name">Reservation Stock</field>
|
<field name="name">Reservation Stock</field>
|
||||||
<field name="location_id" ref="stock.stock_location_company"/>
|
<field name="location_id" ref="stock.stock_location_locations"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
42
stock_reserve/migrations/0.2/post-migration.py
Normal file
42
stock_reserve/migrations/0.2/post-migration.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Author: Leonardo Pistone
|
||||||
|
# Copyright 2015 Camptocamp SA
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(cr, installed_version):
|
||||||
|
"""Update a wrong location that is no_update in XML."""
|
||||||
|
if installed_version == '8.0.0.1':
|
||||||
|
cr.execute('''
|
||||||
|
UPDATE stock_location
|
||||||
|
SET location_id = (
|
||||||
|
SELECT res_id
|
||||||
|
FROM ir_model_data
|
||||||
|
WHERE name = 'stock_location_locations'
|
||||||
|
AND module = 'stock'
|
||||||
|
)
|
||||||
|
WHERE id = (
|
||||||
|
SELECT res_id
|
||||||
|
FROM ir_model_data
|
||||||
|
WHERE name = 'stock_location_reservation'
|
||||||
|
AND module = 'stock_reserve'
|
||||||
|
)
|
||||||
|
AND location_id = (
|
||||||
|
SELECT res_id
|
||||||
|
FROM ir_model_data
|
||||||
|
WHERE name = 'stock_location_company'
|
||||||
|
AND module = 'stock'
|
||||||
|
);
|
||||||
|
''')
|
||||||
@@ -25,19 +25,14 @@ from openerp import models, fields, api
|
|||||||
class ProductTemplate(models.Model):
|
class ProductTemplate(models.Model):
|
||||||
_inherit = 'product.template'
|
_inherit = 'product.template'
|
||||||
|
|
||||||
reservation_count = fields.Integer(
|
reservation_count = fields.Float(
|
||||||
compute='_reservation_count',
|
compute='_reservation_count',
|
||||||
string='# Sales')
|
string='# Sales')
|
||||||
|
|
||||||
@api.multi
|
@api.one
|
||||||
def _reservation_count(self):
|
def _reservation_count(self):
|
||||||
StockReservation = self.env['stock.reservation']
|
self.reservation_count = sum(variant.reservation_count
|
||||||
product_ids = self._get_products()
|
for variant in self.product_variant_ids)
|
||||||
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)
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_view_reservations(self):
|
def action_view_reservations(self):
|
||||||
@@ -56,18 +51,16 @@ class ProductTemplate(models.Model):
|
|||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
_inherit = 'product.product'
|
_inherit = 'product.product'
|
||||||
|
|
||||||
reservation_count = fields.Integer(
|
reservation_count = fields.Float(
|
||||||
compute='_reservation_count',
|
compute='_reservation_count',
|
||||||
string='# Sales')
|
string='# Sales')
|
||||||
|
|
||||||
@api.multi
|
@api.one
|
||||||
def _reservation_count(self):
|
def _reservation_count(self):
|
||||||
StockReservation = self.env['stock.reservation']
|
domain = [('product_id', '=', self.id),
|
||||||
product_id = self._ids[0]
|
|
||||||
domain = [('product_id', '=', product_id),
|
|
||||||
('state', 'in', ['draft', 'assigned'])]
|
('state', 'in', ['draft', 'assigned'])]
|
||||||
reservations = StockReservation.search(domain)
|
reservations = self.env['stock.reservation'].search(domain)
|
||||||
self.reservation_count = sum(reserv.product_uom_qty
|
self.reservation_count = sum(reserv.product_qty
|
||||||
for reserv in reservations)
|
for reserv in reservations)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
@@ -60,8 +60,15 @@
|
|||||||
-
|
-
|
||||||
I confirm the reservation
|
I confirm the reservation
|
||||||
-
|
-
|
||||||
!python {model: stock.reservation}: |
|
!python {model: stock.reservation, id: reserv_sorbet2}: |
|
||||||
self.reserve(cr, uid, [ref('reserv_sorbet2')], context=context)
|
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
|
Then the reservation should be assigned and have reserved a quant
|
||||||
-
|
-
|
||||||
@@ -73,9 +80,9 @@
|
|||||||
-
|
-
|
||||||
I check Virtual stock of Sorbet after update reservation
|
I check Virtual stock of Sorbet after update reservation
|
||||||
-
|
-
|
||||||
!python {model: product.product}: |
|
!python {model: product.product, id: product_sorbet}: |
|
||||||
product = self.browse(cr, uid, ref('stock_reserve.product_sorbet'), context=context)
|
from nose.tools import *
|
||||||
assert product.virtual_available == 3.5, "Stock is not updated."
|
assert_almost_equal(3.5, self.virtual_available)
|
||||||
-
|
-
|
||||||
I run the scheduler
|
I run the scheduler
|
||||||
-
|
-
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
<field name="company_id"
|
<field name="company_id"
|
||||||
groups="base.group_multi_company"
|
groups="base.group_multi_company"
|
||||||
widget="selection"/>
|
widget="selection"/>
|
||||||
|
<field name="restrict_partner_id" groups="stock.group_tracking_owner"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="location" string="Locations"
|
<group name="location" string="Locations"
|
||||||
groups="stock.group_locations">
|
groups="stock.group_locations">
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
<field name="product_uom_qty" sum="Total" />
|
<field name="product_uom_qty" sum="Total" />
|
||||||
<field name="product_uom" />
|
<field name="product_uom" />
|
||||||
<field name="date_validity" />
|
<field name="date_validity" />
|
||||||
|
<field name="restrict_partner_id" groups="stock.group_tracking_owner"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button name="reserve" type="object"
|
<button name="reserve" type="object"
|
||||||
string="Reserve"
|
string="Reserve"
|
||||||
@@ -93,6 +95,7 @@
|
|||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="product_id" />
|
<field name="product_id" />
|
||||||
<field name="move_id" />
|
<field name="move_id" />
|
||||||
|
<field name="restrict_partner_id" groups="stock.group_tracking_owner"/>
|
||||||
<group expand="0" string="Group By...">
|
<group expand="0" string="Group By...">
|
||||||
<filter string="Status"
|
<filter string="Status"
|
||||||
name="groupby_state"
|
name="groupby_state"
|
||||||
|
|||||||
Reference in New Issue
Block a user