Compare commits

...

24 Commits

Author SHA1 Message Date
刘磊
62f0578ce8 Accept Merge Request #2293: (feature/7254_new -> develop)
Merge Request: 材料型号增加是否磁吸

Created By: @刘磊
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @刘磊
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2293
2025-07-18 15:12:05 +08:00
刘磊
b2a0899553 Accept Merge Request #2294: (feature/7230 -> develop)
Merge Request: 夹具型号相关数据表的优化

Created By: @刘磊
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @刘磊
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2294
2025-07-18 15:11:41 +08:00
陈赓
2347ed9cb3 材料型号增加是否磁吸 2025-07-17 14:12:35 +08:00
胡尧
e4c3435840 Accept Merge Request #2292: (feature/增加模块完整性验证 -> develop)
Merge Request: 去掉多余的js

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2292?initial=true
2025-07-16 15:04:01 +08:00
胡尧
2a7048dafd 去掉多余的js 2025-07-16 15:03:23 +08:00
胡尧
2bb215f9df Accept Merge Request #2291: (feature/增加模块完整性验证 -> develop)
Merge Request: 去掉多余的js文件

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2291?initial=true
2025-07-16 14:33:35 +08:00
胡尧
a2be3a0dbf 去掉多余的js文件 2025-07-16 14:32:37 +08:00
李晓斌
1f4ceab377 Accept Merge Request #2290: (feature/7253 -> develop)
Merge Request: Bug_7262_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2290?initial=true
2025-07-16 14:10:37 +08:00
lixiaobin@jikimo.com
94d727e8e0 Bug_7262_lxb_commit 2025-07-16 14:06:58 +08:00
李晓斌
42d9f894dd Accept Merge Request #2289: (feature/7253 -> develop)
Merge Request: BUG_7276_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2289
2025-07-16 11:23:08 +08:00
lixiaobin@jikimo.com
9416d1c1a0 BUG_7276_lxb_commit 2025-07-16 11:20:26 +08:00
管欢
7dd44ca12c Accept Merge Request #2288: (feature/物料需求计划管理 -> develop)
Merge Request: 下达计划按钮重复点击生成重复数据

Created By: @管欢
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @管欢
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2288
2025-07-16 09:41:06 +08:00
guanhuan
5a98b20988 下达计划按钮重复点击生成重复数据 2025-07-16 09:32:28 +08:00
李晓斌
2738085a1e Accept Merge Request #2287: (feature/7253 -> develop)
Merge Request: Bug_7276_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2287?initial=true
2025-07-15 16:56:26 +08:00
lixiaobin@jikimo.com
61c1fdbd05 Bug_7276_lxb_commit 2025-07-15 16:53:52 +08:00
hyyy
7eea5a0ff2 重复点击 2025-07-15 16:25:28 +08:00
李晓斌
714c68c0c1 Accept Merge Request #2286: (feature/7253 -> develop)
Merge Request: BUG_7276_lxb_commit

Created By: @李晓斌
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @李晓斌
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2286
2025-07-15 14:35:11 +08:00
lixiaobin@jikimo.com
f3e7ba7f68 BUG_7276_lxb_commit 2025-07-15 14:17:38 +08:00
lixiaobin@jikimo.com
df589b43e7 BUG_7276_lxb_commit 2025-07-15 14:13:01 +08:00
lixiaobin@jikimo.com
8bdc65c626 BUG_7276_lxb_commit 2025-07-15 14:09:14 +08:00
guanhuan
0c3407572f 需求计划详情 2025-07-15 11:51:14 +08:00
hyyy
e5404efb60 批量下达计划禁用 2025-07-15 11:39:20 +08:00
guanhuan
46f60028aa 需求位置修改 2025-07-15 10:40:19 +08:00
guanhuan
bfc071debd 需求位置修改 2025-07-15 10:34:28 +08:00
18 changed files with 132 additions and 138 deletions

View File

@@ -35,7 +35,6 @@
],
'web.assets_backend': [
'sf_base/static/src/scss/*.scss',
'sf_base/static/src/js/*.js',
],
},

View File

@@ -42,6 +42,7 @@ class MrsMaterialModel(models.Model):
materials_num = fields.Char("编码号")
name = fields.Char('型号名')
need_h = fields.Boolean("热处理", default="false")
need_m = fields.Boolean("是否磁吸", default="false")
mf_materia_post = fields.Char("热处理后密度")
density = fields.Float("密度(kg/m³)")
materials_id = fields.Many2one('sf.production.materials', "材料名")

