Compare commits

..

2 Commits

Author SHA1 Message Date
胡尧
307e860fe0 增加提示模块 2025-06-20 15:16:43 +08:00
胡尧
bd27f288f7 增加提示模块 2025-06-20 15:16:25 +08:00
7 changed files with 44 additions and 73 deletions

View File

@@ -190,7 +190,7 @@ def _create(self, data_list):
# 如果该用户组被限制创建或更新操作 # 如果该用户组被限制创建或更新操作
if rec['is_create_or_update']: if rec['is_create_or_update']:
raise UserError( raise UserError(
_("您没有执行此操作的权限。请联系管理员")) _("您没有执行此操作%s的权限。请联系管理员" % group_xml_id))
else: else:
# 如果 'access.right' 模型不存在,可以在这里定义备选逻辑 # 如果 'access.right' 模型不存在,可以在这里定义备选逻辑
# 例如,记录日志、发送通知或者简单地跳过这部分逻辑 # 例如,记录日志、发送通知或者简单地跳过这部分逻辑

View File

@@ -10,7 +10,7 @@
""", """,
'category': 'sf', 'category': 'sf',
'website': 'https://www.sf.jikimo.com', 'website': 'https://www.sf.jikimo.com',
'depends': ['sf_plan','jikimo_printing'], 'depends': ['sf_plan'],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'views/demand_plan.xml', 'views/demand_plan.xml',

View File

