1

I'm new to Odoo and I'm building a python backend which should create products and price lists in Odoo through API calls. Everything went fairly easy until I tried programatically setting a Price List as archived.

From my research I found that the archive setting is directly linked to the 'Active' property of the Price List. Unfortunately, my code isn't working, and the Price List is still active and unarchived.

price_id = models.execute_kw(db, uid, password, 'product.pricelist', 'create', [{

'name': "Test List", 

'currency_id': "1",

    'active':'False'

}])

UPDATED

I cannot seem to archive a product. The active property is updated to False, but the product still appears in the product list and not in the archived product list.

models.execute_kw(db, uid, password, 'product.product', 'write', [[prod_id], {
    'name': "Testing Apple MacBook 111", 'active':False, 'is_product_variant':False
}])
Macaret
  • 797
  • 9
  • 33
  • 1
    You're using a string as value for `active`, but it should be a boolean: `'active': False`. A non empty string is True, so you won't deactivate the pricelist. (`boolean('False') == True`) – CZoellner Jan 18 '21 at 10:50
  • Thank you! I've update my question. Do you have any ideea why product archiving doesn't work. – Macaret Jun 25 '21 at 12:23

1 Answers1

1

There are two issues:

  1. You have called create method means every time you run API, it will create a new pricelist. - Use write method.

  2. 'active': False - see comment by @CZoellner

Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
  • Thanks for your help! But whatever I do I cannot archive a product. The active property is updated to False but the product doesn't appear inside the archived list of products. I've updated my question. – Macaret Jun 25 '21 at 12:21