#322 filtra la carga de pickings en el PDV cuando hay un cliente seleccionado. Añadido módulo con página de consulta de productos en el website
This commit is contained in:
parent
6debf13f25
commit
bc5f2ab42a
17 changed files with 390 additions and 1 deletions
2
website_search_products/models/__init__.py
Normal file
2
website_search_products/models/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import stock_move
|
||||
59
website_search_products/models/stock_move.py
Normal file
59
website_search_products/models/stock_move.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
from odoo import tools
|
||||
from odoo import models, fields, api
|
||||
|
||||
from datetime import date,datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
@api.multi
|
||||
def get_stock_moves_by_product(self, date_begin, date_end, location):
|
||||
|
||||
if date_begin and date_end:
|
||||
moves = self.env['stock.move'].search([
|
||||
'|',
|
||||
('location_id','=',int(location)),
|
||||
('location_dest_id','=',int(location)),
|
||||
('state', '=', 'done'),
|
||||
('date','>=',date_begin),
|
||||
('date','<=',date_end),
|
||||
])
|
||||
else:
|
||||
return []
|
||||
|
||||
moves_grouped = {}
|
||||
data = []
|
||||
|
||||
if moves:
|
||||
for move in moves:
|
||||
if move.product_id.id and move.product_id.type == 'product':
|
||||
if not moves_grouped.get(move.product_id.id, False):
|
||||
date_end_obj = datetime.strptime(date_end, '%Y-%m-%d').date() + relativedelta(days=1)
|
||||
moves_grouped[move.product_id.id] = dict([])
|
||||
moves_grouped[move.product_id.id]['name'] = move.product_id.name
|
||||
moves_grouped[move.product_id.id]['category'] = move.product_id.categ_id.name
|
||||
moves_grouped[move.product_id.id]['list_price'] = move.product_id.list_price
|
||||
moves_grouped[move.product_id.id]['qty_init'] = move.product_id.with_context({
|
||||
'to_date':date_begin,
|
||||
'location': int(location)
|
||||
}).qty_available
|
||||
moves_grouped[move.product_id.id]['qty_end'] = move.product_id.with_context({
|
||||
'to_date':date_end_obj,
|
||||
'location': int(location)
|
||||
}).qty_available
|
||||
|
||||
if not moves_grouped[move.product_id.id].get('in'):
|
||||
moves_grouped[move.product_id.id]['in'] = 0.0
|
||||
if not moves_grouped[move.product_id.id].get('out'):
|
||||
moves_grouped[move.product_id.id]['out'] = 0.0
|
||||
if int(move.location_id) == int(location):
|
||||
moves_grouped[move.product_id.id]['out'] += move.product_qty
|
||||
elif int(move.location_dest_id) == int(location):
|
||||
moves_grouped[move.product_id.id]['in'] += move.product_qty
|
||||
|
||||
data = list(moves_grouped.values())
|
||||
return data
|
||||
Loading…
Add table
Add a link
Reference in a new issue