View File

@@ -1,62 +0,0 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { barcodeGenericHandlers } from '@barcodes/barcode_handlers';
import { patch } from "@web/core/utils/patch";
// 定义新的 clickOnButton 函数
function customClickOnButton(selector) {
console.log("This is the custom clickOnButton function!");
const buttons = document.body.querySelectorAll(selector);
let length = buttons.length;
if (length > 0) {
buttons[length - 1].click();
} else {
console.warn(`Button with selector ${selector} not found`);
}
}
patch(barcodeGenericHandlers, "start", {
start(env, { ui, barcode, notification }) {
// 使用新定义的 clickOnButton 函数
const COMMANDS = {
"O-CMD.EDIT": () => customClickOnButton(".o_form_button_edit"),
"O-CMD.DISCARD": () => customClickOnButton(".o_form_button_cancel"),
"O-CMD.SAVE": () => customClickOnButton(".o_form_button_save"),
"O-CMD.PREV": () => customClickOnButton(".o_pager_previous"),
"O-CMD.NEXT": () => customClickOnButton(".o_pager_next"),
"O-CMD.PAGER-FIRST": () => updatePager("first"),
"O-CMD.PAGER-LAST": () => updatePager("last"),
"O-CMD.CONFIRM": () => customClickOnButton(".jikimo_button_confirm"),
"O-CMD.FLUSHED": () => customClickOnButton(".jikimo_button_flushed"),
};
barcode.bus.addEventListener("barcode_scanned", (ev) => {
const barcode = ev.detail.barcode;
if (barcode.startsWith("O-BTN.")) {
let targets = [];
try {
targets = getVisibleElements(ui.activeElement, `[barcode_trigger=${barcode.slice(6)}]`);
} catch (_e) {
console.warn(`Barcode '${barcode}' is not valid`);
}
for (let elem of targets) {
elem.click();
}
}
if (barcode.startsWith("O-CMD.")) {
const fn = COMMANDS[barcode];
if (fn) {
fn();
} else {
notification.add(env._t("Barcode: ") + `'${barcode}'`, {
title: env._t("Unknown barcode command"),
type: "danger"
});
}
}
});
}
})

View File

@@ -1,42 +0,0 @@
/** @odoo-module **/
import { registry } from '@web/core/registry';
import { formView } from '@web/views/form/form_view';
import { FormController } from '@web/views/form/form_controller';
import { listView } from '@web/views/list/list_view';
import { ListController } from '@web/views/list/list_controller'
import { onRendered, onMounted } from "@odoo/owl";
export class RemoveFocusFormController extends FormController {
setup() {
super.setup();
onMounted(() => {
this.__owl__.bdom.el.querySelectorAll(':focus').forEach(element => element.blur());
})
}
}
registry.category('views').add('remove_focus_form_view', {
...formView,
Controller: RemoveFocusFormController,
});
export class RemoveFocusListController extends ListController {
setup() {
super.setup();
onMounted(() => {
this.__owl__.bdom.el.querySelectorAll(':focus').forEach(element => element.blur());
})
}
}
registry.category('views').add('remove_focus_list_view', {
...listView,
Controller: RemoveFocusListController,
});

View File

@@ -263,6 +263,7 @@
<field name="materials_no" readonly="1" force_save="1"/>
<field name="gain_way" required="0"/>
<field name="density" readonly="1" required="1" class="custom_required"/>
<field name="need_m" default="false" readonly="1"/>
</group>
<group>
<field name="rough_machining" required="1"/>
@@ -306,6 +307,7 @@
<field name="tensile_strength"/>
<field name="hardness" optional="show"/>
<field name="need_h"/>
<field name="need_m"/>
<field name="apply" widget="many2many_tags" optional="show"/>
<field name="density" optional="show"/>
<field name="rough_machining" optional="hide"/>
@@ -352,6 +354,7 @@
<field name="materials_no"/>
<field name="name"/>
<field name="need_h"/>
<field name="need_m"/>
<field name="mf_materia_post"/>
<field name="density"/>
<field name='materials_id' default="default" invisible="1"/>

View File

@@ -30,6 +30,7 @@
'web.assets_backend': [
'sf_demand_plan/static/src/scss/style.css',
'sf_demand_plan/static/src/js/print_demand.js',
'sf_demand_plan/static/src/js/custom_button.js',
]
},
'license': 'LGPL-3',

