1、优化采购刀具物料时刀具物料的序列号生成规则
This commit is contained in:
@@ -14,6 +14,7 @@ from odoo.addons.stock.models.stock_rule import ProcurementException
|
|||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class StockRule(models.Model):
|
class StockRule(models.Model):
|
||||||
@@ -250,6 +251,22 @@ class ProductionLot(models.Model):
|
|||||||
))
|
))
|
||||||
return lot_names
|
return lot_names
|
||||||
|
|
||||||
|
def get_tool_generate_lot_names1(self, company, product):
|
||||||
|
"""
|
||||||
|
采购时生成刀具物料序列号
|
||||||
|
"""
|
||||||
|
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)],
|
||||||
|
limit=1, order='id DESC')
|
||||||
|
if product.cutting_tool_model_id:
|
||||||
|
if not last_serial:
|
||||||
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
|
||||||
|
else:
|
||||||
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 1)
|
||||||
|
else:
|
||||||
|
raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!')
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_next_serial(self, company, product):
|
def _get_next_serial(self, company, product):
|
||||||
"""Return the next serial number to be attributed to the product."""
|
"""Return the next serial number to be attributed to the product."""
|
||||||
@@ -258,12 +275,13 @@ class ProductionLot(models.Model):
|
|||||||
[('company_id', '=', company.id), ('product_id', '=', product.id)],
|
[('company_id', '=', company.id), ('product_id', '=', product.id)],
|
||||||
limit=1, order='id DESC')
|
limit=1, order='id DESC')
|
||||||
if last_serial:
|
if last_serial:
|
||||||
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[
|
if product.categ_id.name == '刀具':
|
||||||
1]
|
return self.env['stock.lot'].get_tool_generate_lot_names1(company, product)
|
||||||
now = datetime.now().strftime("%Y-%m-%d")
|
else:
|
||||||
# formatted_date = now.strftime("%Y-%m-%d")
|
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:
|
if product.cutting_tool_model_id:
|
||||||
return "%s-%s-%03d" % (product.cutting_tool_model_id.code, now, 1)
|
return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1)
|
||||||
return "%s-%03d" % (product.name, 1)
|
return "%s-%03d" % (product.name, 1)
|
||||||
|
|
||||||
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
|
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
|
||||||
|
|||||||
Reference in New Issue
Block a user