/**
* WPML compatibility functions
*
* @global array $duplicated_posts Array to store the posts being duplicated.
*
* @package Yoast\WP\Duplicate_Post
* @since 3.2
*/
add_action( 'admin_init', 'duplicate_post_wpml_init' );
/**
* Add handlers for WPML compatibility.
*/
function duplicate_post_wpml_init() {
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
add_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10, 3 );
add_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10, 3 );
add_action( 'shutdown', 'duplicate_wpml_string_packages', 11 );
}
}
global $duplicated_posts;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: Renaming a global variable is a BC break.
$duplicated_posts = [];
/**
* Copy post translations.
*
* @global SitePress $sitepress Instance of the Main WPML class.
* @global array $duplicated_posts Array of duplicated posts.
*
* @param int $post_id ID of the copy.
* @param WP_Post $post Original post object.
* @param string $status Status of the new post.
*/
function duplicate_post_wpml_copy_translations( $post_id, $post, $status = '' ) {
global $sitepress;
global $duplicated_posts;
remove_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10 );
remove_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10 );
$current_language = $sitepress->get_current_language();
$trid = $sitepress->get_element_trid( $post->ID );
if ( ! empty( $trid ) ) {
$translations = $sitepress->get_element_translations( $trid );
$new_trid = $sitepress->get_element_trid( $post_id );
foreach ( $translations as $code => $details ) {
if ( $code !== $current_language ) {
if ( $details->element_id ) {
$translation = get_post( $details->element_id );
if ( ! $translation ) {
continue;
}
$new_post_id = duplicate_post_create_duplicate( $translation, $status );
if ( ! is_wp_error( $new_post_id ) ) {
$sitepress->set_element_language_details(
$new_post_id,
'post_' . $translation->post_type,
$new_trid,
$code,
$current_language
);
}
}
}
}
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: see above.
$duplicated_posts[ $post->ID ] = $post_id;
}
}
/**
* Duplicate string packages.
*
* @global array() $duplicated_posts Array of duplicated posts.
*/
function duplicate_wpml_string_packages() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: renaming the function would be a BC-break.
global $duplicated_posts;
foreach ( $duplicated_posts as $original_post_id => $duplicate_post_id ) {
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter.
$original_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $original_post_id );
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter.
$new_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $duplicate_post_id );
if ( is_array( $original_string_packages ) ) {
foreach ( $original_string_packages as $original_string_package ) {
$translated_original_strings = $original_string_package->get_translated_strings( [] );
foreach ( $new_string_packages as $new_string_package ) {
$cache = new WPML_WP_Cache( 'WPML_Package' );
$cache->flush_group_cache();
$new_strings = $new_string_package->get_package_strings();
foreach ( $new_strings as $new_string ) {
if ( isset( $translated_original_strings[ $new_string->name ] ) ) {
foreach ( $translated_original_strings[ $new_string->name ] as $language => $translated_string ) {
do_action(
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter.
'wpml_add_string_translation',
$new_string->id,
$language,
$translated_string['value'],
$translated_string['status']
);
}
}
}
}
}
}
}
}
Odoo MRP Flexible Consumption – Raqqa
内容をスキップ
Odoo MRP Flexible Consumption
➤ BOMで定義された材料数と、実際に使用した数が異なる場合に対応できる設定と運用
✅ 設定方法:柔軟な消費の許容
- 製造 > 製品 > BOM(部品表) を開く
- 「その他の情報(Other Info)」タブへ
- [✓] 消費誤差を許容(Allow Flexible Consumption) にチェック
→ Work Orderで予定と異なる数の材料を入力できるようになる
🧪 使い方:MOでの部品使用数変更の流れ
- 製造 > MO を作成
- 自動入力された部品(BOM)数を編集
例:卵を4個 → 5個に変更
- 「Produce All」ボタンを押す
→ ⚠️ 予定と違う数量の警告が出るが、続ける場合は「Confirm」を押す
- MOが変更後の部品数で正しく完了処理される
🧭 応用機能:品質管理ポイント(QCP)との組み合わせ
● QCPの設定(例:卵のチェック)
- 品質 > 品質コントロール > Control Points を開く
- 新規作成:
- Operation:MIX(対象の作業)
- 製品:チーズスフレ
- 検査タイプ:例えば「数値入力(Measure)」や「チェックリスト」
- → 作業中に作業者が卵の数を入力/確認する作業が挿入される
🔍 QCPを設定することによって起こること
| 項目 | 内容 |
|---|
| 作業者が作業センターのワークオーダー上で検査項目に回答 | 例:卵の数を目視・確認し、数を入力 or OK/NG |
| Validate を押すことで検査完了(ログ記録) | → MO上の部品数量が調整された状態で「Confirm Production」が有効になる |
| 柔軟な消費設定と併用することで、予定外の数でも記録・生産継続が可能に | 例:現場で実際に使った数が反映された生産履歴が残る |
✅ メリットまとめ
| メリット | 説明 |
|---|
| 現場実態に即した生産実績記録 | 材料のばらつき(例:サイズ、破損)に柔軟対応 |
| 在庫の正確な消費管理 | 実際に使用した数量が記録され、在庫差異が生まれにくい |
| 品質検査と紐づけて原因分析が可能 | 「多く使った」「品質不良で交換した」等がトレースできる |
| 将来のBOM見直しにもつながるデータ | 実際に必要だった数が見える化されることで、標準BOMの改善が可能に |
🎯 結論
Flexible Consumptionは、製造現場での実態に即した材料消費の調整を可能にする機能です。
品質管理ポイント(QCP)と併用することで、現場での判断・記録・調整がワークフローに組み込まれ、正確かつ柔軟な生産運用が可能になります。
コメントを残す