Compare commits
15 Commits
feature/72
...
feature/72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5008210176 | ||
|
|
f487ab4cce | ||
|
|
3527105e83 | ||
|
|
88e4cfb541 | ||
|
|
5a175c078f | ||
|
|
20980bed9d | ||
|
|
9b94357439 | ||
|
|
5ae3c5dd47 | ||
|
|
60be14dda2 | ||
|
|
f0ff7c4a74 | ||
|
|
2b6e2fe31b | ||
|
|
f1390e47c9 | ||
|
|
c7cd0a6a69 | ||
|
|
fa5307a2ea | ||
|
|
4706bfe85e |
@@ -41,8 +41,10 @@ class StockPicking(models.Model):
|
|||||||
if backorder_ids:
|
if backorder_ids:
|
||||||
purchase_request_lines = self.move_ids.move_orig_ids.purchase_line_id.purchase_request_lines
|
purchase_request_lines = self.move_ids.move_orig_ids.purchase_line_id.purchase_request_lines
|
||||||
if purchase_request_lines:
|
if purchase_request_lines:
|
||||||
purchase_request_lines.move_dest_ids = [
|
purchase_request_lines.move_dest_ids = [
|
||||||
(4, x.id) for x in backorder_ids.move_ids if x.product_id.id in purchase_request_lines.mapped('product_id.id')
|
(4, x.id) for x in backorder_ids.move_ids if
|
||||||
|
x.product_id.id in purchase_request_lines.mapped('product_id.id') and \
|
||||||
|
not x.created_purchase_request_line_id
|
||||||
]
|
]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -18,3 +18,12 @@ class MrpBom(models.Model):
|
|||||||
subcontract = self.get_supplier(product.materials_type_id)
|
subcontract = self.get_supplier(product.materials_type_id)
|
||||||
bom_id.subcontractor_id = subcontract.partner_id.id
|
bom_id.subcontractor_id = subcontract.partner_id.id
|
||||||
return bom_id
|
return bom_id
|
||||||
|
|
||||||
|
def name_get(self):
|
||||||
|
"""重写name_get方法,只显示BOM编码"""
|
||||||
|
result = []
|
||||||
|
for record in self:
|
||||||
|
# 只显示BOM编码,如果编码为空则显示产品名称
|
||||||
|
display_name = record.code or record.product_tmpl_id.name or f'BOM-{record.id}'
|
||||||
|
result.append((record.id, display_name))
|
||||||
|
return result
|
||||||
@@ -36,6 +36,9 @@ class SfDemandPlan(models.Model):
|
|||||||
|
|
||||||
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
|
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
|
||||||
related='product_id.blank_type')
|
related='product_id.blank_type')
|
||||||
|
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型',
|
||||||
|
related='product_id.blank_precision')
|
||||||
|
manual_quotation = fields.Boolean('人工编程',related='product_id.manual_quotation', default=False)
|
||||||
embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long', store=True)
|
embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long', store=True)
|
||||||
is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True)
|
is_incoming_material = fields.Boolean('客供料', related='sale_order_line_id.is_incoming_material', store=True)
|
||||||
pending_qty = fields.Float(
|
pending_qty = fields.Float(
|
||||||
@@ -112,7 +115,10 @@ class SfDemandPlan(models.Model):
|
|||||||
def _compute_embryo_long(self):
|
def _compute_embryo_long(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
if line.product_id.blank_type == '圆料':
|
||||||
|
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
|
||||||
|
else:
|
||||||
|
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
||||||
else:
|
else:
|
||||||
line.embryo_long = None
|
line.embryo_long = None
|
||||||
|
|
||||||
@@ -209,13 +215,16 @@ class SfDemandPlan(models.Model):
|
|||||||
def name_get(self):
|
def name_get(self):
|
||||||
result = []
|
result = []
|
||||||
for plan in self:
|
for plan in self:
|
||||||
result.append((plan.id, plan.product_id.name))
|
result.append((plan.id, plan.demand_plan_number))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def button_production_release_plan(self):
|
def button_production_release_plan(self):
|
||||||
line_ids = self.line_ids.filtered(lambda p: p.status == '30')
|
line_ids = self.line_ids.filtered(lambda p: p.status == '30')
|
||||||
sum_product_uom_qty = sum(line_ids.mapped('plan_uom_qty'))
|
sum_product_uom_qty = sum(line_ids.mapped('plan_uom_qty'))
|
||||||
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
||||||
|
for line in self.line_ids:
|
||||||
|
if line.manual_quotation and line.custom_made_type == 'automation':
|
||||||
|
raise ValidationError(f"产品{line.product_id.name}为人工编程,不能选择自动化产线加工")
|
||||||
if not self.overdelivery_allowed and line_ids.filtered(lambda p: p.location_id.id == customer_location_id):
|
if not self.overdelivery_allowed and line_ids.filtered(lambda p: p.location_id.id == customer_location_id):
|
||||||
if float_compare(sum_product_uom_qty, self.product_uom_qty,
|
if float_compare(sum_product_uom_qty, self.product_uom_qty,
|
||||||
precision_rounding=self.product_id.uom_id.rounding) == 1:
|
precision_rounding=self.product_id.uom_id.rounding) == 1:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
status = fields.Selection([
|
status = fields.Selection([
|
||||||
('10', '草稿'),
|
('10', '草稿'),
|
||||||
('20', '待确认'),
|
('20', '待确认'),
|
||||||
('30', '需求确认'),
|
('30', '待工艺设计'),
|
||||||
('50', '待下达生产'),
|
('50', '待下达生产'),
|
||||||
('60', '已下达'),
|
('60', '已下达'),
|
||||||
('100', '取消'),
|
('100', '取消'),
|
||||||
@@ -169,7 +169,7 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
finished_product_arrival_date = fields.Date('采购计划到货(成品)')
|
finished_product_arrival_date = fields.Date('采购计划到货(成品)')
|
||||||
bom_id = fields.Many2one('mrp.bom', string="BOM", readonly=True)
|
bom_id = fields.Many2one('mrp.bom', string="BOM", readonly=True)
|
||||||
location_id = fields.Many2one('stock.location', string='需求位置', default=get_location_id, readonly=True)
|
location_id = fields.Many2one('stock.location', string='需求位置', default=get_location_id, readonly=True)
|
||||||
|
manual_quotation = fields.Boolean('人工编程',related='product_id.manual_quotation',default=False)
|
||||||
@api.constrains('plan_uom_qty')
|
@api.constrains('plan_uom_qty')
|
||||||
def _check_plan_uom_qty(self):
|
def _check_plan_uom_qty(self):
|
||||||
line_ids = self.filtered(lambda p: p.plan_uom_qty == 0 or p.plan_uom_qty < 0)
|
line_ids = self.filtered(lambda p: p.plan_uom_qty == 0 or p.plan_uom_qty < 0)
|
||||||
@@ -344,9 +344,11 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
pro_plan.do_production_schedule()
|
pro_plan.do_production_schedule()
|
||||||
|
|
||||||
def update_sale_order_state(self):
|
def update_sale_order_state(self):
|
||||||
demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)])
|
# demand_plan = self.env['sf.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)])
|
||||||
demand_plan_state = demand_plan.filtered(lambda line: line.state != '40')
|
# demand_plan_state = demand_plan.filtered(lambda line: line.state != '40')
|
||||||
if not demand_plan_state:
|
production_demand_plan = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.sale_order_id.id)])
|
||||||
|
production_demand_plan_state = production_demand_plan.filtered(lambda line: line.status in ('10', '20', '30'))
|
||||||
|
if not production_demand_plan_state:
|
||||||
# 修改销售订单为加工中
|
# 修改销售订单为加工中
|
||||||
self.sale_order_id.state = 'processing'
|
self.sale_order_id.state = 'processing'
|
||||||
|
|
||||||
@@ -587,7 +589,7 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
def unlink(self):
|
def unlink(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.status not in ('10', '20', '30'):
|
if item.status not in ('10', '20', '30'):
|
||||||
raise ValidationError(u'只能删除状态为【草稿,待确认,需求确认】的需求计划。')
|
raise ValidationError(u'只能删除状态为【草稿,待确认,待工艺设计】的需求计划。')
|
||||||
else:
|
else:
|
||||||
super(SfProductionDemandPlan, item).unlink()
|
super(SfProductionDemandPlan, item).unlink()
|
||||||
|
|
||||||
@@ -642,6 +644,8 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if not self.new_supply_method:
|
if not self.new_supply_method:
|
||||||
raise ValidationError(f"供货方式不能为空!")
|
raise ValidationError(f"供货方式不能为空!")
|
||||||
|
if self.product_id.manual_quotation and self.custom_made_type == 'automation':
|
||||||
|
raise ValidationError(f"产品{self.product_id.name}为人工编程,不能选择自动化产线加工")
|
||||||
check_overdelivery_allowed = False
|
check_overdelivery_allowed = False
|
||||||
if not self.demand_plan_id.overdelivery_allowed:
|
if not self.demand_plan_id.overdelivery_allowed:
|
||||||
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
||||||
@@ -673,6 +677,7 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
self._action_launch_stock_rule()
|
self._action_launch_stock_rule()
|
||||||
if self.supply_method in ('automation', 'manual'):
|
if self.supply_method in ('automation', 'manual'):
|
||||||
self.write({'status': '50'})
|
self.write({'status': '50'})
|
||||||
|
self.update_sale_order_state()
|
||||||
else:
|
else:
|
||||||
self.write({'status': '60'})
|
self.write({'status': '60'})
|
||||||
self.update_sale_order_state()
|
self.update_sale_order_state()
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
th[data-name=processing_time] + th::before{
|
/*.demand_plan_tree th[data-name=planned_start_date] + th::before{*/
|
||||||
content: '待执行单据';
|
/* content: '待执行单据';*/
|
||||||
line-height: 38px;
|
/* line-height: 38px;*/
|
||||||
}
|
/*}*/
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<field name="model_id" optional="hide"/>
|
<field name="model_id" optional="hide"/>
|
||||||
<field name="part_name"/>
|
<field name="part_name"/>
|
||||||
<field name="part_number"/>
|
<field name="part_number"/>
|
||||||
|
<field name="manual_quotation" optional="hide"/>
|
||||||
<field name="is_incoming_material"/>
|
<field name="is_incoming_material"/>
|
||||||
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
<field name="readonly_custom_made_type" invisible="1"/>
|
<field name="readonly_custom_made_type" invisible="1"/>
|
||||||
@@ -31,9 +32,9 @@
|
|||||||
<field name="product_uom_qty"/>
|
<field name="product_uom_qty"/>
|
||||||
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
<field name="deadline_of_delivery"/>
|
<field name="deadline_of_delivery"/>
|
||||||
<field name="inventory_quantity_auto_apply"/>
|
<field name="inventory_quantity_auto_apply" optional="hide"/>
|
||||||
<field name="qty_delivered"/>
|
<field name="qty_delivered" optional="hide"/>
|
||||||
<field name="qty_to_deliver"/>
|
<field name="qty_to_deliver" optional="hide"/>
|
||||||
<field name="model_long"/>
|
<field name="model_long"/>
|
||||||
<field name="blank_type" optional="hide"/>
|
<field name="blank_type" optional="hide"/>
|
||||||
<field name="blank_precision"/>
|
<field name="blank_precision"/>
|
||||||
|
|||||||
@@ -20,7 +20,9 @@
|
|||||||
<field name="part_number"/>
|
<field name="part_number"/>
|
||||||
<field name="materials_id"/>
|
<field name="materials_id"/>
|
||||||
<field name="blank_type"/>
|
<field name="blank_type"/>
|
||||||
|
<field name="blank_precision"/>
|
||||||
<field name="embryo_long"/>
|
<field name="embryo_long"/>
|
||||||
|
<field name="manual_quotation"/>
|
||||||
<field name="is_incoming_material"/>
|
<field name="is_incoming_material"/>
|
||||||
<field name="pending_qty"/>
|
<field name="pending_qty"/>
|
||||||
<field name="planned_qty"/>
|
<field name="planned_qty"/>
|
||||||
@@ -86,7 +88,7 @@
|
|||||||
'required': [('new_supply_method', '=', 'custom_made')]}"/>
|
'required': [('new_supply_method', '=', 'custom_made')]}"/>
|
||||||
<field name="route_ids" widget="many2many_tags" optional="hide"/>
|
<field name="route_ids" widget="many2many_tags" optional="hide"/>
|
||||||
<field name="location_id" optional="hide"/>
|
<field name="location_id" optional="hide"/>
|
||||||
<field name="bom_id" optional="hide"/>
|
<field name="bom_id" optional="hide" readonly="1" options="{'no_create': True}"/>
|
||||||
<field name="processing_time" optional="hide"/>
|
<field name="processing_time" optional="hide"/>
|
||||||
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
<field name="blank_arrival_date"/>
|
<field name="blank_arrival_date"/>
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ class StockRule(models.Model):
|
|||||||
'''
|
'''
|
||||||
创建制造订单时生成序列号
|
创建制造订单时生成序列号
|
||||||
'''
|
'''
|
||||||
production.action_generate_serial()
|
if production.product_id.tracking != "none":
|
||||||
|
production.action_generate_serial()
|
||||||
origin_production = production.move_dest_ids and production.move_dest_ids[
|
origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||||
0].raw_material_production_id or False
|
0].raw_material_production_id or False
|
||||||
orderpoint = production.orderpoint_id
|
orderpoint = production.orderpoint_id
|
||||||
@@ -442,7 +443,7 @@ class ProductionLot(models.Model):
|
|||||||
@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."""
|
||||||
if product.tracking == "serial":
|
if product.tracking != "none":
|
||||||
last_serial = self.env['stock.lot'].search(
|
last_serial = self.env['stock.lot'].search(
|
||||||
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)],
|
[('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)],
|
||||||
limit=1, order='name desc')
|
limit=1, order='name desc')
|
||||||
@@ -453,7 +454,9 @@ class ProductionLot(models.Model):
|
|||||||
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if (
|
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if (
|
||||||
not move_line_id or
|
not move_line_id or
|
||||||
(last_serial and last_serial.name > move_line_id.lot_name)) else move_line_id.lot_name, 2)[1]
|
(last_serial and last_serial.name > move_line_id.lot_name)) else move_line_id.lot_name, 2)[1]
|
||||||
return "%s-%03d" % (product.name, 1)
|
else:
|
||||||
|
return "%s-%03d" % (product.name, 1)
|
||||||
|
return False
|
||||||
|
|
||||||
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