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
}])
There are two issues:
You have called create method means every time you run API, it will create a new pricelist. - Use write method.
'active': False - see comment by #CZoellner
Related
I'm trying to change the state of a created invoice from 'draft' to 'posted' using the Web APIs (Python) by referring to this documentation : https://www.odoo.com/documentation/13.0/webservices/odoo.html
I'm updating the invoice as follows :
def makeInvoicePosted(invoice_id):
invoice_ids = []
invoice_ids.append(invoice_id)
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
print(common)
uid = common.authenticate(db, username, password, {})
print("makeInvoicePosted : Odoo Admin User Id : ", uid)
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
models.execute_kw(db, uid, password, 'account.move', 'write', [[invoice_id], {'state':"posted"}])
But I'm getting this error : odoo.exceptions.ValidationError: ('Posted journal entry must have an unique sequence number per company.', None)\n'
What could be causing this ? is there something missing in the request?
Thanks in advance!
I recommend to use Odoo's workflow and business logic here by calling post instead of directly writing the state.
models.execute_kw(db, uid, password, 'account.move', 'post', [[invoice_id],])
Why: because there are a lot of checks and also a lot of things done in this method, you could miss or just do wrong (invoices are very complex). You probably will find some mistakes in your calls right before doing the post, because of the checks in it.
I used the Shopify API to create an order using my product's variantID.
For some reason, line_items in orders created using the API always have "vendor":"null". Whereas orders for the same variant created via the store returns the correct vendor.
Am I doing anything wrong?
URL: https://xxyy.myshopify.com/admin/orders.json
{ "order": {
"email": "ken#xxyy.com",
"fulfillment_status": "unfulfilled" ,
"send_receipt": true,
"send_fulfillment_receipt": false,
"line_items": [{
"variant_id": 3866750123,
"quantity": 1
}]
}
}
I get that sometimes too and it is truly crappy. If you create a line item using the API it seems you need to provide not only the product and variant ID, but also the vendor, as even if it exists in the product, that does not get picked up in the order creation process. A lot of Apps screw this up. Which screws up other Apps expecting good orders. And a it seems to me a good order should have the product vendor field set.
I am trying to update some information on my odoo product with PHP and xmlrpc.
This is my code for update product name.
$models->execute_kw($db, $uid, $password, 'product.product', 'write',
array(array(5), array('name'=>"Newer product 3",'type'=>"consu")));
Now I want to change a "Quantity On Hand" field so I trying this code :
$models->execute_kw($db, $uid, $password, 'product.product', 'write',
array(array(5), array('name'=>"Newer product 3",'type'=>"consu",'qty_available'=>'7')));
but it doesn't work, anyone got any ideas how to fix it?
Thank you.
The field qty_available is readonly.
On odoo10 you can use the following operation, python:
product = models.execute_kw(db, uid, password, 'product.product', 'search', [[('default_code', '=', sku)]])
change_id = models.execute_kw(db, uid, password, 'stock.change.product.qty', 'create', [{
'product_id': product[0],
'location_id': 15,
'new_quantity': 20,
}])
models.execute_kw(db, uid, password, 'stock.change.product.qty', 'change_product_qty', [change_id])
Since the field qty_available is read only there is no way to update it.
To update it you'll need to create a stock move
First make sure that the field qty_available really exists in the model. You can check the fields in the model from (via browser)
settings --> database structure --> models
If not make sure sale, stock, product modules are properly installed. By the way in my odoo repository (i.e odoo 9 stable) I even can't see qty_available field in the model product.product . But I can see it in the openerp v7. Probably this field is either removed or the field is inheriting some other modules e.g sale_stock etc.
Hope this will solve you problem.
I would like to add additional information to a customers order after they have made the payment and landed on the confirmation page.
I sell products that have to be installed into the customers car. I would like to capture the customers car make model and year of registration (perferably after the order have been taken to not distract from the sale process).
I was hoping this could be done with the Bigcommerce API; where I could present the customer with a form they can fill in, after they have purchased, on the Order confirmation page and the data can get added to the customers order somehow.
Is this possible or would it be easier to caputre the car details in the cart or checkout?
BTW: not all products will come with vehicle installation.
Has anyone done anything similar using the Big Commerce API?
You can have the customer add it in as a note during check-out, this might be the most economical route.
Not as of today. The PUT request for orders does not allow the same fields as POST (order creation) - http://developer.bigcommerce.com/api/orders#put-ordersidjson
But, this is slated to be pushed in the coming weeks. Then you will be able to simply execute a PUT request on a captured order to update the "staff_notes" or "customer_message" field.
However, if you want to capture this during order creation via API, you can already do something like the following -
$createFields = array('customer_id'=>0, 'date_created' => 'Tue, 20 Nov 2012 00:00:00 +0000','status_id'=>1,'billing_address' => array( "first_name"=> "Trisha", "last_name"=> "McLaughlin", "company"=> "", "street_1"=> "12345 W Anderson Ln", "street_2"=> "", "city"=> "Austin", "state"=> "Texas", "zip"=> "78757", "country"=> "United States", "country_iso2"=> "US", "phone"=> "", "email"=> "elsie#example.com" ), "shipping_addresses" => array(), "external_source" => "POS", "products" => array(), "staff_notes" => "some notes here" );
print_r(Bigcommerce::createOrder($createFields));
I need to show the list of allowed values for the State field by Type for Portfolio items. The following code returns URL's instead of values? What am I doing wrong?
var typeCombobox= Ext.create('Ext.Container', {
items: [{
xtype: 'rallyattributecombobox',
model: 'PortfolioItem/FEATURE',
field: 'State',
multiSelect: true,
}],
});
The State attribute on Portfolio Items is an Object. Ideally the following syntax:
field: 'State.Name'
Would be workable - and the constructor would be smart enough to traverse down to the Name field on the Object. I've filed a Defect on this issue on this with Rally Engineering.
The best workaround in the meantime would probably be to use the Ext.form.field.ComboBox and populate the drop down values via a query for valid PI States. Thanks for bringing this to our attention!