View File

@@ -36,7 +36,7 @@ class PurchaseOrderLine(models.Model):
@api.model
def create(self, vals):
res = super(PurchaseOrderLine, self).create(vals)
if not res.demand_plan_line_id:
if not res.demand_plan_line_id and res.order_id.origin:
origin = [origin.replace(' ', '') for origin in res.order_id.origin.split(',')]
if self.env.context.get('demand_plan_line_id'):
res.demand_plan_line_id = self.env.context.get('demand_plan_line_id')

View File

@@ -222,9 +222,14 @@ class SfDemandPlan(models.Model):
line_ids = self.line_ids.filtered(lambda p: p.status == '30')
sum_product_uom_qty = sum(line_ids.mapped('plan_uom_qty'))
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
if not self.overdelivery_allowed and line_ids.filtered(lambda p: p.location_id.id == customer_location_id):
check_overdelivery_allowed = False
for line in line_ids:
if line.location_id.id == customer_location_id:
if not self.overdelivery_allowed:
if float_compare(sum_product_uom_qty, self.product_uom_qty,
precision_rounding=self.product_id.uom_id.rounding) == 1:
precision_rounding=line.product_id.uom_id.rounding) == 1:
check_overdelivery_allowed = True
if check_overdelivery_allowed:
raise ValidationError(f"已禁止向合作伙伴/客户超量发货,请更换“补货原因”或将“可超量发货”设置为“是”。")
elif float_compare(sum_product_uom_qty, self.product_uom_qty,
precision_rounding=self.product_id.uom_id.rounding) == 1:

View File

@@ -14,10 +14,10 @@ class SfProductionDemandPlan(models.Model):
_description = 'sf_production_demand_plan'
def get_location_id(self):
stock_location = self.env['stock.location'].sudo().search([('name', '=', '客户')], limit=1)
return stock_location.id
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
return customer_location_id
priority = fields.Selection(related='demand_plan_id.priority', string='优先级')
priority = fields.Selection(related='demand_plan_id.priority', string='优先级', store=True)
status = fields.Selection([
('10', '草稿'),
('20', '待确认'),
@@ -34,7 +34,7 @@ class SfProductionDemandPlan(models.Model):
company_id = fields.Many2one(
related='sale_order_id.company_id',
store=True, index=True, precompute=True)
customer_name = fields.Char('客户', related='sale_order_id.customer_name')
customer_name = fields.Char('客户', related='sale_order_id.customer_name', store=True)
order_remark = fields.Text(related='sale_order_id.remark',
string="订单备注", store=True)
glb_url = fields.Char(related='sale_order_line_id.glb_url', string='glb文件地址')
@@ -83,7 +83,7 @@ class SfProductionDemandPlan(models.Model):
related='product_id.blank_precision')
unit_number = fields.Float('单件用量', digits=(16, 3), related='product_id.unit_number')
embryo_long = fields.Char('坯料尺寸(mm)', related='demand_plan_id.embryo_long')
materials_id = fields.Char('材料', related='demand_plan_id.materials_id')
materials_id = fields.Char('材料', related='demand_plan_id.materials_id', store=True)
model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度')
model_process_parameters_ids = fields.Many2many(related='demand_plan_id.model_process_parameters_ids',
string='表面工艺', )
@@ -127,6 +127,12 @@ class SfProductionDemandPlan(models.Model):
string='字段自制类型只读'
)
is_processing = fields.Boolean(
string='正在处理中',
default=False,
help='用于防止重复点击按钮'
)
# hide_action_open_mrp_production = fields.Boolean(
# string='显示待工艺确认按钮',
# compute='_compute_hid_button',
@@ -607,11 +613,6 @@ class SfProductionDemandPlan(models.Model):
filtered_plan = self.filtered(lambda mo: mo.status == '30')
if not filtered_plan:
raise UserError(_("没有需要下达的计划!"))
check_overdelivery_allowed = False
if not self.demand_plan_id.overdelivery_allowed:
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
if self.location_id.id == customer_location_id:
check_overdelivery_allowed = True
# 按产品分组并计算总数
product_data = {}
for plan in filtered_plan:
@@ -659,9 +660,15 @@ class SfProductionDemandPlan(models.Model):
'default_demand_plan_line_id': self.ids,
'default_release_message': warning_message,
}}
else:
for demand_plan_line_id in filtered_plan:
demand_plan_line_id.action_confirm()
def button_release_plan(self):
self.ensure_one()
if self.is_processing:
return
self.is_processing = True
check_overdelivery_allowed = False
if not self.demand_plan_id.overdelivery_allowed:
customer_location_id = self.env['ir.model.data']._xmlid_to_res_id('stock.stock_location_customers')
@@ -701,18 +708,6 @@ class SfProductionDemandPlan(models.Model):
self.update_sale_order_state()
def mrp_bom_create(self):
if self.supply_method in ('automation', 'manual'):
line_ids = self.demand_plan_id.line_ids.filtered(
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
if line_ids:
self.bom_id = line_ids[0].bom_id.id
return
elif self.supply_method == 'outsourcing':
line_ids = self.demand_plan_id.line_ids.filtered(
lambda p: p.supply_method == 'outsourcing' and p.status == '60')
if line_ids:
self.bom_id = line_ids[0].bom_id.id
return
bom_type = ''
# 根据供货方式修改成品模板
if self.supply_method == 'automation':
@@ -732,6 +727,18 @@ class SfProductionDemandPlan(models.Model):
# 复制成品模板上的属性
self.product_id.product_tmpl_id.copy_template(product_template_id)
if self.supply_method in ('automation', 'manual'):
line_ids = self.demand_plan_id.line_ids.filtered(
lambda p: p.supply_method in ('automation', 'manual') and p.status in ('50', '60'))
if line_ids:
self.bom_id = line_ids[0].bom_id.id
return
elif self.supply_method == 'outsourcing':
line_ids = self.demand_plan_id.line_ids.filtered(
lambda p: p.supply_method == 'outsourcing' and p.status == '60')
if line_ids:
self.bom_id = line_ids[0].bom_id.id
return
future_time = datetime.now() + timedelta(hours=8)
# 生成BOM单据编码
code = f"{self.product_id.default_code}-{bom_type}-{future_time.strftime('%Y%m%d%H%M%S')}"
@@ -911,3 +918,6 @@ class SfProductionDemandPlan(models.Model):
'demand_plan_line_id': self.id
}
return values
def button_plan_detail(self):
pass

