Merge branch 'feature/返工、工序优化' into feature/销售、制造、返工优化

This commit is contained in:
yuxianghui
2024-12-19 13:46:01 +08:00
9 changed files with 205 additions and 15 deletions

View File

@@ -27,7 +27,7 @@ class JikimoSaleRoutePicking(Sf_Bf_Connect):
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(
company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'],
kw['delivery_end_date'], kw['payments_way'], kw['pay_way'], state='draft')
kw['delivery_end_date'], kw['payments_way'], kw['pay_way'], kw['order_number'], state='draft')
i = 1
# 给sale_order的default_code字段赋值
# aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)])

View File

@@ -13,6 +13,9 @@ class SaleOrder(models.Model):
('sent', "报价已发送"),
('supply method', "供货方式待确认"),
('sale', "销售订单"),
('processing', "加工中"),
('physical_distribution', "物流中"),
('delivered', "已交付"),
('done', "已锁定"),
('cancel', "已取消"),
])

View File

@@ -13,7 +13,7 @@
<button name="action_confirm" string="供货方式确认" type="object" attrs="{'invisible': [('state', '!=', 'supply method')]}" confirm="确认供货方式"/>
</xpath>
<xpath expr="//header/field[@name='state']" position="attributes">
<attribute name="statusbar_visible">draft,sent,supply method,sale</attribute>
<attribute name="statusbar_visible">supply method,sale,processing,physical_distribution,delivered</attribute>
</xpath>
<xpath expr="//page/field[@name='order_line']/tree/field[@name='remark']" position="before">
<field name="supply_method" attrs="{'invisible': [('state', '=', 'draft')], 'required': [('state', '=', 'supply method')]}" />

View File

