Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] Quick wins inventory adjustment #430

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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