|
|
|
|
@@ -317,13 +317,15 @@ class ProductionLot(models.Model):
|
|
|
|
|
"""
|
|
|
|
|
now = datetime.now().strftime("%Y%m%d")
|
|
|
|
|
last_serial = self.env['stock.lot'].search(
|
|
|
|
|
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'like', now)],
|
|
|
|
|
[('company_id', '=', company.id), ('product_id', '=', product.id)],
|
|
|
|
|
limit=1, order='id DESC')
|
|
|
|
|
if product.cutting_tool_model_id:
|
|
|
|
|
split_codes = product.cutting_tool_model_id.code.split('-')
|
|
|
|
|
if not last_serial:
|
|
|
|
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
|
|
|
|
|
return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1)
|
|
|
|
|
else:
|
|
|
|
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 1)
|
|
|
|
|
return "%s-T-%s-%s-%03d" % (
|
|
|
|
|
split_codes[0], now, product.specification_id.name, int(last_serial.name[-3:]) + 1)
|
|
|
|
|
else:
|
|
|
|
|
raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!')
|
|
|
|
|
|
|
|
|
|
@@ -341,7 +343,8 @@ class ProductionLot(models.Model):
|
|
|
|
|
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1]
|
|
|
|
|
now = datetime.now().strftime("%Y%m%d")
|
|
|
|
|
if product.cutting_tool_model_id:
|
|
|
|
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
|
|
|
|
|
split_codes = product.cutting_tool_model_id.code.split('-')
|
|
|
|
|
return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1)
|
|
|
|
|
return "%s-%03d" % (product.name, 1)
|
|
|
|
|
|
|
|
|
|
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
|
|
|
|
|
@@ -539,6 +542,65 @@ class ReStockMove(models.Model):
|
|
|
|
|
else:
|
|
|
|
|
raise UserError(_("没有可打印的标签数据"))
|
|
|
|
|
|
|
|
|
|
def action_show_details(self):
|
|
|
|
|
""" Returns an action that will open a form view (in a popup) allowing to work on all the
|
|
|
|
|
move lines of a particular move. This form view is used when "show operations" is not
|
|
|
|
|
checked on the picking type.
|
|
|
|
|
"""
|
|
|
|
|
self.ensure_one()
|
|
|
|
|
|
|
|
|
|
# If "show suggestions" is not checked on the picking type, we have to filter out the
|
|
|
|
|
# reserved move lines. We do this by displaying `move_line_nosuggest_ids`. We use
|
|
|
|
|
# different views to display one field or another so that the webclient doesn't have to
|
|
|
|
|
# fetch both.
|
|
|
|
|
if self.picking_type_id.show_reserved:
|
|
|
|
|
view = self.env.ref('stock.view_stock_move_operations')
|
|
|
|
|
else:
|
|
|
|
|
view = self.env.ref('stock.view_stock_move_nosuggest_operations')
|
|
|
|
|
|
|
|
|
|
if self.product_id.tracking == "serial" and self.state == "assigned":
|
|
|
|
|
print(self.origin)
|
|
|
|
|
if self.product_id.categ_id.name == '刀具':
|
|
|
|
|
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
|
|
|
|
|
else:
|
|
|
|
|
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'name': _('Detailed Operations'),
|
|
|
|
|
'type': 'ir.actions.act_window',
|
|
|
|
|
'view_mode': 'form',
|
|
|
|
|
'res_model': 'stock.move',
|
|
|
|
|
'views': [(view.id, 'form')],
|
|
|
|
|
'view_id': view.id,
|
|
|
|
|
'target': 'new',
|
|
|
|
|
'res_id': self.id,
|
|
|
|
|
'context': dict(
|
|
|
|
|
self.env.context,
|
|
|
|
|
show_owner=self.picking_type_id.code != 'incoming',
|
|
|
|
|
show_lots_m2o=self.has_tracking != 'none' and (
|
|
|
|
|
self.picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id),
|
|
|
|
|
# able to create lots, whatever the value of ` use_create_lots`.
|
|
|
|
|
show_lots_text=self.has_tracking != 'none' and self.picking_type_id.use_create_lots and not self.picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id,
|
|
|
|
|
show_source_location=self.picking_type_id.code != 'incoming',
|
|
|
|
|
show_destination_location=self.picking_type_id.code != 'outgoing',
|
|
|
|
|
show_package=not self.location_id.usage == 'supplier',
|
|
|
|
|
show_reserved_quantity=self.state != 'done' and not self.picking_id.immediate_transfer and self.picking_type_id.code != 'incoming'
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def _get_tool_next_serial(self, company, product, origin):
|
|
|
|
|
"""Return the next serial number to be attributed to the product."""
|
|
|
|
|
if product.tracking == "serial":
|
|
|
|
|
last_serial = self.env['stock.lot'].search(
|
|
|
|
|
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', origin)],
|
|
|
|
|
limit=1, order='id DESC')
|
|
|
|
|
split_codes = product.cutting_tool_model_id.code.split('-')
|
|
|
|
|
if last_serial:
|
|
|
|
|
return "%s-T-%s-%s-%03d" % (
|
|
|
|
|
split_codes[0], origin, product.specification_id.name, int(last_serial.name[-3:]) + 1)
|
|
|
|
|
else:
|
|
|
|
|
return "%s-T-%s-%s-%03d" % (split_codes[0], origin, product.specification_id.name, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ReStockQuant(models.Model):
|
|
|
|
|
_inherit = 'stock.quant'
|
|
|
|
|
|