移除销售订单供货方式确认

This commit is contained in:
guanhuan
2025-06-25 14:22:27 +08:00
parent 9f00fddc09
commit d046fd5298
4 changed files with 72 additions and 0 deletions

View File

@@ -10,6 +10,16 @@ class ReSaleOrder(models.Model):
string='与此销售订单相关联的制造订单',
groups='mrp.group_mrp_user', store=True)
demand_plan_count = fields.Integer(
"需求计划生成计数",
compute='_compute_demand_plan_count',
)
def _compute_demand_plan_count(self):
for line in self:
demand_plan = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', line.id)])
line.demand_plan_count = len(demand_plan)
def sale_order_create_line(self, product, item):
ret = super(ReSaleOrder, self).sale_order_create_line(product, item)
vals = {
@@ -30,3 +40,29 @@ class ReSaleOrder(models.Model):
}
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
return ret
def confirm_to_supply_method(self):
self.state = 'sale'
for line in self.order_line:
if line.product_id.auto_machining:
line.supply_method = 'automation'
def action_view_demand_plan(self):
self.ensure_one()
demand_plan_ids = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.id)]).ids
action = {
'res_model': 'sf.production.demand.plan',
'type': 'ir.actions.act_window',
}
if len(demand_plan_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': demand_plan_ids[0],
})
else:
action.update({
'name': _("需求计划"),
'domain': [('id', 'in', demand_plan_ids)],
'view_mode': 'tree',
})
return action

View File

@@ -192,3 +192,9 @@ class SfDemandPlan(models.Model):
if not line.sale_order_line_id:
line.sale_order_line_id = self.sale_order_line_id
return res
def name_get(self):
result = []
for plan in self:
result.append((plan.id, plan.sale_order_id.name))
return result