Accept Merge Request #1324: (feature/库存优化 -> develop)

Merge Request: 库存优化

Created By: @禹翔辉
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1324
This commit is contained in:
禹翔辉
2024-09-19 17:29:29 +08:00
committed by Coding
3 changed files with 11 additions and 9 deletions

View File

@@ -931,13 +931,6 @@ class SfStockMoveLine(models.Model):
if not record.destination_location_id.product_id:
record.destination_location_id.product_id = record.product_id.id
@api.model_create_multi
def create(self, vals_list):
records = super(SfStockMoveLine, self).create(vals_list)
self.put_shelf_location(records)
return records
class SfStockPicking(models.Model):
_inherit = 'stock.picking'
@@ -1122,6 +1115,12 @@ class SfPickingType(models.Model):
'sf_warehouse.group_sf_stock_manager'
)
def _get_action(self, action_xmlid):
action = super(SfPickingType, self)._get_action(action_xmlid)
if not self.env.user.has_group('base.group_system'):
action['context']['create'] = False
return action
class CustomStockMove(models.Model):
_name = 'stock.move'

View File

@@ -4,6 +4,7 @@
<record model="ir.actions.act_window" id="stock.stock_picking_type_action">
<field name="context">{'search_default_groupby_code':1}</field>
<field name="domain">[('name', '!=', '制造')]</field>
</record>
<record id="view_location_form_sf_inherit" model="ir.ui.view">

View File

@@ -77,18 +77,20 @@ class ShelfLocationWizard(models.TransientModel):
def confirm_the_change(self):
if self.destination_barcode_id:
stocks = []
if self.lot_id:
self.current_barcode_id.product_sn_id = False
self.destination_barcode_id.product_sn_id = self.lot_id.id
self.create_stock_moves(self.lot_id, 1)
stocks = self.create_stock_moves(self.lot_id, 1)
elif self.current_product_sn_ids:
for current_product_sn_id in self.current_product_sn_ids:
self.create_stock_moves(current_product_sn_id.lot_id, current_product_sn_id.qty_num)
stocks = self.create_stock_moves(current_product_sn_id.lot_id, current_product_sn_id.qty_num)
current_product_sn_id.write({
'qty_num': 0
})
else:
raise ValidationError('没有需要变更的批次/序列号!')
self.env['stock.move.line'].sudo().put_shelf_location(stocks[-1])
else:
raise ValidationError('请选择目标货位编码!')