From 3cc52c9ab0d40e857dee41fce44db4b65468c4a9 Mon Sep 17 00:00:00 2001 From: Francois Poizat Date: Wed, 8 May 2024 14:52:42 +0200 Subject: [PATCH] wms_connector_picking_batch: working filters --- .../odoo/addons/wms_connector_picking_batch | 1 + setup/wms_connector_picking_batch/setup.py | 6 ++++++ wms_connector/models/stock_warehouse.py | 4 +++- wms_connector_picking_batch/README.rst | 3 --- wms_connector_picking_batch/models/__init__.py | 1 + .../models/stock_picking_batch.py | 6 ++++-- .../models/stock_warehouse.py | 15 ++++++++++++--- wms_connector_picking_batch/readme/HISTORY.md | 3 --- .../views/stock_warehouse.xml | 2 +- 9 files changed, 28 insertions(+), 13 deletions(-) create mode 120000 setup/wms_connector_picking_batch/odoo/addons/wms_connector_picking_batch create mode 100644 setup/wms_connector_picking_batch/setup.py diff --git a/setup/wms_connector_picking_batch/odoo/addons/wms_connector_picking_batch b/setup/wms_connector_picking_batch/odoo/addons/wms_connector_picking_batch new file mode 120000 index 0000000000..ad453a0cc0 --- /dev/null +++ b/setup/wms_connector_picking_batch/odoo/addons/wms_connector_picking_batch @@ -0,0 +1 @@ +../../../../wms_connector_picking_batch \ No newline at end of file diff --git a/setup/wms_connector_picking_batch/setup.py b/setup/wms_connector_picking_batch/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/wms_connector_picking_batch/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/wms_connector/models/stock_warehouse.py b/wms_connector/models/stock_warehouse.py index 265f72960b..cc734718ac 100644 --- a/wms_connector/models/stock_warehouse.py +++ b/wms_connector/models/stock_warehouse.py @@ -3,7 +3,7 @@ from copy import deepcopy -from odoo import fields, models +from odoo import api, fields, models FILTER_VALS = { "wms_export_product_filter_id": { @@ -144,9 +144,11 @@ def _activate_crons_tasks(self): rec._activate_crons() rec._activate_filters() + @api.model def _get_mappings(self): return MAPPINGS + @api.model def _get_filter_vals(self): return FILTER_VALS diff --git a/wms_connector_picking_batch/README.rst b/wms_connector_picking_batch/README.rst index 649dba565b..0b7d52dfbb 100644 --- a/wms_connector_picking_batch/README.rst +++ b/wms_connector_picking_batch/README.rst @@ -81,9 +81,6 @@ To configure this module, you need to: |alternative description|../static/description/image.png) -https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/.https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/.https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/|https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ahttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/lhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/thttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ehttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/rhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/nhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ahttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/thttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ihttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/vhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ehttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/dhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ehttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/shttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/chttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/rhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ihttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/phttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/thttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ihttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ohttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/nhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/|https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ihttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/mhttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ahttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ghttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ehttps://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/:https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/:https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ -https://raw.githubusercontent.com/OCA/wms/14.0/wms_connector_picking_batch/ - Usage ===== diff --git a/wms_connector_picking_batch/models/__init__.py b/wms_connector_picking_batch/models/__init__.py index 07b5490f6c..07ad666d03 100644 --- a/wms_connector_picking_batch/models/__init__.py +++ b/wms_connector_picking_batch/models/__init__.py @@ -1 +1,2 @@ from . import stock_picking_batch +from . import stock_warehouse diff --git a/wms_connector_picking_batch/models/stock_picking_batch.py b/wms_connector_picking_batch/models/stock_picking_batch.py index 9d6d90702a..dc91a5098b 100644 --- a/wms_connector_picking_batch/models/stock_picking_batch.py +++ b/wms_connector_picking_batch/models/stock_picking_batch.py @@ -2,7 +2,7 @@ from odoo.exceptions import UserError -class StockPikcingBatch(models.Model): +class StockPickingBatch(models.Model): _inherit = ["synchronize.exportable.mixin", "stock.picking.batch"] _name = "stock.picking.batch" @@ -68,6 +68,8 @@ def _wms_check_if_editable(self): for picking_batch in self: if picking_batch.wms_export_date: raise UserError( - _("The batch transfer %s have been exported and can not be modified") + _( + "The batch transfer %s have been exported and can not be modified" + ) % picking_batch.name ) diff --git a/wms_connector_picking_batch/models/stock_warehouse.py b/wms_connector_picking_batch/models/stock_warehouse.py index 3aa2a5b0e1..1625213623 100644 --- a/wms_connector_picking_batch/models/stock_warehouse.py +++ b/wms_connector_picking_batch/models/stock_warehouse.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import api, fields, models FILTER_VALS = { "wms_export_batch_picking_in_filter_id": { @@ -10,11 +10,15 @@ "model_id": "stock.picking.batch", }, } +# Find a better way to override filters FILTER_DOMAINS = { - "wms_export_product_filter_id": "[]", "wms_export_picking_in_filter_id": '[("wms_export_date", "=", False),' - ' ("picking_type_id", "=", {}), ("state", "=", "assigned")]', + ' ("picking_type_id", "=", {}), ("state", "=", "assigned"), ("batch_id", "=", False)]', "wms_export_picking_out_filter_id": '[("wms_export_date", "=", False),' + ' ("picking_type_id", "=", {}), ("state", "=", "assigned"), ("batch_id", "=", False)]', + "wms_export_batch_picking_in_filter_id": '[("wms_export_date", "=", False),' + ' ("picking_type_id", "=", {}), ("state", "=", "assigned")]', + "wms_export_batch_picking_out_filter_id": '[("wms_export_date", "=", False),' ' ("picking_type_id", "=", {}), ("state", "=", "assigned")]', } @@ -44,8 +48,10 @@ }, } + class StockWarehouse(models.Model): _inherit = "stock.warehouse" + _name = "stock.warehouse" wms_export_batch_picking_in_cron_id = fields.Many2one("ir.cron", readonly=True) wms_export_batch_picking_out_cron_id = fields.Many2one("ir.cron", readonly=True) @@ -59,11 +65,13 @@ def _wms_domain_for(self, model_domain): } return domains[model_domain] + @api.model def _get_mappings(self): mappings = super()._get_mappings() mappings.update(MAPPINGS) return mappings + @api.model def _get_filter_vals(self): # TODO(franz) remove picking with batch id from the picking in and out filter filter_vals = super()._get_filter_vals() @@ -71,6 +79,7 @@ def _get_filter_vals(self): return filter_vals def _activate_filters(self): + super()._activate_filters() self.wms_export_batch_picking_in_filter_id.domain = FILTER_DOMAINS[ "wms_export_batch_picking_in_filter_id" ].format(self.in_type_id.id) diff --git a/wms_connector_picking_batch/readme/HISTORY.md b/wms_connector_picking_batch/readme/HISTORY.md index 9894c783ec..0b7e26098d 100644 --- a/wms_connector_picking_batch/readme/HISTORY.md +++ b/wms_connector_picking_batch/readme/HISTORY.md @@ -12,6 +12,3 @@ the README.rst or other documents where this fragment is included. ] - [ADD] New feature. ([#74](https://github.com/OCA/repo/issues/74)) - [FIX] Correct this. ([#71](https://github.com/OCA/repo/issues/71)) -## 11.0.x.y.z (YYYY-MM-DD) - -- ... diff --git a/wms_connector_picking_batch/views/stock_warehouse.xml b/wms_connector_picking_batch/views/stock_warehouse.xml index bc27f3ffd3..f489dd9d80 100644 --- a/wms_connector_picking_batch/views/stock_warehouse.xml +++ b/wms_connector_picking_batch/views/stock_warehouse.xml @@ -16,7 +16,7 @@ type="object" />