distil/odoo
Lingxian Kong ef277a2f07 Add check to avoid duplicate quotations in Odoo
- Add the check function by using 'date_order' field in Odoo.
- Fix the bug that we use the wrong field name 'order_date'.

Change-Id: I001c799e131a25138df28db3f6ae4ef7dfc89674
2016-02-24 11:26:37 +13:00
..
.gitignore Sync distil project structure with internal one 2016-02-10 14:56:13 +13:00
glue.ini.example Sync distil project structure with internal one 2016-02-10 14:56:13 +13:00
odoo-glue.py Add check to avoid duplicate quotations in Odoo 2016-02-24 11:26:37 +13:00
odoo-products-snapshot.py Sync distil project structure with internal one 2016-02-10 14:56:13 +13:00
README Sync distil project structure with internal one 2016-02-10 14:56:13 +13:00
requirements.txt Add retry mechanism for build_sales_order 2016-02-24 10:05:16 +13:00

odoo-glue
=========

This script includes the following 2 functions:

- Pulls usage data from distil for a tenant, and creates a matching quote in OpenERP/Odoo.
- Updates quotation status according to some criteria.

dependencies
------------

- odoorpc==0.4.2
- distilclient==0.4.2	(from this source tree, or deb from Catalyst repo)
- OpenStack credentials in environment for an admin user.
- glue.ini adapted to your environment (see glue.ini.example)

Genertate quotations for all tenants
------------------------------------

**IMPORTANT: MAKE SURE DISTIL'S USAGE COLLECTION IS UP TO DATE.**

Replace the --start, --end and logfile names appropriately:
`start` should be the first instant inside the billing period (midnight UTC on the first day).
`end` should be the first instant after the end of the billing period (midnight UTC on the first day after the end)
The output will be useful in case anything goes wrong. An example::

    $ ./odoo-glue.py quote --start 2014-09-01T00:00:00 --end 2014-10-01T00:00:00 1>~/distil-odoo-201409 2>&1

Update quotation status
-----------------------

Updates status of some quotations from draft to new status(can be chosen from manual/cancel/draft) according to order_id, company name and/or tenant_id, please see the following examples.

Update status of all the quotations of a specified tenant to manual::

    $ ./odoo-glue.py --debug update-quote -s manual -t <tenant_id>

Update status of a specified quotation to cancel::

    $ ./odoo-glue.py --debug update-quote -s cancel --id <order_id>

*NOTE*: The ID param is NOT quotation number(something like SO1955), updating quotation status using ID is just for recovery in case of executing this command erroneously. You can find order ID in log.

Please refer to more detailed description about this command by running::

    $ ./odoo-glue.py help update-quote