Files
odoo_source/addons/stock/tests/common.py
T
Arnold Moyaux bdcb3d192b [REF] stock: move stock.inventory feature into stock.quant
This commit removes stock.inventory(.line) and moves its general
functionality into stock.quant. Some features are lost during this
switch as well.

Feature Additions:
- New single list view for inventory adjustments (no more multiple
  inventory adjustment records to keep track of!)
- Improved cyclic counts (annual inventory day setting) + next inventory
  dates are immediately viewable in view (vs auto-generated inventories
  based only on location)
- Specific quants (i.e. counts) can be assigned to users for more
  flexibility (vs only able to restrict by location + product
  combinations)
- Counts can be requested (i.e. bulk assigned to user/for a specific
  inventory date)

Feature Removals:
- Can no longer look at previous inventory adjustments linked to a
  specific record. Each quant has a history button to show inventory
  related moves. [relevant account moves are also now harder to see via
  stock as well]

Other changes:
- Bulk of changes were for demo/test
- Some changes were done to ensure "Update Quantity"/"Inventory Report"
  views still mainly function the same as before with the exception of a
  new column added to support updating quant quantities in these views.

Task: 2440026
ENT PR: odoo/enterprise#17329
Upgrade PR: odoo/upgrade#2326

closes odoo/odoo#68409

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-02 11:51:38 +00:00

98 lines
4.7 KiB
Python

# -*- coding: utf-8 -*-
from odoo.tests import common
class TestStockCommon(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestStockCommon, cls).setUpClass()
cls.ProductObj = cls.env['product.product']
cls.UomObj = cls.env['uom.uom']
cls.PartnerObj = cls.env['res.partner']
cls.ModelDataObj = cls.env['ir.model.data']
cls.StockPackObj = cls.env['stock.move.line']
cls.StockQuantObj = cls.env['stock.quant']
cls.PickingObj = cls.env['stock.picking']
cls.MoveObj = cls.env['stock.move']
cls.LotObj = cls.env['stock.production.lot']
# Model Data
cls.picking_type_in = cls.ModelDataObj.xmlid_to_res_id('stock.picking_type_in')
cls.picking_type_out = cls.ModelDataObj.xmlid_to_res_id('stock.picking_type_out')
cls.env['stock.picking.type'].browse(cls.picking_type_out).reservation_method = 'manual'
cls.supplier_location = cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_suppliers')
cls.stock_location = cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_stock')
pack_location = cls.env.ref('stock.location_pack_zone')
pack_location.active = True
cls.pack_location = pack_location.id
output_location = cls.env.ref('stock.stock_location_output')
output_location.active = True
cls.output_location = output_location.id
cls.customer_location = cls.ModelDataObj.xmlid_to_res_id('stock.stock_location_customers')
cls.categ_unit = cls.ModelDataObj.xmlid_to_res_id('uom.product_uom_categ_unit')
cls.categ_kgm = cls.ModelDataObj.xmlid_to_res_id('uom.product_uom_categ_kgm')
# Product Created A, B, C, D
cls.productA = cls.ProductObj.create({'name': 'Product A', 'type': 'product'})
cls.productB = cls.ProductObj.create({'name': 'Product B', 'type': 'product'})
cls.productC = cls.ProductObj.create({'name': 'Product C', 'type': 'product'})
cls.productD = cls.ProductObj.create({'name': 'Product D', 'type': 'product'})
cls.productE = cls.ProductObj.create({'name': 'Product E', 'type': 'product'})
# Configure unit of measure.
cls.uom_kg = cls.env['uom.uom'].search([('category_id', '=', cls.categ_kgm), ('uom_type', '=', 'reference')], limit=1)
cls.uom_kg.write({
'name': 'Test-KG',
'rounding': 0.000001})
cls.uom_tone = cls.UomObj.create({
'name': 'Test-Tone',
'category_id': cls.categ_kgm,
'uom_type': 'bigger',
'factor_inv': 1000.0,
'rounding': 0.001})
cls.uom_gm = cls.UomObj.create({
'name': 'Test-G',
'category_id': cls.categ_kgm,
'uom_type': 'smaller',
'factor': 1000.0,
'rounding': 0.001})
cls.uom_mg = cls.UomObj.create({
'name': 'Test-MG',
'category_id': cls.categ_kgm,
'uom_type': 'smaller',
'factor': 100000.0,
'rounding': 0.001})
# Check Unit
cls.uom_unit = cls.env['uom.uom'].search([('category_id', '=', cls.categ_unit), ('uom_type', '=', 'reference')], limit=1)
cls.uom_unit.write({
'name': 'Test-Unit',
'rounding': 1.0})
cls.uom_dozen = cls.UomObj.create({
'name': 'Test-DozenA',
'category_id': cls.categ_unit,
'factor_inv': 12,
'uom_type': 'bigger',
'rounding': 0.001})
cls.uom_sdozen = cls.UomObj.create({
'name': 'Test-SDozenA',
'category_id': cls.categ_unit,
'factor_inv': 144,
'uom_type': 'bigger',
'rounding': 0.001})
cls.uom_sdozen_round = cls.UomObj.create({
'name': 'Test-SDozenA Round',
'category_id': cls.categ_unit,
'factor_inv': 144,
'uom_type': 'bigger',
'rounding': 1.0})
# Product for different unit of measure.
cls.DozA = cls.ProductObj.create({'name': 'Dozon-A', 'type': 'product', 'uom_id': cls.uom_dozen.id, 'uom_po_id': cls.uom_dozen.id})
cls.SDozA = cls.ProductObj.create({'name': 'SuperDozon-A', 'type': 'product', 'uom_id': cls.uom_sdozen.id, 'uom_po_id': cls.uom_sdozen.id})
cls.SDozARound = cls.ProductObj.create({'name': 'SuperDozenRound-A', 'type': 'product', 'uom_id': cls.uom_sdozen_round.id, 'uom_po_id': cls.uom_sdozen_round.id})
cls.UnitA = cls.ProductObj.create({'name': 'Unit-A', 'type': 'product'})
cls.kgB = cls.ProductObj.create({'name': 'kg-B', 'type': 'product', 'uom_id': cls.uom_kg.id, 'uom_po_id': cls.uom_kg.id})
cls.gB = cls.ProductObj.create({'name': 'g-B', 'type': 'product', 'uom_id': cls.uom_gm.id, 'uom_po_id': cls.uom_gm.id})