mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD] [9.0] [stock_quant_reserved_qty_uom]
This commit is contained in:
committed by
Jordi Ballester Alomar
parent
65da7e5d03
commit
e4ff326062
56
stock_quant_reserved_qty_uom/README.rst
Normal file
56
stock_quant_reserved_qty_uom/README.rst
Normal file
@@ -0,0 +1,56 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
============================
|
||||
Stock Quant Reserved Qty UoM
|
||||
============================
|
||||
|
||||
This module allows to display the quantity of a quant in the unit of measure
|
||||
defined in the reservation move.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/153/9.0
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/stock-logistics-warehouse/issues>`_. In case of trouble, please
|
||||
check there if your issue has already been reported. If you spotted it first,
|
||||
help us smashing it by providing a detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
5
stock_quant_reserved_qty_uom/__init__.py
Normal file
5
stock_quant_reserved_qty_uom/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import models
|
||||
16
stock_quant_reserved_qty_uom/__openerp__.py
Normal file
16
stock_quant_reserved_qty_uom/__openerp__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Stock Quant Reserved Qty UoM',
|
||||
'version': '9.0.1.0.0',
|
||||
'category': 'Inventory, Logistic, Storage',
|
||||
'license': 'AGPL-3',
|
||||
"author": "Eficent, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
'depends': ['stock'],
|
||||
'data': ['views/stock_quant_view.xml'],
|
||||
'installable': True,
|
||||
}
|
||||
5
stock_quant_reserved_qty_uom/models/__init__.py
Normal file
5
stock_quant_reserved_qty_uom/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import stock_quant
|
||||
34
stock_quant_reserved_qty_uom/models/stock_quant.py
Normal file
34
stock_quant_reserved_qty_uom/models/stock_quant.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import api, fields, models
|
||||
import openerp.addons.decimal_precision as dp
|
||||
|
||||
UNIT = dp.get_precision('Product Unit of Measure')
|
||||
|
||||
|
||||
class StockQuant(models.Model):
|
||||
|
||||
_inherit = 'stock.quant'
|
||||
|
||||
@api.multi
|
||||
@api.depends('qty', 'reservation_id')
|
||||
def _compute_reserved_qty_uom(self):
|
||||
uom_obj = self.env['product.uom']
|
||||
for rec in self:
|
||||
if rec.reservation_id:
|
||||
rec.reserved_qty_uom = uom_obj._compute_qty_obj(
|
||||
rec.product_id.uom_id,
|
||||
rec.qty,
|
||||
rec.reservation_id.product_uom)
|
||||
|
||||
reserved_qty_uom = fields.Float(string="Qty in reservation UoM",
|
||||
compute="_compute_reserved_qty_uom",
|
||||
help="Quantity expressed in the unit of "
|
||||
"measure of the move",
|
||||
digits=UNIT, readonly=True)
|
||||
reservation_uom = fields.Many2one(string="Reservation UoM",
|
||||
comodel_name="product.uom",
|
||||
readonly=True,
|
||||
related='reservation_id.product_uom')
|
||||
BIN
stock_quant_reserved_qty_uom/static/description/icon.png
Normal file
BIN
stock_quant_reserved_qty_uom/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
5
stock_quant_reserved_qty_uom/tests/__init__.py
Normal file
5
stock_quant_reserved_qty_uom/tests/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import test_stock_quant_reserved_qty_uom
|
||||
@@ -0,0 +1,72 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestStockQuantReservedQtyUom(TransactionCase):
|
||||
|
||||
def test01(self):
|
||||
"""checking that the reserved_qty_uom is expressed in the unit of
|
||||
measure of the reservation move."""
|
||||
pickingObj = self.env['stock.picking']
|
||||
productObj = self.env['product.product']
|
||||
supplier_location = self.env.ref('stock.stock_location_suppliers')
|
||||
stock_location = self.env.ref('stock.stock_location_stock')
|
||||
customer_location = self.env.ref('stock.stock_location_customers')
|
||||
uom_unit = self.env.ref('product.product_uom_unit')
|
||||
uom_dozen = self.env.ref('product.product_uom_dozen')
|
||||
|
||||
# Create product A
|
||||
productA = productObj.create(
|
||||
{'name': 'product A',
|
||||
'standard_price': 1.0,
|
||||
'type': 'product',
|
||||
'uom_id': uom_unit.id,
|
||||
'default_code': 'A',
|
||||
})
|
||||
|
||||
# Create a picking move from INCOMING to STOCK
|
||||
pickingInA = pickingObj.create({
|
||||
'picking_type_id': self.ref('stock.picking_type_in'),
|
||||
'location_id': supplier_location.id,
|
||||
'location_dest_id': stock_location.id,
|
||||
'move_lines': [
|
||||
(0, 0, {
|
||||
'name': 'Test move',
|
||||
'product_id': productA.id,
|
||||
'product_uom': productA.uom_id.id,
|
||||
'product_uom_qty': 12.0,
|
||||
'location_id': supplier_location.id,
|
||||
'location_dest_id': stock_location.id,
|
||||
})]
|
||||
})
|
||||
|
||||
pickingInA.action_confirm()
|
||||
pickingInA.action_assign()
|
||||
pickingInA.action_done()
|
||||
|
||||
# Create a picking from STOCK to CUSTOMER
|
||||
pickingOutA = pickingObj.create({
|
||||
'picking_type_id': self.ref('stock.picking_type_out'),
|
||||
'location_id': stock_location.id,
|
||||
'location_dest_id': customer_location.id,
|
||||
'move_lines': [
|
||||
(0, 0, {
|
||||
'name': 'Test move',
|
||||
'product_id': productA.id,
|
||||
'product_uom': uom_dozen.id,
|
||||
'product_uom_qty': 1.0,
|
||||
'location_id': stock_location.id,
|
||||
'location_dest_id': customer_location.id,
|
||||
})]
|
||||
})
|
||||
pickingOutA.action_confirm()
|
||||
pickingOutA.action_assign()
|
||||
|
||||
for move in pickingOutA.move_lines:
|
||||
for quant in move.reserved_quant_ids:
|
||||
quant._compute_reserved_qty_uom()
|
||||
self.assertEqual(quant.reserved_qty_uom, 1)
|
||||
self.assertEqual(quant.qty, 12)
|
||||
29
stock_quant_reserved_qty_uom/views/stock_quant_view.xml
Normal file
29
stock_quant_reserved_qty_uom/views/stock_quant_view.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<record model="ir.ui.view" id="view_stock_quant_tree">
|
||||
<field name="name">stock.quant.tree</field>
|
||||
<field name="model">stock.quant</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_quant_tree"/>
|
||||
<field eval="10" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="reservation_id" position="after">
|
||||
<field name="reserved_qty_uom"/>
|
||||
<field name="reservation_uom" groups="product.group_uom"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_stock_quant_form">
|
||||
<field name="name">stock.quant.form</field>
|
||||
<field name="model">stock.quant</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_quant_form"/>
|
||||
<field eval="10" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="reservation_id" position="after">
|
||||
<field name="reserved_qty_uom"/>
|
||||
<field name="reservation_uom" groups="product.group_uom"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user