View File

@@ -0,0 +1,59 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { ListRenderer } from "@web/views/list/list_renderer";
import { useService } from "@web/core/utils/hooks";
import { useEffect } from "@odoo/owl";
export class CustomDemandPlanListRenderer extends ListRenderer {
setup() {
super.setup();
this.orm = useService("orm");
this.notification = useService("notification");
console.log('setup', this.props);
// 监听selection属性的变化
useEffect(() => {
this.updateButtonState();
}, () => [this.props.list.selection]);
}
/**
* 更新按钮状态
*/
async updateButtonState() {
const selectedRecords = this.props.list.selection;
const isStatus30 = selectedRecords.some(record => record.data.status != "30");
const button = $(this.__owl__.parent.bdom.parentEl).find('button[name="button_batch_release_plan"]');
console.log('isStatus30', isStatus30, button);
if (isStatus30) {
// 禁用按钮
button.attr('disabled', true);
} else {
button.attr('disabled', false);
}
}
}
// 使用setTimeout延迟注册避免在模块加载时立即执行
setTimeout(() => {
const registerCustomRenderer = () => {
try {
const listView = registry.category("views").get("list");
if (listView) {
registry.category("views").add("custom_demand_plan_list", {
...listView,
Renderer: CustomDemandPlanListRenderer,
});
console.log("Custom demand plan list renderer registered successfully");
} else {
console.warn("List view not found, retrying...");
// 如果还没找到,再等一段时间
setTimeout(registerCustomRenderer, 1000);
}
} catch (error) {
console.error("Error registering custom renderer:", error);
}
};
registerCustomRenderer();
}, 1000);

View File

@@ -4,7 +4,8 @@
<field name="model">sf.production.demand.plan</field>
<field name="arch" type="xml">
<tree string="需求计划" default_order="sequence desc,id desc" editable="bottom"
class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false">
class="demand_plan_tree freeze-columns-before-part_number" create="false" delete="false"
js_class="custom_demand_plan_list">
<header>
<button string="打印" name="button_action_print" type="object"
class="btn-primary"/>

View File

