Skip to content

Commit

Permalink
[ADD] Quick wins inventory adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
jcadhoc committed Jan 16, 2024
1 parent 4675037 commit e6a2b6d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions stock_ux/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
from . import stock_picking_type
from . import res_config_settings
from . import stock_rule
from . import stock_quant
33 changes: 33 additions & 0 deletions stock_ux/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from odoo import models,api

class StockQuant(models.Model):
_inherit = 'stock.quant'



# Establecemos por defecto al usuario creador
@api.onchange('inventory_quantity')
def _onchange_inventory_quantity_user(self):
if not self.user_id:
self.user_id = self.env.user

def _get_inventory_move_values(self, qty, location_id, location_dest_id, out=False):
self.ensure_one()
move_values = super(StockQuant, self)._get_inventory_move_values(qty, location_id, location_dest_id, out)
partner_id = self.user_id.partner_id
move_line_values = {
'product_id': self.product_id.id,
'product_uom_id': self.product_uom_id.id,
'qty_done': qty,
'location_id': location_id.id,
'location_dest_id': location_dest_id.id,
'company_id': self.company_id.id or self.env.company.id,
'lot_id': self.lot_id.id,
'package_id': out and self.package_id.id or False,
'result_package_id': (not out) and self.package_id.id or False,
'owner_id': self.owner_id.id,
'picking_partner_id': partner_id.id or self.owner_id.id, # Agregamos el usuario contador
}
move_values['move_line_ids'] = [(0, 0, move_line_values)]

return move_values

0 comments on commit e6a2b6d

Please sign in to comment.