处理代发货下发

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

4
sf_stock/__init__.py Normal file
View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import models

36
sf_stock/__manifest__.py Normal file
View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
{
'name': "sf_stock",
'summary': """
Short (1 phrase/line) summary of the module's purpose, used as
subtitle on modules listing or apps.openerp.com""",
'description': """
Long description of module's purpose
""",
'author': "My Company",
'website': "https://www.yourcompany.com",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'Uncategorized',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': ['sf_sale', 'stock'],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/stock_picking.xml',
],
# only loaded in demonstration mode
'demo': [
'demo/demo.xml',
],
'installable': True,
'application': True,
}

View File

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

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# from odoo import http
# class SfStock(http.Controller):
# @http.route('/sf_stock/sf_stock', auth='public')
# def index(self, **kw):
# return "Hello, world"
# @http.route('/sf_stock/sf_stock/objects', auth='public')
# def list(self, **kw):
# return http.request.render('sf_stock.listing', {
# 'root': '/sf_stock/sf_stock',
# 'objects': http.request.env['sf_stock.sf_stock'].search([]),
# })
# @http.route('/sf_stock/sf_stock/objects/<model("sf_stock.sf_stock"):obj>', auth='public')
# def object(self, obj, **kw):
# return http.request.render('sf_stock.object', {
# 'object': obj
# })

30
sf_stock/demo/demo.xml Normal file
View File

@@ -0,0 +1,30 @@
<odoo>
<data>
<!--
<record id="object0" model="sf_stock.sf_stock">
<field name="name">Object 0</field>
<field name="value">0</field>
</record>
<record id="object1" model="sf_stock.sf_stock">
<field name="name">Object 1</field>
<field name="value">10</field>
</record>
<record id="object2" model="sf_stock.sf_stock">
<field name="name">Object 2</field>
<field name="value">20</field>
</record>
<record id="object3" model="sf_stock.sf_stock">
<field name="name">Object 3</field>
<field name="value">30</field>
</record>
<record id="object4" model="sf_stock.sf_stock">
<field name="name">Object 4</field>
<field name="value">40</field>
</record>
-->
</data>
</odoo>

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失败')

View File

@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_stock_sf_stock,sf_stock.sf_stock,model_sf_stock_sf_stock,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sf_stock_sf_stock sf_stock.sf_stock model_sf_stock_sf_stock base.group_user 1 1 1 1

View File

@@ -0,0 +1,5 @@
<odoo>
<data>
</data>
</odoo>