fix: bridge SKU→policy mapping for ARTICOLE_TERTI mapped articles
codmat_policy_map had CODMAT keys only, but build_articles_json looks up by GoMag SKU — mapped articles like FRSETP250 never got per-article id_pol, causing Oracle to use default sales policy and fail when price exists only in production policy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -499,6 +499,17 @@ async def run_sync(id_pol: int = None, id_sectie: int = None, run_id: str = None
|
||||
conn, mapped_id_map, cota_tva=cota_tva
|
||||
)
|
||||
|
||||
# Add SKU → policy entries for mapped articles (1:1 and kits)
|
||||
# codmat_policy_map has CODMAT keys, but build_articles_json
|
||||
# looks up by GoMag SKU — bridge the gap here
|
||||
if codmat_policy_map and mapped_codmat_data:
|
||||
for sku, entries in mapped_codmat_data.items():
|
||||
if len(entries) == 1:
|
||||
# 1:1 mapping: SKU inherits the CODMAT's policy
|
||||
codmat = entries[0]["codmat"]
|
||||
if codmat in codmat_policy_map:
|
||||
codmat_policy_map[sku] = codmat_policy_map[codmat]
|
||||
|
||||
# Pass codmat_policy_map to import via app_settings
|
||||
if codmat_policy_map:
|
||||
app_settings["_codmat_policy_map"] = codmat_policy_map
|
||||
|
||||
Reference in New Issue
Block a user