增加快速订单逻辑,修改报价筛选逻辑
This commit is contained in:
@@ -121,3 +121,18 @@ def _create_or_update_stock_rule(env, rule_data):
|
|||||||
# 如果不存在,创建新记录
|
# 如果不存在,创建新记录
|
||||||
env['stock.rule'].create(rule_data)
|
env['stock.rule'].create(rule_data)
|
||||||
|
|
||||||
|
def _data_uninstall(cr, registry):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
warehouse = env['stock.warehouse'].search([('company_id', '=', env.company.id)], limit=1)
|
||||||
|
product_route_id = warehouse.pbm_route_id
|
||||||
|
resupply_route_id = warehouse.subcontracting_route_id
|
||||||
|
mto_route_id = env.ref('stock.route_warehouse0_mto')
|
||||||
|
# Fail unlink means that the route is used somewhere (e.g. route_id on stock.rule). In this case
|
||||||
|
# we don't try to do anything.
|
||||||
|
try:
|
||||||
|
with env.cr.savepoint():
|
||||||
|
env['stock.rule'].search([('name', 'in', ('WH: 原料存货区 → 制造前', 'WH: 坯料存货区 → 制造前', 'WH: 制造后 → 坯料存货区', 'WH: 制造后 → 成品存货区')), ('route_id', '=', product_route_id.id)]).unlink()
|
||||||
|
env['stock.rule'].search([('name', 'in', ('WH: 原料存货区 → 外包位置 (MTO)', 'WH: 坯料存货区 → 外包位置 (MTO)')), ('route_id', '=', mto_route_id.id)]).unlink()
|
||||||
|
env['stock.rule'].search([('name', '=', 'WH: 坯料存货区 → 外包位置'), ('route_id', '=', resupply_route_id.id)]).unlink()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
# ],
|
# ],
|
||||||
},
|
},
|
||||||
'post_init_hook': '_data_install',
|
'post_init_hook': '_data_install',
|
||||||
|
'uninstall_hook': '_data_uninstall',
|
||||||
'application': True,
|
'application': True,
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ class JikimoSaleRoutePicking(Sf_Bf_Connect):
|
|||||||
kw['delivery_end_date'], kw['payments_way'], kw['pay_way'], state='draft')
|
kw['delivery_end_date'], kw['payments_way'], kw['pay_way'], state='draft')
|
||||||
i = 1
|
i = 1
|
||||||
# 给sale_order的default_code字段赋值
|
# 给sale_order的default_code字段赋值
|
||||||
aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
# aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
||||||
_logger.info('get_bfm_process_or===================================:%s' % order_id.name)
|
# _logger.info('get_bfm_process_or===================================:%s' % order_id.name)
|
||||||
aa.default_code = kw['order_number']
|
order_id.default_code = kw['order_number']
|
||||||
if kw.get('logistics_way'):
|
if kw.get('logistics_way'):
|
||||||
aa.logistics_way = kw['logistics_way']
|
order_id.logistics_way = kw['logistics_way']
|
||||||
_logger.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code)
|
_logger.info('get_bfm_process_order_listaaaaaaaaaaaaaaaaaaaaaaaaaaaa================:%s' % aa.default_code)
|
||||||
for item in bfm_process_order_list:
|
for item in bfm_process_order_list:
|
||||||
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import base64
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class QuickEasyOrder(models.Model):
|
||||||
|
_inherit = 'quick.easy.order'
|
||||||
|
|
||||||
|
def distribute_to_factory(self, obj):
|
||||||
|
"""
|
||||||
|
多供货方式,重写派单到工厂
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
_logger.info('---------派单到工厂-------')
|
||||||
|
res = {'bfm_process_order_list': []}
|
||||||
|
for item in obj:
|
||||||
|
attachment = item.upload_model_file[0]
|
||||||
|
base64_data = base64.b64encode(attachment.datas)
|
||||||
|
base64_datas = base64_data.decode('utf-8')
|
||||||
|
barcode = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
|
# logging.info('model_file-size: %s' % len(item.model_file))
|
||||||
|
res['bfm_process_order_list'].append({
|
||||||
|
'model_long': item.model_length,
|
||||||
|
'model_width': item.model_width,
|
||||||
|
'model_height': item.model_height,
|
||||||
|
'model_volume': item.model_volume,
|
||||||
|
'model_machining_precision': item.machining_precision,
|
||||||
|
'model_name': attachment.name,
|
||||||
|
'model_data': base64_datas,
|
||||||
|
'model_file': base64.b64encode(item.model_file).decode('utf-8'),
|
||||||
|
'texture_code': item.material_id.materials_no,
|
||||||
|
'texture_type_code': item.material_model_id.materials_no,
|
||||||
|
# 'surface_process_code': self.env['jikimo.surface.process']._json_surface_process_code(item),
|
||||||
|
'process_parameters_code': self.env[
|
||||||
|
'sf.production.process.parameter']._json_production_process_item_code(
|
||||||
|
item),
|
||||||
|
'price': item.price,
|
||||||
|
'number': item.quantity,
|
||||||
|
'total_amount': item.price,
|
||||||
|
'remark': '',
|
||||||
|
'manual_quotation': True,
|
||||||
|
'barcode': barcode,
|
||||||
|
'part_number': item.part_drawing_number,
|
||||||
|
'machining_drawings_name': '',
|
||||||
|
'quality_standard_name': '',
|
||||||
|
'machining_drawings_mimetype': '',
|
||||||
|
'quality_standard_mimetype': '',
|
||||||
|
'machining_drawings': item.machining_drawings,
|
||||||
|
'quality_standard': '',
|
||||||
|
'part_name': '',
|
||||||
|
})
|
||||||
|
company_id = self.env.ref('base.main_company').sudo()
|
||||||
|
product_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_default').sudo()
|
||||||
|
# user_id = request.env.ref('base.user_admin').sudo()
|
||||||
|
order_id = self.env['sale.order'].sale_order_create(company_id, 'XXXXX', 'XXXXX', 'XXXXX',
|
||||||
|
str(datetime.now()), '现结', '支付宝', state='draft')
|
||||||
|
order_id.default_code = obj.name
|
||||||
|
i = 1
|
||||||
|
for item in res['bfm_process_order_list']:
|
||||||
|
product = self.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||||
|
obj.name, i)
|
||||||
|
order_id.with_user(self.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||||
|
return order_id
|
||||||
|
except Exception as e:
|
||||||
|
return UserError('工厂创建销售订单和产品失败,请联系管理员')
|
||||||
@@ -34,13 +34,9 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="jikimo_sale_order_view_search_inherit_quotation" model="ir.ui.view">
|
<record id="jikimo_sale_order_view_search_inherit_quotation" model="ir.ui.view">
|
||||||
<field name="name">jikimo.sale.order.search.inherit.quotation</field>
|
|
||||||
<field name="model">sale.order</field>
|
|
||||||
<field name="mode">primary</field>
|
|
||||||
<field name="inherit_id" ref="sale.sale_order_view_search_inherit_quotation"/>
|
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//filter[@name='my_quotation']" position="replace">
|
<xpath expr="//filter[@name='my_quotation']" position="attributes">
|
||||||
<filter string="My Quotations" name="my_quotation" domain="[('state', 'in', ('draft', 'sent'))]"/>
|
<attribute name="domain">[('state', 'in', ('draft', 'sent')), ('user_id', '=', uid)]</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -51,8 +47,8 @@
|
|||||||
<field name="mode">primary</field>
|
<field name="mode">primary</field>
|
||||||
<field name="inherit_id" ref="sale.sale_order_view_search_inherit_quotation"/>
|
<field name="inherit_id" ref="sale.sale_order_view_search_inherit_quotation"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//filter[@name='my_quotation']" position="replace">
|
<xpath expr="//filter[@name='my_quotation']" position="attributes">
|
||||||
<filter string="My Quotations" name="my_quotation" domain="[('state', 'in', ('draft', 'sent'))]"/>
|
<attribute name="domain">[('state', 'in', ('draft', 'sent')), ('user_id', '=', uid)]</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//filter[@name='draft']" position="after">
|
<xpath expr="//filter[@name='draft']" position="after">
|
||||||
<filter string="供货方式待确认" name="supply_method" domain="[('state', '=', 'supply method')]"/>
|
<filter string="供货方式待确认" name="supply_method" domain="[('state', '=', 'supply method')]"/>
|
||||||
@@ -60,7 +56,7 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="sale.action_quotations" model="ir.actions.act_window">
|
<record id="sale.action_quotations_with_onboarding" model="ir.actions.act_window">
|
||||||
<field name="search_view_id" ref="jikimo_sale_order_view_search_inherit_quotation"/>
|
<field name="search_view_id" ref="jikimo_sale_order_view_search_inherit_quotation"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -69,6 +65,7 @@
|
|||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">sale.order</field>
|
<field name="res_model">sale.order</field>
|
||||||
<field name="view_mode">tree,kanban,form,calendar,pivot,graph,activity</field>
|
<field name="view_mode">tree,kanban,form,calendar,pivot,graph,activity</field>
|
||||||
|
<field name="view_id" ref="sale.view_quotation_tree_with_onboarding"/>
|
||||||
<field name="search_view_id" ref="jikimo_sale_order_view_search_inherit_quotation_supply_method"/>
|
<field name="search_view_id" ref="jikimo_sale_order_view_search_inherit_quotation_supply_method"/>
|
||||||
<field name="context">{'search_default_supply_method': 1}</field>
|
<field name="context">{'search_default_supply_method': 1}</field>
|
||||||
<field name="help" type="html">
|
<field name="help" type="html">
|
||||||
@@ -93,7 +90,7 @@
|
|||||||
<!--供货路线专员菜单-->
|
<!--供货路线专员菜单-->
|
||||||
<menuitem
|
<menuitem
|
||||||
id="sale_order_menu_quotations_supply_method"
|
id="sale_order_menu_quotations_supply_method"
|
||||||
name="报价单"
|
name="报价"
|
||||||
action="action_quotations_supply_method"
|
action="action_quotations_supply_method"
|
||||||
parent="sale_order_menu_supply_method"
|
parent="sale_order_menu_supply_method"
|
||||||
groups="sf_base.group_production_engineer"
|
groups="sf_base.group_production_engineer"
|
||||||
|
|||||||
Reference in New Issue
Block a user