@@ -108,6 +108,9 @@
class="btn-primary"
attrs="{'invisible': [('hide_release_production_order', '=', False)]}"
/>
<button string="详情" name="button_plan_detail" type="object"
class="btn-primary"
/>
</tree>
</field>
</page>

View File

@@ -37,7 +37,7 @@ class SfDemandPlanPrintWizard(models.TransientModel):
if pdf_data:
try:
# 执行打印
self.env['jikimo.printing'].sudo().print_pdf(pdf_data)
# self.env['jikimo.printing'].sudo().print_pdf(pdf_data)
record.status = 'success'
production_demand_plan_id = self.env['sf.production.demand.plan'].sudo().search(
[('model_id', '=', record.model_id)])

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import logging
from odoo import models, fields, api, _
from werkzeug.exceptions import InternalServerError
_logger = logging.getLogger(__name__)
@@ -17,4 +18,10 @@ class SfReleasePlanWizard(models.TransientModel):
def confirm(self):
if self.demand_plan_line_id:
for demand_plan_line_id in self.demand_plan_line_id:
try:
demand_plan_line_id.action_confirm()
except Exception as e:
self.env.cr.rollback()
demand_plan_line_id.write({'is_processing': False})
self.env.cr.commit()
raise InternalServerError('操作失败', e)

View File

@@ -11,7 +11,7 @@
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse', 'jikimo_attachment_viewer',
'jikimo_sale_multiple_supply_methods', 'product'],
'jikimo_sale_multiple_supply_methods', 'product', 'jikimo_tree_header_buttons_always_visible'],
'data': [
'data/cron_data.xml',
'data/stock_data.xml',

View File

@@ -179,6 +179,7 @@ class sfMaterialModel(models.Model):
materials_model.mf_materia_post = item['mf_materia_post']
materials_model.materials_id = materials.id
materials_model.need_h = item['need_h']
materials_model.need_m = item['need_m']
materials_model.density = item['density']
materials_model.active = item['active']
else:
@@ -193,6 +194,7 @@ class sfMaterialModel(models.Model):
"active": item['active'],
"materials_id": materials.id,
"need_h": item['need_h'],
"need_m": item['need_m'],
"mf_materia_post": item['mf_materia_post'],
"density": item['density'],
})
@@ -229,6 +231,7 @@ class sfMaterialModel(models.Model):
"standards_id": self.env['sf.international.standards'].search(
[("name", '=', item['standards_id'])]).id,
"need_h": item['need_h'],
"need_m": item['need_m'],
"alloy_code": item['alloy_code'],
"mf_materia_post": item['mf_materia_post'],
"density": item['density'],
@@ -249,6 +252,7 @@ class sfMaterialModel(models.Model):
materials_model.mf_materia_post = item['mf_materia_post']
materials_model.materials_id = materials.id
materials_model.need_h = item['need_h']
materials_model.need_m = item['need_m']
materials_model.density = item['density']
materials_model.active = item['active']
materials_model.materials_code= item['materials_code']

View File

@@ -45759,6 +45759,11 @@ msgstr ""
msgid "热处理"
msgstr ""
#. module: sf_base
#: model:ir.model.fields,field_description:sf_base.field_sf_materials_model__need_m
msgid "是否磁吸"
msgstr ""
#. module: sf_base
#: model:ir.model.fields,field_description:sf_base.field_sf_materials_model__mf_materia_post
msgid "热处理后密度"

View File

@@ -155,7 +155,7 @@ class ReSaleOrder(models.Model):
'glb_url': item['glb_url'],
'remark': item.get('remark'),
'embryo_redundancy_id': item.get('embryo_redundancy_id'),
'is_incoming_material': True if item.get('embryo_redundancy_id') else False,
'is_incoming_material': True if item.get('incoming_size') else False,
'manual_quotation': item.get('manual_quotation'),
'model_id': item['model_id'],
'delivery_end_date': item['delivery_end_date']
@@ -287,7 +287,7 @@ class ResaleOrderLine(models.Model):
check_status = fields.Selection(related='order_id.check_status')
remark = fields.Char('备注')
is_incoming_material = fields.Boolean('客供料', compute='_compute_is_incoming_material', store=True)
is_incoming_material = fields.Boolean('客供料', store=True)
embryo_redundancy_id = fields.Many2one('sf.embryo.redundancy', '坯料冗余')
manual_quotation = fields.Boolean('人工编程', default=False)
model_url = fields.Char('模型文件地址')