Compare commits
2 Commits
feature/物料
...
feature/72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f66f275719 | ||
|
|
0cb473f209 |
@@ -41,10 +41,8 @@ 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
|
(4, x.id) for x in backorder_ids.move_ids if x.product_id.id in purchase_request_lines.mapped('product_id.id')
|
||||||
x.product_id.id in purchase_request_lines.mapped('product_id.id') and \
|
|
||||||
not x.created_purchase_request_line_id
|
|
||||||
]
|
]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'sf',
|
'category': 'sf',
|
||||||
'website': 'https://www.sf.jikimo.com',
|
'website': 'https://www.sf.jikimo.com',
|
||||||
'depends': ['sf_plan', 'jikimo_printing', 'purchase_request', 'purchase_request_tier_validation'],
|
'depends': ['sf_plan','jikimo_printing'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'data/stock_route_group.xml',
|
'data/stock_route_group.xml',
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
'views/sale_order_views.xml',
|
'views/sale_order_views.xml',
|
||||||
'wizard/sf_demand_plan_print_wizard_view.xml',
|
'wizard/sf_demand_plan_print_wizard_view.xml',
|
||||||
'wizard/sf_release_plan_wizard_views.xml',
|
'wizard/sf_release_plan_wizard_views.xml',
|
||||||
'wizard/sf_demand_plan_detail_wizard_view.xml',
|
|
||||||
'views/menu_view.xml',
|
'views/menu_view.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
@@ -31,7 +30,6 @@
|
|||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'sf_demand_plan/static/src/scss/style.css',
|
'sf_demand_plan/static/src/scss/style.css',
|
||||||
'sf_demand_plan/static/src/js/print_demand.js',
|
'sf_demand_plan/static/src/js/print_demand.js',
|
||||||
'sf_demand_plan/static/src/js/custom_button.js',
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'license': 'LGPL-3',
|
'license': 'LGPL-3',
|
||||||
|
|||||||
@@ -9,5 +9,3 @@ from . import mrp_production
|
|||||||
from . import stock_rule
|
from . import stock_rule
|
||||||
from . import purchase_request
|
from . import purchase_request
|
||||||
from . import purchase_order
|
from . import purchase_order
|
||||||
from . import stock_move
|
|
||||||
from . import stock_picking
|
|
||||||
|
|||||||
@@ -18,12 +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):
|
def name_get(self):
|
||||||
"""重写name_get方法,只显示BOM编码"""
|
"""重写name_get方法,只显示BOM编码"""
|
||||||
result = []
|
result = []
|
||||||
for record in self:
|
for record in self:
|
||||||
# 只显示BOM编码,如果编码为空则显示产品名称
|
# 只显示BOM编码,如果编码为空则显示名称
|
||||||
display_name = record.code or record.product_tmpl_id.name or f'BOM-{record.id}'
|
display_name = record.code or record.name or f'BOM-{record.id}'
|
||||||
result.append((record.id, display_name))
|
result.append((record.id, display_name))
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class PurchaseOrderLine(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
res = super(PurchaseOrderLine, self).create(vals)
|
res = super(PurchaseOrderLine, self).create(vals)
|
||||||
if not res.demand_plan_line_id and res.order_id.origin:
|
if not res.demand_plan_line_id:
|
||||||
origin = [origin.replace(' ', '') for origin in res.order_id.origin.split(',')]
|
origin = [origin.replace(' ', '') for origin in res.order_id.origin.split(',')]
|
||||||
if self.env.context.get('demand_plan_line_id'):
|
if self.env.context.get('demand_plan_line_id'):
|
||||||
res.demand_plan_line_id = self.env.context.get('demand_plan_line_id')
|
res.demand_plan_line_id = self.env.context.get('demand_plan_line_id')
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ 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(
|
||||||
@@ -115,10 +112,7 @@ 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:
|
||||||
if line.product_id.blank_type == '圆料':
|
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)}"
|
||||||
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
|
||||||
|
|
||||||
@@ -215,7 +209,7 @@ 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.demand_plan_number))
|
result.append((plan.id, plan.product_id.name))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def button_production_release_plan(self):
|
def button_production_release_plan(self):
|
||||||
@@ -224,10 +218,10 @@ class SfDemandPlan(models.Model):
|
|||||||
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')
|
||||||
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:
|
||||||
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
|
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
|
||||||
elif float_compare(sum_product_uom_qty, self.product_uom_qty,
|
elif 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:
|
||||||
return {
|
return {
|
||||||
'name': _('需求计划'),
|
'name': _('需求计划'),
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
@@ -243,12 +237,11 @@ class SfDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
for demand_plan_line_id in line_ids:
|
for demand_plan_line_id in line_ids:
|
||||||
demand_plan_line_id.action_confirm()
|
demand_plan_line_id.action_confirm()
|
||||||
|
#需求要求取值格式是来源+来源明细行ID,但是来源明细行ID取得就是product_id.name得最后一位,所以这里也直接截取product_id.name
|
||||||
# 需求要求取值格式是来源+来源明细行ID,但是来源明细行ID取得就是product_id.name得最后一位,所以这里也直接截取product_id.name
|
|
||||||
@api.depends('product_id.name')
|
@api.depends('product_id.name')
|
||||||
def _compute_demand_plan_number(self):
|
def _compute_demand_plan_number(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
product_name = line.product_id.name or ''
|
product_name = line.product_id.name or ''
|
||||||
plan_no = None
|
plan_no = None
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
# 使用正则表达式匹配P-后面的所有字符
|
# 使用正则表达式匹配P-后面的所有字符
|
||||||
@@ -257,4 +250,4 @@ class SfDemandPlan(models.Model):
|
|||||||
plan_no = match.group(1)
|
plan_no = match.group(1)
|
||||||
line.demand_plan_number = plan_no
|
line.demand_plan_number = plan_no
|
||||||
else:
|
else:
|
||||||
line.demand_plan_number = None
|
line.demand_plan_number = None
|
||||||
@@ -14,14 +14,14 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
_description = 'sf_production_demand_plan'
|
_description = 'sf_production_demand_plan'
|
||||||
|
|
||||||
def get_location_id(self):
|
def get_location_id(self):
|
||||||
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
|
stock_location = self.env['stock.location'].sudo().search([('name', '=', '客户')], limit=1)
|
||||||
return customer_location_id
|
return stock_location.id
|
||||||
|
|
||||||
priority = fields.Selection(related='demand_plan_id.priority', string='优先级', store=True)
|
priority = fields.Selection(related='demand_plan_id.priority', string='优先级')
|
||||||
status = fields.Selection([
|
status = fields.Selection([
|
||||||
('10', '草稿'),
|
('10', '草稿'),
|
||||||
('20', '待确认'),
|
('20', '待确认'),
|
||||||
('30', '待工艺设计'),
|
('30', '需求确认'),
|
||||||
('50', '待下达生产'),
|
('50', '待下达生产'),
|
||||||
('60', '已下达'),
|
('60', '已下达'),
|
||||||
('100', '取消'),
|
('100', '取消'),
|
||||||
@@ -34,7 +34,7 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
related='sale_order_id.company_id',
|
related='sale_order_id.company_id',
|
||||||
store=True, index=True, precompute=True)
|
store=True, index=True, precompute=True)
|
||||||
customer_name = fields.Char('客户', related='sale_order_id.customer_name', store=True)
|
customer_name = fields.Char('客户', related='sale_order_id.customer_name')
|
||||||
order_remark = fields.Text(related='sale_order_id.remark',
|
order_remark = fields.Text(related='sale_order_id.remark',
|
||||||
string="订单备注", store=True)
|
string="订单备注", store=True)
|
||||||
glb_url = fields.Char(related='sale_order_line_id.glb_url', string='glb文件地址')
|
glb_url = fields.Char(related='sale_order_line_id.glb_url', string='glb文件地址')
|
||||||
@@ -81,9 +81,8 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
related='product_id.blank_type')
|
related='product_id.blank_type')
|
||||||
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型',
|
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型',
|
||||||
related='product_id.blank_precision')
|
related='product_id.blank_precision')
|
||||||
unit_number = fields.Float('单件用量', digits=(16, 3), related='product_id.unit_number')
|
|
||||||
embryo_long = fields.Char('坯料尺寸(mm)', related='demand_plan_id.embryo_long')
|
embryo_long = fields.Char('坯料尺寸(mm)', related='demand_plan_id.embryo_long')
|
||||||
materials_id = fields.Char('材料', related='demand_plan_id.materials_id', store=True)
|
materials_id = fields.Char('材料', related='demand_plan_id.materials_id')
|
||||||
model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度')
|
model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度')
|
||||||
model_process_parameters_ids = fields.Many2many(related='demand_plan_id.model_process_parameters_ids',
|
model_process_parameters_ids = fields.Many2many(related='demand_plan_id.model_process_parameters_ids',
|
||||||
string='表面工艺', )
|
string='表面工艺', )
|
||||||
@@ -127,12 +126,6 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
string='字段自制类型只读'
|
string='字段自制类型只读'
|
||||||
)
|
)
|
||||||
|
|
||||||
is_processing = fields.Boolean(
|
|
||||||
string='正在处理中',
|
|
||||||
default=False,
|
|
||||||
help='用于防止重复点击按钮'
|
|
||||||
)
|
|
||||||
|
|
||||||
# hide_action_open_mrp_production = fields.Boolean(
|
# hide_action_open_mrp_production = fields.Boolean(
|
||||||
# string='显示待工艺确认按钮',
|
# string='显示待工艺确认按钮',
|
||||||
# compute='_compute_hid_button',
|
# compute='_compute_hid_button',
|
||||||
@@ -176,7 +169,6 @@ 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):
|
||||||
@@ -184,22 +176,15 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
if line_ids:
|
if line_ids:
|
||||||
raise ValidationError(_("计划量不能小于等于0"))
|
raise ValidationError(_("计划量不能小于等于0"))
|
||||||
|
|
||||||
@api.constrains('supply_method')
|
@api.constrains('new_supply_method')
|
||||||
def _check_supply_method(self):
|
def _check_new_supply_method(self):
|
||||||
product_name = []
|
product_name = []
|
||||||
product = []
|
|
||||||
for line in self:
|
for line in self:
|
||||||
if line.supply_method == 'purchase' and line.is_incoming_material:
|
if line.new_supply_method == 'purchase' and line.is_incoming_material:
|
||||||
product_name.append(line.product_id.display_name)
|
product_name.append(line.product_id.display_name)
|
||||||
if line.supply_method == 'automation' and line.manual_quotation:
|
|
||||||
product.append(line.product_id.display_name)
|
|
||||||
|
|
||||||
if product_name:
|
if product_name:
|
||||||
unique_product_names = list(set(product_name))
|
unique_product_names = list(set(product_name))
|
||||||
raise UserError('当前(%s)产品为客供料,不能选择外购' % ','.join(unique_product_names))
|
raise UserError('当前(%s)产品为客供料,不能选择外购' % ','.join(unique_product_names))
|
||||||
if product:
|
|
||||||
unique_product = list(set(product))
|
|
||||||
raise UserError('当前(%s)产品为人工编程,不能选择自动化产线加工' % ','.join(unique_product))
|
|
||||||
|
|
||||||
@api.depends('new_supply_method')
|
@api.depends('new_supply_method')
|
||||||
def _compute_custom_made_type(self):
|
def _compute_custom_made_type(self):
|
||||||
@@ -359,12 +344,9 @@ 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')
|
||||||
production_demand_plan = self.env['sf.production.demand.plan'].sudo().search(
|
if not demand_plan_state:
|
||||||
[('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'
|
||||||
|
|
||||||
@@ -605,7 +587,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()
|
||||||
|
|
||||||
@@ -634,7 +616,7 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
warning_messages = []
|
warning_messages = []
|
||||||
for product, data in product_data.items():
|
for product, data in product_data.items():
|
||||||
if float_compare(data['plan_uom_qty'], data['product_uom_qty'],
|
if float_compare(data['plan_uom_qty'], data['product_uom_qty'],
|
||||||
precision_rounding=product.uom_id.rounding) == 1:
|
precision_rounding=product.uom_id.rounding) == 1:
|
||||||
warning_messages.append(
|
warning_messages.append(
|
||||||
_("您正在下达的产品 %s,计划量%s,需求数量为%s,已超过需求数量") %
|
_("您正在下达的产品 %s,计划量%s,需求数量为%s,已超过需求数量") %
|
||||||
(product.display_name, data['plan_uom_qty'], data['product_uom_qty'])
|
(product.display_name, data['plan_uom_qty'], data['product_uom_qty'])
|
||||||
@@ -658,20 +640,17 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
|
|
||||||
def button_release_plan(self):
|
def button_release_plan(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if self.is_processing:
|
if not self.new_supply_method:
|
||||||
return
|
raise ValidationError(f"供货方式不能为空!")
|
||||||
self.is_processing = True
|
|
||||||
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')
|
||||||
if self.location_id.id == customer_location_id:
|
if self.location_id.id == customer_location_id:
|
||||||
check_overdelivery_allowed = True
|
check_overdelivery_allowed = True
|
||||||
if check_overdelivery_allowed:
|
if check_overdelivery_allowed:
|
||||||
if float_compare(self.plan_uom_qty, self.product_uom_qty,
|
if float_compare(self.plan_uom_qty, self.product_uom_qty,precision_rounding=self.product_id.uom_id.rounding) == 1:
|
||||||
precision_rounding=self.product_id.uom_id.rounding) == 1:
|
|
||||||
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
|
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
|
||||||
elif float_compare(self.plan_uom_qty, self.product_uom_qty,
|
elif float_compare(self.plan_uom_qty, self.product_uom_qty,precision_rounding=self.product_id.uom_id.rounding) == 1:
|
||||||
precision_rounding=self.product_id.uom_id.rounding) == 1:
|
|
||||||
return {
|
return {
|
||||||
'name': _('需求计划'),
|
'name': _('需求计划'),
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
@@ -694,12 +673,23 @@ 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()
|
||||||
|
|
||||||
def mrp_bom_create(self):
|
def mrp_bom_create(self):
|
||||||
|
if self.supply_method in ('automation', 'manual'):
|
||||||
|
line_ids = self.demand_plan_id.line_ids.filtered(
|
||||||
|
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
|
||||||
|
if line_ids:
|
||||||
|
self.bom_id = line_ids[0].bom_id.id
|
||||||
|
return
|
||||||
|
elif self.supply_method == 'outsourcing':
|
||||||
|
line_ids = self.demand_plan_id.line_ids.filtered(
|
||||||
|
lambda p: p.supply_method == 'outsourcing' and p.status == '60')
|
||||||
|
if line_ids:
|
||||||
|
self.bom_id = line_ids[0].bom_id.id
|
||||||
|
return
|
||||||
bom_type = ''
|
bom_type = ''
|
||||||
# 根据供货方式修改成品模板
|
# 根据供货方式修改成品模板
|
||||||
if self.supply_method == 'automation':
|
if self.supply_method == 'automation':
|
||||||
@@ -719,18 +709,6 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
|
|
||||||
# 复制成品模板上的属性
|
# 复制成品模板上的属性
|
||||||
self.product_id.product_tmpl_id.copy_template(product_template_id)
|
self.product_id.product_tmpl_id.copy_template(product_template_id)
|
||||||
if self.supply_method in ('automation', 'manual'):
|
|
||||||
line_ids = self.demand_plan_id.line_ids.filtered(
|
|
||||||
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
|
|
||||||
if line_ids:
|
|
||||||
self.bom_id = line_ids[0].bom_id.id
|
|
||||||
return
|
|
||||||
elif self.supply_method == 'outsourcing':
|
|
||||||
line_ids = self.demand_plan_id.line_ids.filtered(
|
|
||||||
lambda p: p.supply_method == 'outsourcing' and p.status == '60')
|
|
||||||
if line_ids:
|
|
||||||
self.bom_id = line_ids[0].bom_id.id
|
|
||||||
return
|
|
||||||
future_time = datetime.now() + timedelta(hours=8)
|
future_time = datetime.now() + timedelta(hours=8)
|
||||||
# 生成BOM单据编码
|
# 生成BOM单据编码
|
||||||
code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}"
|
code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}"
|
||||||
@@ -910,62 +888,3 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
'demand_plan_line_id': self.id
|
'demand_plan_line_id': self.id
|
||||||
}
|
}
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def button_plan_detail(self):
|
|
||||||
self.ensure_one()
|
|
||||||
purchase_request_ids = self.env['purchase.request'].sudo().search(
|
|
||||||
[('line_ids.demand_plan_line_id', 'in', self.ids)])
|
|
||||||
purchase_order_ids = self.env['purchase.order'].sudo().search(
|
|
||||||
[('order_line.demand_plan_line_id', 'in', self.ids)])
|
|
||||||
picking_ids = self.env['stock.picking'].sudo().search(
|
|
||||||
[('demand_plan_line_ids', 'in', self.ids)])
|
|
||||||
return {
|
|
||||||
'name': _('详情'),
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_model': 'sf.demand.plan.detail.wizard',
|
|
||||||
'target': 'new',
|
|
||||||
'views': [(False, 'form')],
|
|
||||||
'context': {
|
|
||||||
'default_mrp_production_ids': self.mrp_production_ids.ids,
|
|
||||||
'default_purchase_request_ids': purchase_request_ids.ids,
|
|
||||||
'default_standard_purchase_order_ids': purchase_order_ids.filtered(
|
|
||||||
lambda o: o.purchase_type == 'standard'
|
|
||||||
).ids,
|
|
||||||
'default_consignment_purchase_order_ids': purchase_order_ids.filtered(
|
|
||||||
lambda o: o.purchase_type == 'consignment'
|
|
||||||
).ids,
|
|
||||||
'default_outsourcing_purchase_order_ids': purchase_order_ids.filtered(
|
|
||||||
lambda o: o.purchase_type == 'outsourcing'
|
|
||||||
).ids,
|
|
||||||
'default_outside_purchase_order_ids': purchase_order_ids.filtered(
|
|
||||||
lambda o: o.purchase_type == 'outside'
|
|
||||||
).ids,
|
|
||||||
'default_in_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'IN'
|
|
||||||
).ids,
|
|
||||||
'default_dl_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'DL'
|
|
||||||
).ids,
|
|
||||||
'default_int_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'INT'
|
|
||||||
).ids,
|
|
||||||
'default_pc_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'PC'
|
|
||||||
).ids,
|
|
||||||
'default_sfp_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'SFP'
|
|
||||||
).ids,
|
|
||||||
'default_onin_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'OCIN'
|
|
||||||
).ids,
|
|
||||||
'default_ocout_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'OCOUT'
|
|
||||||
).ids,
|
|
||||||
'default_out_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'OUT'
|
|
||||||
).ids,
|
|
||||||
'default_res_stock_picking_ids': picking_ids.filtered(
|
|
||||||
lambda o: o.picking_type_sequence_code == 'RES'
|
|
||||||
).ids,
|
|
||||||
}}
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class StockMove(models.Model):
|
|
||||||
_inherit = 'stock.move'
|
|
||||||
|
|
||||||
demand_plan_line_ids = fields.Many2many(comodel_name="sf.production.demand.plan",
|
|
||||||
string="需求计划明细", compute='_compute_demand_plan_line_ids', store=True)
|
|
||||||
|
|
||||||
@api.depends('origin', 'move_orig_ids')
|
|
||||||
def _compute_demand_plan_line_ids(self):
|
|
||||||
sorted_records = self.sorted(key=lambda r: -r.id)
|
|
||||||
for line in sorted_records:
|
|
||||||
origin = [origin.replace(' ', '') for origin in line.origin.split(',')]
|
|
||||||
if line.created_purchase_request_line_id:
|
|
||||||
line.demand_plan_line_ids = line.created_purchase_request_line_id.demand_plan_line_id.ids
|
|
||||||
elif line.origin and 'MO' in line.origin:
|
|
||||||
mp_ids = self.env['mrp.production'].sudo().search([('name', '=', origin[0])])
|
|
||||||
line.demand_plan_line_ids = mp_ids.demand_plan_line_id.ids if mp_ids else []
|
|
||||||
elif line.origin and 'P' in line.origin:
|
|
||||||
purchase_order_ids = self.env['purchase.order'].sudo().search([('name', '=', origin[0])])
|
|
||||||
if purchase_order_ids.order_line:
|
|
||||||
line.demand_plan_line_ids = purchase_order_ids.order_line.demand_plan_line_id.ids
|
|
||||||
elif line.move_orig_ids:
|
|
||||||
demand_plan_lines = self.env['sf.production.demand.plan']
|
|
||||||
for move_orig in line.move_orig_ids:
|
|
||||||
demand_plan_lines |= move_orig.demand_plan_line_ids
|
|
||||||
line.demand_plan_line_ids = demand_plan_lines.ids
|
|
||||||
else:
|
|
||||||
line.demand_plan_line_ids = []
|
|
||||||
|
|
||||||
if not line.demand_plan_line_ids and self.env.context.get('demand_plan_line_id'):
|
|
||||||
plan_ids = self.env.context['demand_plan_line_id']
|
|
||||||
line.demand_plan_line_ids = [plan_ids]
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
from odoo import fields, api, models, _
|
|
||||||
|
|
||||||
|
|
||||||
class StockPicking(models.Model):
|
|
||||||
_inherit = "stock.picking"
|
|
||||||
|
|
||||||
demand_plan_line_ids = fields.Many2many(comodel_name="sf.production.demand.plan",
|
|
||||||
string="需求计划明细", compute='_compute_demand_plan_line_ids', store=True)
|
|
||||||
|
|
||||||
@api.depends('move_ids_without_package')
|
|
||||||
def _compute_demand_plan_line_ids(self):
|
|
||||||
for line in self:
|
|
||||||
demand_plan_lines = self.env['sf.production.demand.plan']
|
|
||||||
if line.move_ids_without_package and line.move_ids_without_package.demand_plan_line_ids:
|
|
||||||
demand_plan_lines |= line.move_ids_without_package.demand_plan_line_ids
|
|
||||||
line.demand_plan_line_ids = demand_plan_lines.ids
|
|
||||||
@@ -13,7 +13,4 @@ access_stock_route_group,stock.route.group,model_stock_route_group,base.group_us
|
|||||||
access_stock_route_group_dispatch,stock.route.group.dispatch,model_stock_route_group,sf_base.group_plan_dispatch,1,1,0,0
|
access_stock_route_group_dispatch,stock.route.group.dispatch,model_stock_route_group,sf_base.group_plan_dispatch,1,1,0,0
|
||||||
|
|
||||||
access_sf_release_plan_wizard,sf.release.plan.wizard,model_sf_release_plan_wizard,base.group_user,1,0,0,0
|
access_sf_release_plan_wizard,sf.release.plan.wizard,model_sf_release_plan_wizard,base.group_user,1,0,0,0
|
||||||
access_sf_release_plan_wizard_for_dispatch,sf.release.plan.wizard for dispatch,model_sf_release_plan_wizard,sf_base.group_plan_dispatch,1,1,1,1
|
access_sf_release_plan_wizard_for_dispatch,sf.release.plan.wizard for dispatch,model_sf_release_plan_wizard,sf_base.group_plan_dispatch,1,1,1,1
|
||||||
|
|
||||||
access_sf_demand_plan_detail_wizard,sf.demand.plan.detail.wizard,model_sf_demand_plan_detail_wizard,base.group_user,1,0,0,0
|
|
||||||
access_sf_demand_plan_detail_wizard_for_dispatch,sf.demand.plan.detail.wizard for dispatch,model_sf_demand_plan_detail_wizard,sf_base.group_plan_dispatch,1,1,1,1
|
|
||||||
|
@@ -1,58 +0,0 @@
|
|||||||
/** @odoo-module **/
|
|
||||||
|
|
||||||
import { registry } from "@web/core/registry";
|
|
||||||
import { ListRenderer } from "@web/views/list/list_renderer";
|
|
||||||
import { useService } from "@web/core/utils/hooks";
|
|
||||||
import { useEffect } from "@odoo/owl";
|
|
||||||
|
|
||||||
export class CustomDemandPlanListRenderer extends ListRenderer {
|
|
||||||
setup() {
|
|
||||||
super.setup();
|
|
||||||
this.orm = useService("orm");
|
|
||||||
this.notification = useService("notification");
|
|
||||||
console.log('setup', this.props);
|
|
||||||
|
|
||||||
// 监听selection属性的变化
|
|
||||||
useEffect(() => {
|
|
||||||
this.updateButtonState();
|
|
||||||
}, () => [this.props.list.selection]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新按钮状态
|
|
||||||
*/
|
|
||||||
async updateButtonState() {
|
|
||||||
const selectedRecords = this.props.list.selection;
|
|
||||||
const isStatus30 = selectedRecords.some(record => record.data.status != "30");
|
|
||||||
const button = $(this.__owl__.parent.bdom.parentEl).find('button[name="button_batch_release_plan"]');
|
|
||||||
if (isStatus30) {
|
|
||||||
// 禁用按钮
|
|
||||||
button.attr('disabled', true);
|
|
||||||
} else {
|
|
||||||
button.attr('disabled', false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 使用setTimeout延迟注册,避免在模块加载时立即执行
|
|
||||||
setTimeout(() => {
|
|
||||||
const registerCustomRenderer = () => {
|
|
||||||
try {
|
|
||||||
const listView = registry.category("views").get("list");
|
|
||||||
if (listView) {
|
|
||||||
registry.category("views").add("custom_demand_plan_list", {
|
|
||||||
...listView,
|
|
||||||
Renderer: CustomDemandPlanListRenderer,
|
|
||||||
});
|
|
||||||
console.log("Custom demand plan list renderer registered successfully");
|
|
||||||
} else {
|
|
||||||
console.warn("List view not found, retrying...");
|
|
||||||
// 如果还没找到,再等一段时间
|
|
||||||
setTimeout(registerCustomRenderer, 1000);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error registering custom renderer:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
registerCustomRenderer();
|
|
||||||
}, 1000);
|
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*.demand_plan_tree th[data-name=planned_start_date] + th::before{*/
|
th[data-name=processing_time] + th::before{
|
||||||
/* content: '待执行单据';*/
|
content: '待执行单据';
|
||||||
/* line-height: 38px;*/
|
line-height: 38px;
|
||||||
/*}*/
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
<field name="model">sf.production.demand.plan</field>
|
<field name="model">sf.production.demand.plan</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="需求计划" default_order="sequence desc,id desc" editable="bottom"
|
<tree string="需求计划" default_order="sequence desc,id desc" editable="bottom"
|
||||||
class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false"
|
class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false">
|
||||||
js_class="custom_demand_plan_list">
|
|
||||||
<header>
|
<header>
|
||||||
<button string="打印" name="button_action_print" type="object"
|
<button string="打印" name="button_action_print" type="object"
|
||||||
class="btn-primary"/>
|
class="btn-primary"/>
|
||||||
@@ -23,7 +22,6 @@
|
|||||||
<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"/>
|
||||||
@@ -33,14 +31,13 @@
|
|||||||
<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" optional="hide"/>
|
<field name="inventory_quantity_auto_apply"/>
|
||||||
<field name="qty_delivered" optional="hide"/>
|
<field name="qty_delivered"/>
|
||||||
<field name="qty_to_deliver" optional="hide"/>
|
<field name="qty_to_deliver"/>
|
||||||
<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"/>
|
||||||
<field name="embryo_long"/>
|
<field name="embryo_long"/>
|
||||||
<field name="unit_number" optional="hide"/>
|
|
||||||
<field name="materials_id"/>
|
<field name="materials_id"/>
|
||||||
<field name="model_machining_precision"/>
|
<field name="model_machining_precision"/>
|
||||||
<field name="model_process_parameters_ids" widget="many2many_tags"/>
|
<field name="model_process_parameters_ids" widget="many2many_tags"/>
|
||||||
@@ -92,10 +89,6 @@
|
|||||||
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
<button name="edit_button" type="object" string="拆分" class="btn-primary"/>
|
<button name="edit_button" type="object" string="拆分" class="btn-primary"/>
|
||||||
<button string="详情" name="button_plan_detail" type="object"
|
|
||||||
class="btn-primary"
|
|
||||||
attrs="{'invisible': [('status', 'not in', ('50','60'))]}"
|
|
||||||
/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -14,15 +14,12 @@
|
|||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="demand_plan_number"/>
|
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="part_name"/>
|
<field name="part_name"/>
|
||||||
<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"/>
|
||||||
@@ -39,46 +36,12 @@
|
|||||||
<field name="inventory_quantity_auto_apply"/>
|
<field name="inventory_quantity_auto_apply"/>
|
||||||
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
|
<field name="priority" attrs="{'readonly': [('state', 'in', ('40','50'))]}"/>
|
||||||
<field name="overdelivery_allowed"/>
|
<field name="overdelivery_allowed"/>
|
||||||
<field name="origin"/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="计划">
|
<page string="计划">
|
||||||
<field name="line_ids" attrs="{'invisible': [('state', 'in', ('40','50'))]}">
|
<field name="line_ids" attrs="{'readonly': [('state', 'in', ('40','50'))]}">
|
||||||
<tree editable="bottom" create="false" delete="false">
|
<tree editable="bottom" delete="false">
|
||||||
<field name="status"/>
|
|
||||||
<field name="readonly_custom_made_type" invisible="1"/>
|
|
||||||
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
|
||||||
<field name="custom_made_type"
|
|
||||||
attrs="{
|
|
||||||
'readonly': ['|', '|', ('new_supply_method', '!=', 'custom_made'), ('status', '!=', '30'), ('readonly_custom_made_type', '=', True)],
|
|
||||||
'required': [('new_supply_method', '=', 'custom_made')]}"/>
|
|
||||||
<field name="route_ids" widget="many2many_tags" optional="hide"/>
|
|
||||||
<field name="location_id" optional="hide"/>
|
|
||||||
<field name="bom_id" optional="hide"/>
|
|
||||||
<field name="processing_time" optional="hide"/>
|
|
||||||
<field name="plan_uom_qty" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
|
||||||
<field name="blank_arrival_date"/>
|
|
||||||
<field name="finished_product_arrival_date"/>
|
|
||||||
<field name="planned_start_date"/>
|
|
||||||
<field name="actual_start_date"/>
|
|
||||||
<field name="actual_end_date"/>
|
|
||||||
<field name="plan_remark"/>
|
|
||||||
<field name="procurement_reason"/>
|
|
||||||
<field name="write_date" string="更新时间"/>
|
|
||||||
<field name="hide_release_production_order" invisible="1"/>
|
|
||||||
<button string="下达计划" name="button_release_plan" type="object"
|
|
||||||
class="btn-primary"
|
|
||||||
attrs="{'invisible': [('status', 'in', ('50','60','100'))]}"
|
|
||||||
/>
|
|
||||||
<button name="button_release_production" type="object" string="下发生产"
|
|
||||||
class="btn-primary"
|
|
||||||
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
|
||||||
/>
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
<field name="line_ids" attrs="{'invisible': [('state', 'not in', ('40','50'))]}">
|
|
||||||
<tree editable="bottom">
|
|
||||||
<field name="status"/>
|
<field name="status"/>
|
||||||
<field name="readonly_custom_made_type" invisible="1"/>
|
<field name="readonly_custom_made_type" invisible="1"/>
|
||||||
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
<field name="new_supply_method" attrs="{'readonly': [('status', '!=', '30')]}"/>
|
||||||
@@ -89,7 +52,6 @@
|
|||||||
<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" readonly="1" options="{'no_create': True}"/>
|
<field name="bom_id" optional="hide" readonly="1" options="{'no_create': True}"/>
|
||||||
<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"/>
|
||||||
<field name="finished_product_arrival_date"/>
|
<field name="finished_product_arrival_date"/>
|
||||||
@@ -108,10 +70,10 @@
|
|||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
|
||||||
/>
|
/>
|
||||||
<button string="详情" name="button_plan_detail" type="object"
|
<button name="button_delete" type="object" string="删除"
|
||||||
class="btn-primary"
|
class="btn-primary"
|
||||||
attrs="{'invisible': [('status', 'not in', ('50','60'))]}"
|
attrs="{'invisible': [('status', 'not in', ('10','20','30'))]}"
|
||||||
/>
|
confirm='是否确认删除?'/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
from . import sf_demand_plan_print_wizard
|
from . import sf_demand_plan_print_wizard
|
||||||
from . import sf_release_plan_wizard
|
from . import sf_release_plan_wizard
|
||||||
from . import sf_demand_plan_detail_wizard
|
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import logging
|
|
||||||
from odoo import models, fields, api, _
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class SfDemandPlanDetailWizard(models.TransientModel):
|
|
||||||
_name = 'sf.demand.plan.detail.wizard'
|
|
||||||
_description = u'需求计划详情向导'
|
|
||||||
|
|
||||||
mrp_production_ids = fields.Many2many('mrp.production', string='关联制造订单', readonly=True)
|
|
||||||
purchase_request_ids = fields.Many2many('purchase.request', string='关联采购申请', readonly=True)
|
|
||||||
standard_purchase_order_ids = fields.Many2many('purchase.order', string='关联标准采购',
|
|
||||||
relation='standard_purchase_order_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='purchase_order_id',
|
|
||||||
readonly=True)
|
|
||||||
consignment_purchase_order_ids = fields.Many2many('purchase.order', string='关联工序外协采购',
|
|
||||||
relation='consignment_purchase_order_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='purchase_order_id',
|
|
||||||
readonly=True)
|
|
||||||
outsourcing_purchase_order_ids = fields.Many2many('purchase.order', string='关联委外加工采购',
|
|
||||||
relation='outsourcing_purchase_order_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='purchase_order_id',
|
|
||||||
readonly=True)
|
|
||||||
outside_purchase_order_ids = fields.Many2many('purchase.order', string='关联外购订单采购',
|
|
||||||
relation='outside_purchase_order_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='purchase_order_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
in_stock_picking_ids = fields.Many2many('stock.picking', string='关联收料入库调拨单',
|
|
||||||
relation='in_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
dl_stock_picking_ids = fields.Many2many('stock.picking', string='关联客供料入库调拨单',
|
|
||||||
relation='dl_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
int_stock_picking_ids = fields.Many2many('stock.picking', string='关联内部调拨',
|
|
||||||
relation='int_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
pc_stock_picking_ids = fields.Many2many('stock.picking', string='关联生产发料调拨单',
|
|
||||||
relation='pc_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
sfp_stock_picking_ids = fields.Many2many('stock.picking', string='关联生产入库调拨单',
|
|
||||||
relation='sfp_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
onin_stock_picking_ids = fields.Many2many('stock.picking', string='关联外协入库调拨单',
|
|
||||||
relation='onin_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
ocout_stock_picking_ids = fields.Many2many('stock.picking', string='关联外协出库调拨单',
|
|
||||||
relation='ocout_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
out_stock_picking_ids = fields.Many2many('stock.picking', string='关联发料出库调拨单',
|
|
||||||
relation='out_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
res_stock_picking_ids = fields.Many2many('stock.picking', string='关联委外发料调拨单',
|
|
||||||
relation='res_stock_picking_rel',
|
|
||||||
column1='plan_detail_wizard_id', column2='stock_picking_id',
|
|
||||||
readonly=True)
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<odoo>
|
|
||||||
<record id="action_plan_detail_form" model="ir.ui.view">
|
|
||||||
<field name="name">sf.demand.plan.detail.wizard.form</field>
|
|
||||||
<field name="model">sf.demand.plan.detail.wizard</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form string="详情">
|
|
||||||
<notebook>
|
|
||||||
<page string="采购申请" attrs="{'invisible': [('purchase_request_ids', '=', [])]}">
|
|
||||||
<field name="purchase_request_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="制造订单" attrs="{'invisible': [('mrp_production_ids', '=', [])]}">
|
|
||||||
<field name="mrp_production_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="标准采购" attrs="{'invisible': [('standard_purchase_order_ids', '=', [])]}">
|
|
||||||
<field name="standard_purchase_order_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="工序外协采购" attrs="{'invisible': [('consignment_purchase_order_ids', '=', [])]}">
|
|
||||||
<field name="consignment_purchase_order_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="委外加工采购" attrs="{'invisible': [('outsourcing_purchase_order_ids', '=', [])]}">
|
|
||||||
<field name="outsourcing_purchase_order_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="外购订单采购" attrs="{'invisible': [('outside_purchase_order_ids', '=', [])]}">
|
|
||||||
<field name="outside_purchase_order_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="收料入库" attrs="{'invisible': [('in_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="in_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="客供料入库" attrs="{'invisible': [('dl_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="dl_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="内部调拨" attrs="{'invisible': [('int_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="int_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="生产发料" attrs="{'invisible': [('pc_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="pc_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="生产入库" attrs="{'invisible': [('sfp_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="sfp_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="外协入库" attrs="{'invisible': [('onin_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="onin_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="外协出库" attrs="{'invisible': [('ocout_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="ocout_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="发料出库" attrs="{'invisible': [('out_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="out_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
<page string="委外发料" attrs="{'invisible': [('res_stock_picking_ids', '=', [])]}">
|
|
||||||
<field name="res_stock_picking_ids" widget="many2many"/>
|
|
||||||
</page>
|
|
||||||
</notebook>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
@@ -5,7 +5,7 @@ from odoo import models, fields, api, _
|
|||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SfDemandPlanPrintWizard(models.Model):
|
class SfDemandPlanPrintWizard(models.TransientModel):
|
||||||
_name = 'sf.demand.plan.print.wizard'
|
_name = 'sf.demand.plan.print.wizard'
|
||||||
_description = u'打印向导'
|
_description = u'打印向导'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from werkzeug.exceptions import InternalServerError
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -18,10 +17,4 @@ class SfReleasePlanWizard(models.TransientModel):
|
|||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.demand_plan_line_id:
|
if self.demand_plan_line_id:
|
||||||
for demand_plan_line_id in self.demand_plan_line_id:
|
for demand_plan_line_id in self.demand_plan_line_id:
|
||||||
try:
|
demand_plan_line_id.action_confirm()
|
||||||
demand_plan_line_id.action_confirm()
|
|
||||||
except Exception as e:
|
|
||||||
self.env.cr.rollback()
|
|
||||||
demand_plan_line_id.write({'is_processing': False})
|
|
||||||
self.env.cr.commit()
|
|
||||||
raise InternalServerError('操作失败', e)
|
|
||||||
|
|||||||
@@ -217,8 +217,7 @@ class StockRule(models.Model):
|
|||||||
'''
|
'''
|
||||||
创建制造订单时生成序列号
|
创建制造订单时生成序列号
|
||||||
'''
|
'''
|
||||||
if production.product_id.tracking != "none":
|
production.action_generate_serial()
|
||||||
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
|
||||||
@@ -443,7 +442,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 != "none":
|
if product.tracking == "serial":
|
||||||
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')
|
||||||
@@ -454,9 +453,7 @@ 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]
|
||||||
else:
|
return "%s-%03d" % (product.name, 1)
|
||||||
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