diff --git a/pos_picking_load/__openerp__.py b/pos_picking_load/__openerp__.py index 76e5e12a..85edddf0 100644 --- a/pos_picking_load/__openerp__.py +++ b/pos_picking_load/__openerp__.py @@ -5,7 +5,7 @@ { 'name': 'POS Picking Load', - 'version': '8.0.1.1.0', + 'version': '8.0.1.2.0', 'author': 'GRAP,Odoo Community Association (OCA)', 'category': 'Point Of Sale', 'license': 'AGPL-3', diff --git a/pos_picking_load/models/pos_config.py b/pos_picking_load/models/pos_config.py index 40faa973..aa3f45c3 100644 --- a/pos_picking_load/models/pos_config.py +++ b/pos_picking_load/models/pos_config.py @@ -10,3 +10,6 @@ class PosConfig(models.Model): _inherit = 'pos.config' iface_load_picking = fields.Boolean(string='Load Pickings', default=True) + + iface_load_picking_max_qty = fields.Integer( + string='Max Picking Quantity To Load', default=10, required=True) diff --git a/pos_picking_load/models/stock_move.py b/pos_picking_load/models/stock_move.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pos_picking_load/models/stock_picking.py b/pos_picking_load/models/stock_picking.py index 3a50b6fa..e18b8e77 100644 --- a/pos_picking_load/models/stock_picking.py +++ b/pos_picking_load/models/stock_picking.py @@ -18,30 +18,37 @@ class StockPicking(models.Model): # Custom Section @api.model def _prepare_filter_for_pos(self, pos_session_id): + picking_type_obj = self.env['stock.picking.type'] + picking_types = picking_type_obj.search( + [('available_in_pos', '=', True)]) return [ + ('picking_type_id', 'in', picking_types.ids), ('state', 'in', ['confirmed', 'partially_available', 'assigned']), ('invoice_state', '=', '2binvoiced'), ] + @api.model + def _prepare_filter_query_for_pos(self, pos_session_id, query): + return [ + '|', '|', + ('name', 'ilike', query), + ('origin', 'ilike', query), + ('partner_id', 'ilike', query), + ] + @api.model def _prepare_fields_for_pos_list(self): return ['name', 'partner_id', 'min_date', 'origin'] @api.model def search_pickings_for_pos(self, query, pos_session_id): - # Get Picking Types available for PoS - picking_type_obj = self.env['stock.picking.type'] - picking_types = picking_type_obj.search( - [('available_in_pos', '=', True)]) - condition = self._prepare_filter_for_pos(pos_session_id) + [ - ('picking_type_id', 'in', picking_types.ids), - '|', '|', - ('name', 'ilike', query), - ('origin', 'ilike', query), - ('partner_id', 'ilike', query) - ] + session_obj = self.env['pos.session'] + config = session_obj.browse(pos_session_id).config_id + condition = self._prepare_filter_for_pos(pos_session_id) +\ + self._prepare_filter_query_for_pos(pos_session_id, query) fields = self._prepare_fields_for_pos_list() - return self.search_read(condition, fields, limit=10) + return self.search_read( + condition, fields, limit=config.iface_load_picking_max_qty) @api.multi def load_picking_for_pos(self): diff --git a/pos_picking_load/static/src/js/pos_picking_load.js b/pos_picking_load/static/src/js/pos_picking_load.js index f86a129f..09762d7e 100644 --- a/pos_picking_load/static/src/js/pos_picking_load.js +++ b/pos_picking_load/static/src/js/pos_picking_load.js @@ -162,7 +162,7 @@ openerp.pos_picking_load = function(instance, local) { prepare_orderline: function(product, pickingline) { return { - quantity: pickingline.qty, + quantity: pickingline.quantity, price: pickingline.price_unit || product.price, discount: pickingline.discount || 0.0, }; diff --git a/pos_picking_load/views/view_pos_config.xml b/pos_picking_load/views/view_pos_config.xml index 0428da44..c100c848 100644 --- a/pos_picking_load/views/view_pos_config.xml +++ b/pos_picking_load/views/view_pos_config.xml @@ -7,6 +7,7 @@ +