upgrade v16 addons valores por defecto según la categoría interna

This commit is contained in:
snt 2024-09-04 23:07:41 +02:00
parent 688782abd8
commit 412d897695
88 changed files with 4 additions and 4787 deletions

View file

@ -1,2 +0,0 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import stock_move

View file

@ -1,58 +0,0 @@
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'
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