콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

Hey Team

I'm just wondering if it is possible to update a product to track inventory after it has been previously sold as a consumable item.

We just done our stock take so we now have up-to-date numbers on all the items we have in stock.

But since we have already sold some of these products when we want to change a consumable product to a tracked product that comes up with the error that we cannot change it after a sale has been completed.

Invalid Operation

You can not change the inventory tracking of a product that was already used.

I assume the most tidy/simple method here is to duplicate the product and then archive the old one?


Thanks



아바타
취소

i am encountering the same can someone reply please thanks


베스트 답변

hello Etter 

my suggestion is to Duplicate the Product Archive of the Old One and change the product type from Consumable to Storable Product.

아바타
취소
베스트 답변

Hi

This is a process you can use to change product type. I got it from Thuy Ngoc, so all credits to him.

Step 1: Go to menu Settings => Technical => Actions => Server Actions.
Step 2: Create an action with the following information:
+ Name: Update product type
+ Model: Server Action
+ Action To Do: Execute Python Code
+ Python Code: env.cr.execute("""Update product_template set detailed_type = 'consu' where id = id_of_product_template """)
Step 3: Click Run

To get the ID of your product, make an export with that field. Replace "id_of_product_template" in the code with your specific number.

If you want the change product type to storable product, replace "consu" with "product".

아바타
취소

kindly suggest the exact way to write the code.

Hi Nourhan
I think you didn't read my post well enough :)

Here is the code again:

env.cr.execute("""Update product_template set detailed_type = 'consu' where id = id_of_product_template """)

Replace "id_of_product_template" in the code with the ID of your specific product.

베스트 답변

hi Stefan,

the answer you received from Rakesh is good and easy.
I f you also need to sum the sell statistics, you can try to manage them by labels on that products. Another possibility is to export all data of consumabile item, and import them in the storable one, but export/import is always more complicated option

아바타
취소
베스트 답변
Below is a refined code for the above. Execute it as server action. Remember the product need to be of type 'consu' if you're in odoo18 
# Update both type and is_storable
env.cr.execute("""
    UPDATE product_template
    SET is_storable = true
    WHERE type = 'consu'
""")

updated_count = env.cr.rowcount
env.cr.commit()

# Show notification
action = {
    'type': 'ir.actions.client',
    'tag': 'display_notification',
    'params': {
        'title': 'Update Complete',
        'message': f'Updated {updated_count} products type and storable status',
        'type': 'success',
        'sticky': False,
    }
}
아바타
취소
베스트 답변

From database edit tables product template field type

아바타
취소
관련 게시물 답글 화면 활동
2
6월 25
2301
3
9월 25
5252
0
11월 24
1094
2
11월 23
2823
7
7월 24
8490