外协流程更改

This commit is contained in:
liaodanlong
2025-04-17 14:29:06 +08:00
parent 0db31f7936
commit 962931bc9d
17 changed files with 281 additions and 58 deletions

View File

@@ -6,3 +6,4 @@ from . import production_technology_re_adjust_wizard
from . import mrp_workorder_batch_replan_wizard
from . import sf_programming_reason
from . import sale_order_cancel
from . import process_outsourcing

View File

@@ -0,0 +1,42 @@
from odoo import models, fields, api
class ProductCreationWizard(models.TransientModel):
_name = 'product.creation.wizard'
_description = '产品创建向导'
# 唯一需要用户输入的字段:产品类别
categ_id = fields.Many2one(
'product.category',
string='产品类别',
required=True,default=lambda self: self.env.ref(
'sf_manufacturing.product_category_outsource_other_process',
raise_if_not_found=False
).sudo(),
)
process_parameter_id = fields.Many2one('sf.production.process.parameter')
def action_create_service_product(self):
# 获取产品分类(服务)
service_categ = self.env.ref('sf_manufacturing.product_category_outsource_other_process').sudo()
default_values = {
'detailed_type': 'service',
'name': f"{self.process_parameter_id.process_id.name}{self.process_parameter_id.name}",
'invoice_policy': 'delivery',
'categ_id': service_categ.id,
'description': f"基于{self.process_parameter_id.name}创建的服务产品",
'sale_ok': True, # 可销售
'purchase_ok': True, # 可采购
'server_product_process_parameters_id': self.process_parameter_id.id,
}
def action_create_product(self):
service_categ = self.env.ref('sf_manufacturing.product_category_outsource_other_process').sudo()
default_values = {
'detailed_type': 'service',
'name': f"{self.process_parameter_id.process_id.name}{self.process_parameter_id.name}",
'invoice_policy': 'delivery',
'categ_id': self.categ_id.id,
'description': f"基于{self.process_parameter_id.name}创建的服务产品",
'sale_ok': True, # 可销售
'purchase_ok': True, # 可采购
'server_product_process_parameters_id': self.process_parameter_id.id,
}
self.env['product.template'].create(default_values)

View File

@@ -0,0 +1,37 @@
<odoo>
<record id="view_product_creation_wizard_form" model="ir.ui.view">
<field name="name">product.creation.wizard.form</field>
<field name="model">product.creation.wizard</field>
<field name="arch" type="xml">
<form string="创建产品">
<sheet>
<group>
<field name="categ_id" required="1"/>
</group>
</sheet>
<footer>
<button
name="action_create_product"
string="创建"
type="object"
class="btn-primary"
/>
<button
string="取消"
special="cancel"
class="btn-secondary"
/>
</footer>
</form>
</field>
</record>
<!-- 向导动作 -->
<record id="action_product_creation_wizard" model="ir.actions.act_window">
<field name="name">快速创建产品</field>
<field name="res_model">product.creation.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="product.model_product_product"/>
</record>
</odoo>