33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
from odoo import models, fields, api, _
|
|
|
|
|
|
class ReSaleOrder(models.Model):
|
|
_inherit = 'sale.order'
|
|
|
|
mrp_production_ids = fields.Many2many(
|
|
'mrp.production',
|
|
compute='_compute_mrp_production_ids',
|
|
string='与此销售订单相关联的制造订单',
|
|
groups='mrp.group_mrp_user', store=True)
|
|
|
|
def sale_order_create_line(self, product, item):
|
|
ret = super(ReSaleOrder, self).sale_order_create_line(product, item)
|
|
vals = {
|
|
'sale_order_id': ret.order_id.id,
|
|
'sale_order_line_id': ret.id,
|
|
}
|
|
demand_plan_info = self.env['sf.demand.plan'].sudo().create(vals)
|
|
vals.update({'demand_plan_id': demand_plan_info.id})
|
|
demand_plan = self.env['sf.production.demand.plan'].sudo().create(vals)
|
|
demand_plan_info.write({'line_ids': demand_plan.id})
|
|
if demand_plan.product_id.machining_drawings_name:
|
|
filename_url = demand_plan.product_id.machining_drawings_name.rsplit('.', 1)[0]
|
|
wizard_vals = {
|
|
'demand_plan_id': demand_plan.id,
|
|
'model_id': demand_plan.model_id,
|
|
'filename_url': filename_url,
|
|
'type': '1',
|
|
}
|
|
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
|
|
return ret
|