This commit is contained in:
胡尧
2024-11-11 10:22:53 +08:00
parent 2798ce6183
commit 0f37b45b30
26 changed files with 70 additions and 357 deletions

View File

@@ -7,8 +7,8 @@ from odoo import api, SUPERUSER_ID
def _set_init_product_active_false(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
# 获取所有需要设置的产品模板
env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').product_variant_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').product_variant_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_template_default').product_variant_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_template_raw_material_customer_provided').product_variant_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').product_variant_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_product_purchase').product_tmpl_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_product_manual_processing').product_tmpl_id.write({'active': False, 'single_manufacturing': True})
env.ref('jikimo_sale_multiple_supply_methods.product_product_default').product_tmpl_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_product_raw_material_customer_provided').product_tmpl_id.write({'active': False})
env.ref('jikimo_sale_multiple_supply_methods.product_product_outsourcing').product_tmpl_id.write({'active': False})

View File

@@ -6,13 +6,13 @@
'author': 'fox',
'website': '',
'category': '',
'depends': ['product', 'sf_dlm_management', 'sale_stock'],
'depends': ['product', 'sf_dlm', 'sale_stock'],
"data": [
'security/ir.model.access.csv',
'data/stock_routes.xml',
'data/product_data.xml',
'views/sale_order_views.xml',
'views/product_product_views.xml',
# 'views/product_product_views.xml',
],'assets': {
# 'web.assets_backend': [
# 'jikimo_sale_multiple_supply_methods/static/src/**/*'

View File

@@ -19,12 +19,7 @@ class JikimoSaleRoutePicking(Sf_Bf_Connect):
res = {'status': 1, 'factory_order_no': ''}
# _logger.info('get_bfm_process_order_list:%s' % kw['order_number'])
try:
product_tmpl_id = request.env.ref('jikimo_sale_multiple_supply_methods.product_template_default').sudo()
product_id = request.env['product.product'].sudo().search(
[('product_tmpl_id', '=', product_tmpl_id.id), ('active', '=', False)],
limit=1,
order='id asc'
)
product_id = request.env.ref('jikimo_sale_multiple_supply_methods.product_product_default').sudo()
company_id = request.env.ref('base.main_company').sudo()
bfm_process_order_list = json.loads(kw['bfm_process_order_list'])
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<record id="product_template_manual_processing" model="product.template">
<record id="product_product_manual_processing" model="product.product">
<field name="name">人工线下加工模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
@@ -19,7 +19,7 @@
<field name="is_manual_processing">true</field>
</record>
<record id="product_template_purchase" model="product.template">
<record id="product_product_purchase" model="product.product">
<field name="name">成品外购模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
@@ -33,7 +33,7 @@
<field name="is_bfm">true</field>
</record>
<record id="product_template_outsourcing" model="product.template">
<record id="product_product_outsourcing" model="product.product">
<field name="name">成品委外加工模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
@@ -47,7 +47,7 @@
<field name="is_bfm">true</field>
</record>
<record id="product_template_default" model="product.template">
<record id="product_product_default" model="product.product">
<field name="name">成品初始化模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="sf_dlm.product_category_finished_sf"/>
@@ -65,7 +65,7 @@
<field name="partner_id" eval="91"/>
</record>
<record id="product_template_raw_material_customer_provided" model="product.template">
<record id="product_product_raw_material_customer_provided" model="product.product">
<field name="name">坯料客供料模板</field>
<field name="active" eval="False"/>
<field name="categ_id" ref="sf_dlm.product_category_embryo_sf"/>
@@ -81,5 +81,10 @@
<field name="company_id" ref="base.main_company"/>
<field name="seller_ids" eval="[ref('jikimo_sale_multiple_supply_methods.product_supplierinfo_bfm')]"/>
</record>
<record id="product_embryo_sf_self_machining" model="product.product">
<field name="name">坯料加工模板(人工线下加工)</field>
<field name="is_manual_processing">true</field>
</record>
</data>
</odoo>

View File

@@ -28,5 +28,7 @@
<field name="picking_type_id" ref="material_picking_in"/>
<field name="action">pull</field>
</record>
</data>
</odoo>

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import product_template
from . import sale_order
from . import mrp_bom

View File

@@ -0,0 +1,13 @@
from odoo import models, fields
class MrpBom(models.Model):
_inherit = 'mrp.bom'
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
def bom_create(self, product, bom_type, product_type):
bom_id = super(MrpBom, self).bom_create(product, bom_type, product_type)
# 成品的供应商从模板中获取
if product_type == 'product':
bom_id.subcontractor_id = product.product_tmpl_id.seller_ids.partner_id.id
return bom_id

View File

@@ -28,4 +28,5 @@ class ProductTemplate(models.Model):
self.tracking = product_template_id.tracking
self.is_bfm = product_template_id.is_bfm
self.is_manual_processing = product_template_id.is_manual_processing
self.seller_ids = product_template_id.seller_ids
# 复制 seller_ids
self.seller_ids = [(0, 0, {'partner_id': seller.partner_id.id, 'delay': 1.0}) for seller in product_template_id.seller_ids]

View File

@@ -28,18 +28,18 @@ class SaleOrder(models.Model):
# 根据供货方式修改成品模板
if line.supply_method == 'automation':
bom_type = 'normal'
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo().product_tmpl_id
product_template_id = self.env.ref('sf_dlm.product_template_sf').sudo()
elif line.supply_method == 'outsourcing':
bom_type = 'subcontract'
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_outsourcing').sudo()
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_outsourcing').sudo()
elif line.supply_method == 'purchase':
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_purchase').sudo()
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_purchase').sudo()
elif line.supply_method == 'manual':
bom_type = 'normal'
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_manual_processing').sudo()
product_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_manual_processing').sudo()
# 复制成品模板上的属性
line.product_id.product_tmpl_id.copy_template(product_template_id)
line.product_id.product_tmpl_id.copy_template(product_template_id.product_tmpl_id)
order_id = self
product = line.product_id
@@ -63,21 +63,16 @@ class SaleOrder(models.Model):
# 当成品上带有客供料选项时,生成坯料时选择“客供料”路线
if line.is_incoming_material:
# 将成品模板的内容复制到成品上
embryo_template_id = self.env.ref('jikimo_sale_multiple_supply_methods.product_template_raw_material_customer_provided').sudo()
embryo_id = self.env['product.product'].search(
[('product_tmpl_id', '=', embryo_template_id.id), ('active', '=', False)],
limit=1,
order='id asc'
)
customer_provided_embryo = self.env.ref('jikimo_sale_multiple_supply_methods.product_product_raw_material_customer_provided').sudo()
# 创建坯料客供料的批量不需要创建bom
material_customer_provided_embryo = self.env['product.template'].sudo().no_bom_product_create(
embryo_id,
customer_provided_embryo,
item,
order_id, 'material_customer_provided', 0, product)
# 成品配置bom
product_bom_material_customer_provided = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create(
product, bom_type, True)
product, bom_type, 'product')
product_bom_material_customer_provided.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
material_customer_provided_embryo)
elif line.product_id.materials_type_id.gain_way == '自加工':
@@ -100,7 +95,7 @@ class SaleOrder(models.Model):
# 产品配置bom
product_bom_self_machining = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create(
product, bom_type, True)
product, bom_type, 'product')
product_bom_self_machining.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
self_machining_embryo)
elif line.product_id.materials_type_id.gain_way == '外协':
@@ -124,7 +119,7 @@ class SaleOrder(models.Model):
raise UserError('该订单模型的材料型号暂未有原材料,请先配置再进行分配')
# 产品配置bom
product_bom_outsource = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create(product, bom_type, True)
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product')
product_bom_outsource.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
outsource_embryo)
elif line.product_id.materials_type_id.gain_way == '采购':
@@ -132,14 +127,14 @@ class SaleOrder(models.Model):
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id,
item,
order_id,
'purchase', i,
'purchase', 0,
product)
if purchase_embryo == -3:
raise UserError('该订单模型的材料型号暂未设置获取方式和供应商,请先配置再进行分配')
else:
# 产品配置bom
product_bom_purchase = self.env['mrp.bom'].with_user(
self.env.ref("base.user_admin")).bom_create(product, bom_type, True)
self.env.ref("base.user_admin")).bom_create(product, bom_type, 'product')
product_bom_purchase.with_user(self.env.ref("base.user_admin")).bom_create_line_has(
purchase_embryo)
return super(SaleOrder, self).action_confirm()

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- 由于该模块不能依赖sf_dlm_management, 该功能只能在sf_dlm_management中实现并且依赖该模块-->
<record id="view_product_product_form_inherit_sf" model="ir.ui.view">
<field name="name">view.product.template.form.inherit.sf</field>
<field name="model">product.template</field>