Skip to content

Commit

Permalink
wms_connector_picking_batch: working filters
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzPoize committed May 8, 2024
1 parent d4ab4bc commit 3cc52c9
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 13 deletions.
6 changes: 6 additions & 0 deletions setup/wms_connector_picking_batch/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
4 changes: 3 additions & 1 deletion wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions wms_connector_picking_batch/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=====

Expand Down
1 change: 1 addition & 0 deletions wms_connector_picking_batch/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import stock_picking_batch
from . import stock_warehouse
6 changes: 4 additions & 2 deletions wms_connector_picking_batch/models/stock_picking_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
)
15 changes: 12 additions & 3 deletions wms_connector_picking_batch/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import fields, models
from odoo import api, fields, models

FILTER_VALS = {
"wms_export_batch_picking_in_filter_id": {
Expand All @@ -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")]',
}

Expand Down Expand Up @@ -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)
Expand All @@ -59,18 +65,21 @@ 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()
filter_vals.update(FILTER_VALS)
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)
Expand Down
3 changes: 0 additions & 3 deletions wms_connector_picking_batch/readme/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

- ...
2 changes: 1 addition & 1 deletion wms_connector_picking_batch/views/stock_warehouse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
type="object"
/>
<button
name="button_open_wms_pickings_out"
name="button_open_wms_batch_pickings_out"
string="WMS sync batch transfer pickings out"
icon="fa-refresh"
class="oe_stat_button"
Expand Down

0 comments on commit 3cc52c9

Please sign in to comment.