处理代发货下发

This commit is contained in:
hujiaying
2024-08-27 17:24:04 +08:00
parent bf1271a742
commit 1e172cb4e3
9 changed files with 143 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import stock_picking

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
import json
import requests
from odoo import models, fields, api
from odoo.exceptions import UserError
import logging
_logger = logging.getLogger(__name__)
class StockPicking(models.Model):
_inherit = 'stock.picking'
# 重写验证下发发货到bfm
def button_validate(self):
info = super(StockPicking, self).button_validate()
if self.picking_type_id.code == 'outgoing':
self.send_to_bfm()
return info
def send_to_bfm(self):
# 下发发货到bfm
config = self.env['res.config.settings'].get_values()
json1 = {
'params': {
'name': self.origin,
'send_no': self.name,
'qty_done': self.move_line_ids.qty_done,
},
}
url1 = config['bfm_url_new'] + '/api/stock/deliver_goods'
r = requests.post(url1, json=json1, data=None)
if r.status_code == 200:
result = json.loads(r.json()['result'])
if result['code'] != 200:
raise UserError(result['message'] or '工厂发货下发bfm失败')
else:
raise UserError('工厂发货下发bfm失败')