Add stock_product_qty_by_packaging

This commit is contained in:
Simone Orsi
2021-05-28 09:49:22 +02:00
committed by nguyen hoang hiep
parent 928f03b0a1
commit bb298877f0
12 changed files with 143 additions and 0 deletions

View File

@@ -0,0 +1 @@
wait for the bot ;)

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,16 @@
# Copyright 2020 Camptocamp SA
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl)
{
"name": "Stock packaging calculator",
"summary": "Compute product quantity to pick by packaging",
"version": "13.0.1.0.0",
"development_status": "Alpha",
"category": "Warehouse Management",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": ["stock_packaging_calculator", "stock"],
"data": ["views/stock_picking.xml"],
}

View File

@@ -0,0 +1,3 @@
from . import stock_move
from . import stock_move_line
from . import stock_quant

View File

@@ -0,0 +1,13 @@
# Copyright 2020 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# @author: Sébastien Alix <sebastien.alix@camptocamp.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models
class StockMove(models.Model):
_name = "stock.move"
_inherit = ["stock.move", "product.qty_by_packaging.mixin"]
_qty_by_pkg__qty_field_name = "product_uom_qty"

View File

@@ -0,0 +1,13 @@
# Copyright 2020 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# @author: Sébastien Alix <sebastien.alix@camptocamp.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models
class StockMoveLine(models.Model):
_name = "stock.move.line"
_inherit = ["stock.move.line", "product.qty_by_packaging.mixin"]
_qty_by_pkg__qty_field_name = "product_qty"

View File

@@ -0,0 +1,13 @@
# Copyright 2020 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# @author: Sébastien Alix <sebastien.alix@camptocamp.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class StockQuant(models.Model):
_name = "stock.quant"
_inherit = ["stock.quant", "product.qty_by_packaging.mixin"]
_qty_by_pkg__qty_field_name = "quantity"

View File

@@ -0,0 +1,2 @@
Simone Orsi <simone.orsi@camptocamp.com>
Sébastien Alix <sebastien.alix@camptocamp.com>

View File

@@ -0,0 +1 @@
Glue module for `stock_packaging_calculator` and `stock`.

View File

@@ -0,0 +1 @@
from . import test_stock

View File

@@ -0,0 +1,63 @@
# Copyright 2021 Camptocamp SA
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl)
from odoo.addons.stock_packaging_calculator.tests.common import TestCommon
# from odoo.addons.stock_packaging_calculator.tests.utils import make_pkg_values
class TestStock(TestCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
ref = cls.env.ref
cls.stock_location = ref("stock.stock_location_stock")
cls.sub_location = cls.env["stock.location"].create(
{"name": "Sub", "location_id": cls.stock_location.id}
)
cls.wh = cls.env.ref("stock.warehouse0")
cls.picking_type = cls.wh.out_type_id
cls.product_a.type = "product"
cls.env["stock.quant"]._update_available_quantity(
cls.product_a, cls.stock_location, 2825
)
cls.move = cls.env["stock.move"].create(
{
"name": "test",
"product_id": cls.product_a.id,
"location_id": cls.stock_location.id,
"location_dest_id": cls.sub_location.id,
"product_uom": cls.product_a.uom_id.id,
"product_uom_qty": 2825,
"state": "waiting",
"picking_type_id": cls.picking_type.id,
}
)
cls.move._assign_picking()
cls.move._action_assign()
cls.move_line = cls.move.move_line_ids[0]
cls.move_line.product_uom_qty = 1470
cls.quant = cls.env["stock.quant"].create(
{
"location_id": cls.stock_location.id,
"product_id": cls.product_a.id,
"quantity": 3190.0,
}
)
def test_move(self):
self.assertEqual(
self.move.product_qty_by_packaging_display,
"1 Pallet,\xa04 Big Box,\xa025 Units",
)
def test_move_line(self):
self.assertEqual(
self.move_line.product_qty_by_packaging_display,
"7 Big Box,\xa01 Box,\xa020 Units",
)
def test_quant(self):
self.assertEqual(
self.quant.product_qty_by_packaging_display,
"1 Pallet,\xa05 Big Box,\xa03 Box,\xa040 Units",
)

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_picking_form" model="ir.ui.view">
<field name="name">stock.view.picking.form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom']"
position="after"
>
<field name="product_qty_by_packaging_display" />
</xpath>
</field>
</record>
</odoo>