Browse Source

[FIX] picking lines quantity are correcty loaded

[ADD] parameter to load a custom quantity of picking in PoS
[IMP] prepare function to let possibility to users to overload search function
pull/365/head
Sylvain LE GAL 7 years ago
parent
commit
c5d91ef71e
  1. 2
      pos_picking_load/__openerp__.py
  2. 3
      pos_picking_load/models/pos_config.py
  3. 0
      pos_picking_load/models/stock_move.py
  4. 31
      pos_picking_load/models/stock_picking.py
  5. 2
      pos_picking_load/static/src/js/pos_picking_load.js
  6. 1
      pos_picking_load/views/view_pos_config.xml

2
pos_picking_load/__openerp__.py

@ -5,7 +5,7 @@
{ {
'name': 'POS Picking Load', 'name': 'POS Picking Load',
'version': '8.0.1.1.0',
'version': '8.0.1.2.0',
'author': 'GRAP,Odoo Community Association (OCA)', 'author': 'GRAP,Odoo Community Association (OCA)',
'category': 'Point Of Sale', 'category': 'Point Of Sale',
'license': 'AGPL-3', 'license': 'AGPL-3',

3
pos_picking_load/models/pos_config.py

@ -10,3 +10,6 @@ class PosConfig(models.Model):
_inherit = 'pos.config' _inherit = 'pos.config'
iface_load_picking = fields.Boolean(string='Load Pickings', default=True) 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)

0
pos_picking_load/models/stock_move.py

31
pos_picking_load/models/stock_picking.py

@ -18,30 +18,37 @@ class StockPicking(models.Model):
# Custom Section # Custom Section
@api.model @api.model
def _prepare_filter_for_pos(self, pos_session_id): 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 [ return [
('picking_type_id', 'in', picking_types.ids),
('state', 'in', ['confirmed', 'partially_available', 'assigned']), ('state', 'in', ['confirmed', 'partially_available', 'assigned']),
('invoice_state', '=', '2binvoiced'), ('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 @api.model
def _prepare_fields_for_pos_list(self): def _prepare_fields_for_pos_list(self):
return ['name', 'partner_id', 'min_date', 'origin'] return ['name', 'partner_id', 'min_date', 'origin']
@api.model @api.model
def search_pickings_for_pos(self, query, pos_session_id): 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() 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 @api.multi
def load_picking_for_pos(self): def load_picking_for_pos(self):

2
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) { prepare_orderline: function(product, pickingline) {
return { return {
quantity: pickingline.qty,
quantity: pickingline.quantity,
price: pickingline.price_unit || product.price, price: pickingline.price_unit || product.price,
discount: pickingline.discount || 0.0, discount: pickingline.discount || 0.0,
}; };

1
pos_picking_load/views/view_pos_config.xml

@ -7,6 +7,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="iface_invoicing" position="after"> <field name="iface_invoicing" position="after">
<field name="iface_load_picking" /> <field name="iface_load_picking" />
<field name="iface_load_picking_max_qty" attrs="{'invisible': [('iface_load_picking', '=', False)]}" />
</field> </field>
</field> </field>
</record> </record>

Loading…
Cancel
Save