1、调整功能刀具清单模型的菜单代码位置,解决依赖冲突问题;2、产品采购时,添加一个订单同时采购多个相同产品的校验;3、优化刀柄采购入库时,自动生成的序列号规则;
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<field name="name">刀具标准库</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.cutting_tool.standard.library</field>
|
||||
<!-- <field name="context">{'default_cutting_tool_material_id': cutting_tool_material_id}</field>-->
|
||||
<!-- <field name="context">{'default_cutting_tool_material_id': cutting_tool_material_id}</field>-->
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<!-- 功能刀具action -->
|
||||
@@ -69,14 +69,22 @@
|
||||
sequence="20"
|
||||
action="action_sf_cutting_tool_standard_library"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_tool_inventory"
|
||||
parent="menu_sf_cutting_tool"
|
||||
name="功能刀具清单"
|
||||
sequence="25"
|
||||
action="action_sf_tool_inventory"
|
||||
/>
|
||||
<!-- 功能刀具 -->
|
||||
<!-- <menuitem-->
|
||||
<!-- id="menu_sf_functional_cutting_tool"-->
|
||||
<!-- parent="menu_sf_cutting_tool"-->
|
||||
<!-- name="功能刀具"-->
|
||||
<!-- sequence="5"-->
|
||||
<!-- action="action_sf_functional_cutting_tool"-->
|
||||
<!-- />-->
|
||||
<!-- <menuitem-->
|
||||
<!-- id="menu_sf_functional_cutting_tool"-->
|
||||
<!-- parent="menu_sf_cutting_tool"-->
|
||||
<!-- name="功能刀具"-->
|
||||
<!-- sequence="5"-->
|
||||
<!-- action="action_sf_functional_cutting_tool"-->
|
||||
<!-- />-->
|
||||
<!-- 功能刀具类型 -->
|
||||
<menuitem
|
||||
id="menu_sf_functional_cutting_tool_model_type"
|
||||
|
||||
@@ -609,13 +609,4 @@
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_tool_inventory"
|
||||
parent="menu_sf_cutting_tool"
|
||||
name="功能刀具清单"
|
||||
sequence="25"
|
||||
action="action_sf_tool_inventory"
|
||||
/>
|
||||
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -206,6 +206,16 @@ class RePurchaseOrder(models.Model):
|
||||
order.message_subscribe([order.partner_id.id])
|
||||
return True
|
||||
|
||||
@api.onchange('order_line')
|
||||
def _onchange_order_line(self):
|
||||
for order in self:
|
||||
if order.order_line:
|
||||
line = order.order_line
|
||||
product = line.product_id
|
||||
product_id = product.ids
|
||||
if len(product_id) != len(line):
|
||||
raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name)
|
||||
|
||||
|
||||
class ResPartnerToSale(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
Reference in New Issue
Block a user