销售订单添加合同字段,销售订单form页面新增合同page页,优化/api/bfm_process_order/list接口添加合同信息处理。
This commit is contained in:
@@ -45,6 +45,8 @@ class JikimoSaleRoutePicking(Sf_Bf_Connect):
|
||||
product.product_tmpl_id.is_customer_provided = True if item['embryo_redundancy_id'] else False
|
||||
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||
i += 1
|
||||
if kw.get('contract_file_name') and kw.get('contract_file'):
|
||||
order_id.create_sale_documents(kw.get('contract_file_name'), kw.get('contract_file'))
|
||||
res['factory_order_no'] = order_id.name
|
||||
order_id.confirm_to_supply_method()
|
||||
except Exception as e:
|
||||
|
||||
@@ -190,7 +190,29 @@ class SaleOrder(models.Model):
|
||||
'target': 'new',
|
||||
'res_id': wizard.id,
|
||||
}
|
||||
def create_sale_documents(self, contract_file_name, contract_file):
|
||||
# 创建ir.attachment记录
|
||||
attachment = self.env['ir.attachment'].sudo().create({
|
||||
'name': contract_file_name,
|
||||
'type': 'binary',
|
||||
'datas': contract_file,
|
||||
'res_model': 'sale.order',
|
||||
})
|
||||
|
||||
# 获取默认的文档文件夹
|
||||
workspace = self.env.ref('sf_sale.documents_sales_contracts_folder_1').id
|
||||
|
||||
# 创建 documents.document 记录
|
||||
document = self.env['documents.document'].sudo().create({
|
||||
'name': contract_file_name,
|
||||
'attachment_id': attachment.id,
|
||||
'folder_id': workspace,
|
||||
'res_model': 'sale.order'
|
||||
})
|
||||
|
||||
self.write({
|
||||
'contract_document_id': document.id
|
||||
})
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = 'sale.order.line'
|
||||
|
||||
@@ -125,12 +125,16 @@ class ReworkWizard(models.TransientModel):
|
||||
# 1、单独返工CNC工单则不解绑托盘RFID,如单独返工装夹预调工单,则自动解绑托盘RFID;
|
||||
# 2、返工CNC工单和装夹预调工单则自动解绑RFID
|
||||
clamp_workorder_ids = rework_workorder_ids.filtered(lambda rp: rp.routing_type == '装夹预调')
|
||||
|
||||
vals_list = [{
|
||||
'id': order.id,
|
||||
'rfid_code_old': order.rfid_code,
|
||||
'rfid_code': False
|
||||
} for order in rework_workorder_ids]
|
||||
rework_workorder_ids.write(vals_list)
|
||||
if clamp_workorder_ids:
|
||||
for clamp_workorder_id in clamp_workorder_ids:
|
||||
rfid_code = clamp_workorder_id.rfid_code
|
||||
clamp_workorder_id.write({'rfid_code_old': rfid_code, 'rfid_code': False})
|
||||
self.production_id.workorder_ids.filtered(lambda wk: (
|
||||
wk.routing_type != '装夹预调' and
|
||||
wk.processing_panel == clamp_workorder_id.processing_panel)).write({'rfid_code': None})
|
||||
# 返工工单状态设置为【返工】
|
||||
rework_workorder_ids.write({'state': 'rework'})
|
||||
|
||||
Reference in New Issue
Block a user