@@ -26,7 +26,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
ret = json.loads(ret['result'])
logging.info('下发编程单:%s' % ret)
domain = [('programming_no', '=', ret['programming_no'])]
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework', 'rework'):
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
else:
domain += [('state', 'in', ['confirmed', 'pending_cam'])]
@@ -56,7 +56,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
return json.JSONEncoder().encode(res)
for production in productions:
production.write({'programming_state': '已编程', 'work_state': '已编程'})
production.write({'programming_state': '已编程', 'work_state': '已编程', 'is_rework': False})
for panel in ret['processing_panel'].split(','):
# 查询状态为进行中且工序类型为CNC加工的工单
cnc_workorder_has = production.workorder_ids.filtered(

View File

@@ -26,6 +26,7 @@
'assets': {
'web.assets_backend': [
'sf_sale/static/js/setTableWidth.js',
'sf_sale/static/src/css/purchase_list.css',
]
},
'demo': [

View File

@@ -55,12 +55,15 @@ class ReSaleOrder(models.Model):
store=True, readonly=False, copy=False, precompute=True,
states=READONLY_FIELD_STATES, default=fields.Datetime.now)
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效',
tracking=True)
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')],
default='normal',
string='时效', tracking=True)
order_code = fields.Char('平台订单号', readonly=True)
# 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
deadline_of_delivery, payments_way, pay_way, state='sale'):
deadline_of_delivery, payments_way, pay_way, order_number, state='sale'):
now_time = datetime.datetime.now()
partner = self.get_customer()
data = {
@@ -76,6 +79,7 @@ class ReSaleOrder(models.Model):
'address_of_delivery': delivery_address,
'payments_way': payments_way,
'pay_way': pay_way,
'order_code': order_number,
}
if deadline_of_delivery:
# deadline_of_delivery字段存在为false字符串情况
@@ -158,6 +162,66 @@ class ReSaleOrder(models.Model):
if not line.tax_id:
raise UserError('请对【订单行】中的【税】进行选择')
consignment_purchase_order_count = fields.Integer(
"Number of consignment Purchase Order Generated",
compute='_compute_purchase_order_count')
@api.depends('order_line.purchase_line_ids.order_id')
def _compute_purchase_order_count(self):
for order in self:
order.purchase_order_count = len(order._get_purchase_orders().filtered(
lambda po: po.purchase_type not in ['consignment']))
order.consignment_purchase_order_count = len(order._get_purchase_orders().filtered(
lambda po: po.purchase_type in ['consignment']))
def action_view_purchase_orders(self):
"""
采购
"""
self.ensure_one()
purchase_order_ids = self._get_purchase_orders().filtered(
lambda po: po.purchase_type not in ['consignment']).ids
action = {
'res_model': 'purchase.order',
'type': 'ir.actions.act_window',
}
if len(purchase_order_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': purchase_order_ids[0],
})
else:
action.update({
'name': _("%s生成采购订单", self.name),
'domain': [('id', 'in', purchase_order_ids)],
'view_mode': 'tree,form',
})
return action
def action_view_consignment_purchase_orders(self):
"""
委外加工
"""
self.ensure_one()
consignment_purchase_order_ids = self._get_purchase_orders().filtered(
lambda po: po.purchase_type in ['consignment']).ids
action = {
'res_model': 'purchase.order',
'type': 'ir.actions.act_window',
}
if len(consignment_purchase_order_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': consignment_purchase_order_ids[0],
})
else:
action.update({
'name': _("%s生成委外加工订单", self.name),
'domain': [('id', 'in', consignment_purchase_order_ids)],
'view_mode': 'tree,form',
})
return action
class ResaleOrderLine(models.Model):
_inherit = 'sale.order.line'
@@ -199,6 +263,7 @@ class ProductTemplate(models.Model):
_inherit = 'product.template'
manual_quotation = fields.Boolean('人工编程', default=False)
part_name = fields.Char(string='零件名称', readonly=True)
class RePurchaseOrder(models.Model):
@@ -215,8 +280,22 @@ class RePurchaseOrder(models.Model):
compute='_compute_user_id',
store=True)
purchase_type = fields.Selection([('standard', '标准采购'), ('consignment', '委外加工')], string='采购类型',
default='standard')
purchase_type = fields.Selection(
[('standard', '标准采购'), ('consignment', '委外加工'), ('outsourcing', '工序外协'), ('outside', '外购订单')],
string='采购类型', default='standard')
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', compute='_compute_origin_sale_id')
@api.depends('order_line.move_dest_ids.group_id.mrp_production_ids',
'order_line.move_ids.move_dest_ids.group_id.mrp_production_ids')
def _compute_origin_sale_id(self):
for purchase in self:
productions_ids = purchase._get_mrp_productions()
if productions_ids:
if productions_ids[0].sale_order_id:
purchase.origin_sale_id = productions_ids[0].sale_order_id.id
continue
purchase.origin_sale_id = False
@api.depends('partner_id')
def _compute_user_id(self):
@@ -255,7 +334,7 @@ class RePurchaseOrder(models.Model):
else:
server_template = self.env['product.template'].search(
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
('detailed_type', '=', 'service')])
('detailed_type', '=', 'service')])
server_product_process.append((0, 0, {
'product_id': server_template.product_variant_id.id,
'product_qty': 1,
@@ -300,6 +379,12 @@ class RePurchaseOrder(models.Model):
return result
class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=True)
class ResPartnerToSale(models.Model):
_inherit = 'res.partner'

View File

@@ -0,0 +1,3 @@
.purchase_order_list_name {
min-width: 62px !important;
}

View File

@@ -130,6 +130,15 @@
<xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="attributes">
<attribute name="options">{'no_create': True}</attribute>
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
<field name="part_name" string="零件名称" optional="show"/>
</xpath>
<xpath expr="//field[@name='date_order']" position="attributes">
<attribute name="string">报价截止日期</attribute>
</xpath>
<field name="partner_ref" position="attributes">
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
</attribute>
@@ -163,6 +172,10 @@
<field name="partner_ref" position="after">
<field name="purchase_type" string="采购类型" readonly="1"/>
</field>
<!-- 添加销售订单号字段-->
<field name="effective_date" position="after">
<field name="origin_sale_id" readonly="1" attrs="{'invisible': [('origin_sale_id', '=', False)]}"/>
</field>
</field>
</record>
@@ -174,6 +187,25 @@
<xpath expr="//tree//header//button[@name='action_create_invoice']" position="attributes">
<attribute name="groups">sf_base.group_purchase,sf_base.group_purchase_director</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="attributes">
<attribute name="string">采购员</attribute>
</xpath>
<xpath expr="//field[@name='activity_ids']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
<xpath expr="//field[@name='date_order']" position="attributes">
<attribute name="string">报价截止日期</attribute>
<attribute name="widget">''</attribute>
</xpath>
<xpath expr="//field[@name='date_order']" position="after">
<field name="date_planned"/>
</xpath>
<xpath expr="//field[@name='name']" position="after">
<field name="purchase_type"/>
</xpath>
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="class">purchase_order_list_name</attribute>
</xpath>
</field>
</record>
@@ -201,6 +233,23 @@
<tree position="attributes">
<attribute name="default_order">date_approve asc</attribute>
</tree>
<xpath expr="//field[@name='activity_ids']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
<xpath expr="//field[@name='date_planned']" position="replace">
</xpath>
<xpath expr="//field[@name='user_id']" position="attributes">
<attribute name="string">采购员</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="date_planned" string="预计到货日期" optional="show"/>
</xpath>
<xpath expr="//field[@name='name']" position="after">
<field name="purchase_type"/>
</xpath>
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="class">purchase_order_list_name</attribute>
</xpath>
</field>
</record>
@@ -212,8 +261,29 @@
<xpath expr="//field[@name='name']" position="replace">
<field name="name" string="单据编码" filter_domain="[('name', 'ilike', self)]"/>
</xpath>
<!-- <xpath expr="//search" position="inside">-->
<!-- <searchpanel>-->
<!-- <field name="purchase_type" icon="fa-filter"/>-->
<!-- <field name="state" icon="fa-filter"/>-->
<!-- </searchpanel>-->
<!-- </xpath>-->
</field>
</record>
<record id="purchase_order_view_search_sf" model="ir.ui.view">
<field name="name">purchase.order.list.select.sf</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_view_search"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<searchpanel>
<field name="purchase_type" icon="fa-filter" enable_counters="1"/>
<field name="state" icon="fa-filter" enable_counters="1"/>
</searchpanel>
</xpath>
</field>
</record>
<record id="purchase.product_normal_action_puchased" model="ir.actions.act_window">
<field name="context">
{"search_default_categ_id":1,"search_default_filter_to_purchase":1, "purchase_product_template": 1}

View File

@@ -169,20 +169,36 @@
<field name="manual_quotation" />
<field name="is_incoming_material"/>
</xpath>
<xpath expr="//field[@name='date_order']" position="attributes">
<attribute name="string">下单时间</attribute>
<xpath expr="//sheet//group//group[@name='order_details']//div[@class='o_td_label'][2]//label[@for='date_order']" position="attributes">
<attribute name="string">下单日期</attribute>
</xpath>
</field>
</record>
<record id="sale_order_inherited_form_purchase_sf" model="ir.ui.view">
<field name="name">sale.order.inherited.form.purchase</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_purchase.sale_order_inherited_form_purchase"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_view_purchase_orders']" position="before">
<button class="oe_stat_button" name="action_view_consignment_purchase_orders" type="object" icon="fa-credit-card"
groups='purchase.group_purchase_user'
attrs="{'invisible': [('consignment_purchase_order_count', '=', 0)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="consignment_purchase_order_count"/></span>
<span class="o_stat_text">委外加工</span>
</div>
</button>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_sale_management_order_form_quote_inherit_sf">
<field name="name">sale.management.order.form.quote.inherit.sf</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_management.sale_order_form_quote"/>
<field name="arch" type="xml">
<field name="date_order" position="attributes">
<attribute name="string">下单日期</attribute>
</field>
<field name="sale_order_template_id" position="after">
<field name="remark" attrs="{'readonly': [('state', 'in', ('sale','cancel'))]}"/>
</field>
@@ -224,6 +240,7 @@
<attribute name="optional">hide</attribute>
</xpath>
<xpath expr="//field[@name='create_date']" position="after">
<field name="order_code"/>
<field name="deadline_of_delivery"/>
</xpath>
<!-- <field name="state" position="after">
@@ -245,6 +262,10 @@
<separator/>
<filter string="预警" name="filter_order_warning" domain="[('delivery_warning', '=', 'warning')]"/>
<filter string="逾期" name="filter_order_overdue" domain="[('delivery_warning', '=', 'overdue')]"/>
<searchpanel>
<field name="delivery_warning" string="交期状态" icon="fa-filter" enable_counters="1"/>
<field name="state" icon="fa-filter" enable_counters="1"/>
</searchpanel>
</xpath>
</field>
</record>
@@ -267,7 +288,11 @@
<field name="amount_total" position="after">
<field name="delivery_warning" invisible="1"/>
</field>
<field name="date_order" position="attributes">
<attribute name="string">下单日期</attribute>
</field>
<xpath expr="//field[@name='date_order']" position="after">
<field name="order_code"/>
<field name="deadline_of_delivery"/>
</xpath>
<xpath expr="//field[@name='activity_ids']" position="attributes">
@@ -276,6 +301,9 @@
<xpath expr="//field[@name='invoice_status']" position="after">
<field name="state"/>
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="delivery_warning" string="交期状态"/>
</xpath>
</field>
</record>