@@ -196,14 +196,11 @@ class SfProductionDemandPlan(models.Model):
else: else:
line.model_long = None line.model_long = None
@api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height', 'product_id.blank_type') @api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height')
def _compute_embryo_long(self): def _compute_embryo_long(self):
for line in self: for line in self:
if line.product_id: if line.product_id:
if line.product_id.blank_type == '圆料': line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
else:
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
else: else:
line.embryo_long = None line.embryo_long = None
@@ -406,30 +403,29 @@ class SfProductionDemandPlan(models.Model):
outsourcing_purchase_request.extend(pr_ids.ids) outsourcing_purchase_request.extend(pr_ids.ids)
if record.supply_method == 'outsourcing' and not record.sale_order_line_id.is_incoming_material: if record.supply_method == 'outsourcing' and not record.sale_order_line_id.is_incoming_material:
bom_line_ids = record.product_id.bom_ids.bom_line_ids bom_line_ids = record.product_id.bom_ids.bom_line_ids
if bom_line_ids: # BOM_数量
# BOM_数量 total_product_qty = sum(line.product_qty for line in bom_line_ids)
total_product_qty = sum(line.product_qty for line in bom_line_ids) bom_product_ids = bom_line_ids.mapped('product_id')
bom_product_ids = bom_line_ids.mapped('product_id') product_purchase_orders = self.env['purchase.order'].sudo().search([
product_purchase_orders = self.env['purchase.order'].sudo().search([ ('state', 'in', ('purchase', 'done')),
('state', 'in', ('purchase', 'done')), ('order_line.product_id', 'in', bom_product_ids.ids)
('order_line.product_id', 'in', bom_product_ids.ids) ])
]) # 购订单_数量
# 购订单_数量 total_outsourcing_purchase_quantity = sum(
total_outsourcing_purchase_quantity = sum( sum(
sum( order.order_line.filtered(
order.order_line.filtered( lambda line: line.product_id in bom_product_ids
lambda line: line.product_id in bom_product_ids ).mapped('product_qty')
).mapped('product_qty')
)
for order in product_purchase_orders
) )
quantity = total_outsourcing_purchase_quantity / total_product_qty for order in product_purchase_orders
if float_compare(quantity, record.product_uom_qty, )
precision_rounding=record.product_id.uom_id.rounding) == -1: quantity = total_outsourcing_purchase_quantity / total_product_qty
purchase_request = self.env['purchase.request'].sudo().search( if float_compare(quantity, record.product_uom_qty,
[('line_ids.product_id', 'in', bom_product_ids.ids), precision_rounding=record.product_id.uom_id.rounding) == -1:
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')]) purchase_request = self.env['purchase.request'].sudo().search(
outsourcing_purchase_request.extend(purchase_request.ids) [('line_ids.product_id', 'in', bom_product_ids.ids),
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')])
outsourcing_purchase_request.extend(purchase_request.ids)
record.outsourcing_purchase_request = json.dumps(outsourcing_purchase_request) record.outsourcing_purchase_request = json.dumps(outsourcing_purchase_request)
if outsourcing_purchase_request: if outsourcing_purchase_request:
record.hide_action_purchase_orders = True record.hide_action_purchase_orders = True

View File

@@ -28,7 +28,7 @@
<field name="qty_delivered"/> <field name="qty_delivered"/>
<field name="qty_to_deliver"/> <field name="qty_to_deliver"/>
<field name="model_long"/> <field name="model_long"/>
<field name="blank_type" optional="hide"/> <field name="blank_type"/>
<field name="embryo_long"/> <field name="embryo_long"/>
<field name="materials_id"/> <field name="materials_id"/>
<field name="model_machining_precision"/> <field name="model_machining_precision"/>

View File

@@ -4,12 +4,12 @@
<field name="name">sf.demand.plan.print.wizard.tree</field> <field name="name">sf.demand.plan.print.wizard.tree</field>
<field name="model">sf.demand.plan.print.wizard</field> <field name="model">sf.demand.plan.print.wizard</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="打印" class="print_demand" js_class="print_demand"> <tree string="打印" class="print_demand" js_class="print_demand" >
<field name="model_id"/> <field name="model_id"/>
<field name="filename_url"/> <field name="filename_url"/>
<field name="type"/> <field name="type"/>
<field name="machining_drawings" attrs="{'column_invisible': True }"/> <field name="machining_drawings" attrs="{'column_invisible': True }"/>
<field name="cnc_worksheet" attrs="{'column_invisible': True }"/> <field name="cnc_worksheet" attrs="{'column_invisible': True }" />
<field name="status"/> <field name="status"/>
</tree> </tree>
</field> </field>

View File

@@ -437,7 +437,7 @@ class Sf_Dashboard_Connect(http.Controller):
('state', 'in', ['ready', 'progress', 'done']) ('state', 'in', ['ready', 'progress', 'done'])
]) ])
plan_data_total_counts = sum(plan_data_total.mapped('qty_production')) plan_data_total_counts = sum(plan_data_total.mapped('qty_produced'))
# # 工单完成量 # # 工单完成量
# plan_data_finish_counts = plan_obj.search_count( # plan_data_finish_counts = plan_obj.search_count(
@@ -489,7 +489,7 @@ class Sf_Dashboard_Connect(http.Controller):
# 工单返工数量 # 工单返工数量
plan_data_rework = work_order_obj.search(work_order_domain + [ plan_data_rework = work_order_obj.search(plan_domain + [
('state', 'in', ['rework']) ('state', 'in', ['rework'])
]) ])
@@ -717,7 +717,7 @@ class Sf_Dashboard_Connect(http.Controller):
# 使用小时和分钟作为键,确保每个小时的数据有独立的键 # 使用小时和分钟作为键,确保每个小时的数据有独立的键
key = start_time.strftime('%H:%M:%S') # 只取小时:分钟:秒作为键 key = start_time.strftime('%H:%M:%S') # 只取小时:分钟:秒作为键
# time_count_dict[key] = len(orders) # time_count_dict[key] = len(orders)
plan_count_dict[key] = sum(interval_orders.mapped('qty_production')) plan_count_dict[key] = sum(interval_orders.mapped('qty_produced'))
# order_counts.append() # order_counts.append()
res['data'][line] = { res['data'][line] = {
@@ -857,6 +857,7 @@ class Sf_Dashboard_Connect(http.Controller):
:param kw: :param kw:
:return: :return:
""" """
request.env['stock.warehouse'].browse(request.env.company.id).pbm_loc_id
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []} # res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
res = {'status': 1, 'message': '成功', 'data': {}} res = {'status': 1, 'message': '成功', 'data': {}}
plan_obj = request.env['sf.production.plan'].sudo() plan_obj = request.env['sf.production.plan'].sudo()

View File

@@ -201,34 +201,10 @@
</div> </div>
</div> --> </div> -->
<div class="footer">
<div style="border-top: 2px solid black;"></div>
<div>
<p>o_index: <t t-esc="o_index"/></p>
<p>len(docs): <t t-esc="len(docs)"/></p>
</div>
<t t-if="o_index + 1 == len(docs)">
<div class="row">
<div class="col-6">
<p>售后服务: <span t-field="o.company_id.phone"/></p>
<p>公司名称: <span t-field="o.company_id.name"/></p>
<p>加工工厂: <span t-field="o.company_id.factory_name"/></p>
</div>
<div class="col-6">
<p>公司网址: <span t-field="o.company_id.website"/></p>
<p>公司邮箱: <span t-field="o.company_id.email"/></p>
</div>
</div>
</t>
<div class="text-center">
<span><span class="page"/> 页/共 <span class="topage"/></span>
</div>
</div>
<!-- 页脚固定在底部 --> <!-- 页脚固定在底部 -->
<!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> -->
<!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> --> <t t-call="sf_quality.report_quality_footer"/>
<!-- <t t-call="sf_quality.report_quality_footer"/>--> <!-- </div> -->
<!-- </div> -->
</div> </div>
</t> </t>
</t> </t>
@@ -353,11 +329,9 @@
</div> --> </div> -->
<!-- 页脚固定在底部 --> <!-- 页脚固定在底部 -->
<!-- <t t-if="loop.index == len(docs) - 1">--> <!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> -->
<!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> --> <t t-call="sf_quality.html_report_quality_footer"/>
<t t-call="sf_quality.html_report_quality_footer"/> <!-- </div> -->
<!-- </div> -->
<!-- </t>-->
</div> </div>
</t> </t>
</t> </t>