销售订单添加合同字段,销售订单form页面新增合同page页,优化/api/bfm_process_order/list接口添加合同信息处理。

This commit is contained in:
yuxianghui
2025-06-04 11:31:28 +08:00
parent 4a09148b53
commit 573b50da68
7 changed files with 65 additions and 4 deletions

View File

@@ -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:

View File

@@ -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'

View File

@@ -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'})

View File

@@ -17,6 +17,7 @@
'wizard/sale_order_wizard_views.xml',
'wizard/purchase_order_wizard_views.xml',
'data/cron_data.xml',
'data/documents_data.xml',
'views/sale_team.xml',
'views/sale_order_view.xml',
'views/res_partner_view.xml',

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- 创建采购合同文件夹 -->
<record id="documents_sales_contracts_folder" model="documents.folder">
<field name="name">销售合同</field>
<field name="description">存放销售合同相关文件</field>
<field name="sequence">8</field>
</record>
<record id="documents_sales_contracts_folder_1" model="documents.folder">
<field name="name">下单凭证</field>
<field name="parent_folder_id" ref="documents_sales_contracts_folder"/>
</record>
</data>
</odoo>

View File

@@ -63,6 +63,10 @@ class ReSaleOrder(models.Model):
model_display_version = fields.Char('模型展示版本', default="v1")
contract_document_id = fields.Many2one('documents.document', string='合同文件')
contract_file = fields.Binary(related='contract_document_id.datas', string='合同文件内容')
contract_file_name = fields.Char(related='contract_document_id.attachment_id.name', string='文件名')
# 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
deadline_of_delivery, payments_way, pay_way, order_number, state='sale',

View File

@@ -198,7 +198,20 @@
</div>
<field name="date_order" attrs="{'invisible': [('state', 'in', ['done', 'cancel'])], 'required': True}" nolabel="1"/>
</xpath>
<xpath expr="//notebook/page[@name='customer_signature']" position="after">
<page string="合同" name="contract_documents"
attrs="{'invisible': [('contract_document_id', '=', False)]}">
<group>
<group>
<field name="contract_document_id" invisible="1"/>
<field name="contract_file_name" invisible="1"/>
<field name="contract_file"
widget="adaptive_viewer"
filename="contract_file_name"/>
</group>
</group>
</page>
</xpath>
</field>
</record>