From 8522fcad79e62f41c31fc8a371b3cf8406d05ba6 Mon Sep 17 00:00:00 2001 From: Raimon Esteve Date: Fri, 29 Jan 2021 16:10:08 +0100 Subject: [PATCH] Remove lag_quantity and warehouse field #042744 --- __init__.py | 3 - locale/ca.po | 12 ---- locale/es.po | 12 ---- stock.py | 60 +----------------- stock.xml | 12 ---- tests/test_stock_lot_jreport.py | 104 -------------------------------- view/lot_form.xml | 12 ---- view/lot_tree.xml | 10 --- 8 files changed, 1 insertion(+), 224 deletions(-) delete mode 100644 view/lot_form.xml delete mode 100644 view/lot_tree.xml diff --git a/__init__.py b/__init__.py index efa6771..de076fe 100644 --- a/__init__.py +++ b/__init__.py @@ -5,9 +5,6 @@ from . import stock def register(): - Pool.register( - stock.Lot, - module='stock_lot_jreport', type_='model') Pool.register( stock.LotReport, module='stock_lot_jreport', type_='report') diff --git a/locale/ca.po b/locale/ca.po index 7250283..982d076 100644 --- a/locale/ca.po +++ b/locale/ca.po @@ -2,14 +2,6 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "field:stock.lot,lag_quantity:" -msgid "Lag Quantity" -msgstr "Quantitat de retard" - -msgctxt "field:stock.lot,warehouse:" -msgid "Warehouse" -msgstr "Magatzem" - msgctxt "report:stock.lot.jreport:" msgid "Date" msgstr "Data" @@ -41,7 +33,3 @@ msgstr "Quantitat" msgctxt "report:stock.lot.jreport:" msgid "Warehouse" msgstr "Magatzem" - -msgctxt "model:ir.action,name:stock_lot_report_action" -msgid "Stock Lot" -msgstr "Lot" diff --git a/locale/es.po b/locale/es.po index f9348c1..35f7744 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2,14 +2,6 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "field:stock.lot,lag_quantity:" -msgid "Lag Quantity" -msgstr "Cantidad de retraso" - -msgctxt "field:stock.lot,warehouse:" -msgid "Warehouse" -msgstr "Almacén" - msgctxt "report:stock.lot.jreport:" msgid "Date" msgstr "Fecha" @@ -41,7 +33,3 @@ msgstr "Importe" msgctxt "report:stock.lot.jreport:" msgid "Warehouse" msgstr "Almacén" - -msgctxt "model:ir.action,name:stock_lot_report_action" -msgid "Stock Lot" -msgstr "Lote stock" diff --git a/stock.py b/stock.py index 8b7d3e4..a8eabf0 100644 --- a/stock.py +++ b/stock.py @@ -7,65 +7,7 @@ from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction from dateutil.relativedelta import relativedelta -__all__ = ['Lot', 'LotReport'] - - -class Lot(metaclass=PoolMeta): - __name__ = 'stock.lot' - - lag_quantity = fields.Function(fields.Float('Lag Quantity'), - 'get_lag_quantity', searcher='search_lag_quantity') - warehouse = fields.Function(fields.Many2One('stock.location', - 'Warehouse'), 'get_warehouse') - - @classmethod - def get_lag_quantity(cls, lots, name): - pool = Pool() - Date = pool.get('ir.date') - Location = pool.get('stock.location') - - configuration = pool.get('stock.configuration')(1) - - location_ids = (configuration.warehouse and - [configuration.warehouse.id] or []) - - if not location_ids: - warehouses = Location.search([('type', '=', 'warehouse')]) - location_ids = [w.storage_location.id for w in warehouses] - - lag_days = configuration.lag_days or 0 - stock_date_end = Date.today() + relativedelta(days=int(lag_days)) - with Transaction().set_context({'stock_date_end': stock_date_end}): - quantities = cls._get_quantity(lots, name, location_ids, - grouping=('product', 'lot')) - return quantities - - @classmethod - def search_lag_quantity(cls, name, domain=None): - pool = Pool() - Date = pool.get('ir.date') - configuration = pool.get('stock.configuration')(1) - Location = pool.get('stock.location') - - location_ids = (configuration.warehouse and - [configuration.warehouse.id] or []) - - if not location_ids: - warehouses = Location.search([('type', '=', 'warehouse')]) - location_ids = [w.storage_location.id for w in warehouses] - - lag_days = configuration.lag_days or 0 - stock_date_end = Date.today() + relativedelta(days=int(lag_days)) - with Transaction().set_context({'stock_date_end': stock_date_end}): - return cls._search_quantity(name, location_ids, domain, - grouping=('product', 'lot')) - - @classmethod - def get_warehouse(cls, lots, name): - configuration = Pool().get('stock.configuration')(1) - warehouse_id = (configuration.warehouse and - configuration.warehouse.id or None) - return {l.id: warehouse_id for l in lots} +__all__ = ['LotReport'] class LotReport(JasperReport): diff --git a/stock.xml b/stock.xml index f1f3da5..1f6284c 100644 --- a/stock.xml +++ b/stock.xml @@ -4,18 +4,6 @@ The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. --> - - - stock.lot - - lot_form - - - stock.lot - - lot_tree - - Stock Lot diff --git a/tests/test_stock_lot_jreport.py b/tests/test_stock_lot_jreport.py index 93bd103..ff09a46 100644 --- a/tests/test_stock_lot_jreport.py +++ b/tests/test_stock_lot_jreport.py @@ -17,110 +17,6 @@ class TestCase(ModuleTestCase): 'Test module' module = 'stock_lot_jreport' - @with_transaction() - def test0010get_lag_quantity(self): - 'Test get_lag_quantity' - pool = Pool() - StockConfiguration = pool.get('stock.configuration') - Uom = pool.get('product.uom') - Template = pool.get('product.template') - Product = pool.get('product.product') - Location = pool.get('stock.location') - Move = pool.get('stock.move') - Lot = pool.get('stock.lot') - - # Create Company - company = create_company() - with set_company(company): - - supplier, = Location.search([('code', '=', 'SUP')]) - customer, = Location.search([('code', '=', 'CUS')]) - storage, = Location.search([('code', '=', 'STO')]) - warehouse, = Location.search([('code', '=', 'WH')]) - - StockConfiguration.create([{ - 'warehouse': warehouse.id, - 'lag_days': 1, - }]) - - unit, = Uom.search([('name', '=', 'Unit')]) - template, = Template.create([{ - 'name': 'Test period', - 'type': 'goods', - 'cost_price_method': 'fixed', - 'default_uom': unit.id, - 'list_price': Decimal(0), - }]) - product, = Product.create([{ - 'template': template.id, - }]) - - lot1, lot2 = Lot.create([{ - 'number': '1', - 'product': product.id, - }, { - 'number': '2', - 'product': product.id, - }]) - - today = datetime.date.today() - moves = Move.create([{ - 'product': product.id, - 'lot': lot1.id, - 'uom': unit.id, - 'quantity': 5, - 'from_location': supplier.id, - 'to_location': storage.id, - 'unit_price': Decimal('1'), - }, { - 'product': product.id, - 'lot': lot2.id, - 'uom': unit.id, - 'quantity': 10, - 'from_location': supplier.id, - 'to_location': storage.id, - 'unit_price': Decimal('1'), - }, { - 'product': product.id, - 'lot': lot2.id, - 'uom': unit.id, - 'quantity': 2, - 'from_location': storage.id, - 'to_location': customer.id, - 'unit_price': Decimal('1'), - }, { - 'product': product.id, - 'lot': lot1.id, - 'uom': unit.id, - 'quantity': 5, - 'from_location': supplier.id, - 'to_location': storage.id, - 'planned_date': today + relativedelta(days=2), - 'effective_date': today + relativedelta(days=2), - 'unit_price': Decimal('1'), - }, { - 'product': product.id, - 'lot': lot2.id, - 'uom': unit.id, - 'quantity': 10, - 'from_location': supplier.id, - 'to_location': storage.id, - 'planned_date': today - relativedelta(days=1), - 'effective_date': today - relativedelta(days=1), - 'unit_price': Decimal('1'), - }]) - Move.do(moves) - - quantities = { - '1': 5, - '2': 18, - } - - lots = Lot.search([]) - for lot in lots: - self.assertEqual(lot.lag_quantity, quantities[lot.number]) - - def suite(): suite = trytond.tests.test_tryton.suite() suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase)) diff --git a/view/lot_form.xml b/view/lot_form.xml deleted file mode 100644 index beb142d..0000000 --- a/view/lot_form.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/view/lot_tree.xml b/view/lot_tree.xml deleted file mode 100644 index a595b95..0000000 --- a/view/lot_tree.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - -