0
votes

I am working on Odoo 8.0 I have our Sales and Ordering system configured with 5473 products. I have also configured our suppliers and they are linked to the appropriate products. I have verified the suppliers have the address field entered and we are almost ready to go.

However to enable automatic procurement for RFQ (Request For Quotation) I have found out that on any product under the procurement tab there are route_ids. One is Buy and one is Make to Order. I have been told in order for RFQ's to be kicked off automatically that the Buy and Make to Order checkboxes need to be enabled.

I have went through the models, fields and database and cannot seem to find the table where these to checkboxes are set. Can anyone help me out with which table I can dump and modify then reimport to automatically set both checkbox fields?

1

1 Answers

0
votes

To find out stuff like this quickly, Odoo has a "trick": if you click in the upper right on your username and "About Odoo", you can click "Activate Developer Mode". Now, when you go to the view of a product, click "Edit", and hover over a field label, it will show information about the field.

In this case, hovering over "Routes" tells us that this is a "many2many" field called "route_ids", bringing the object "product.product" in relation with "stock_location_route".

Usually the corresponding database table would be called something like "stock_location_route_product_rel", but in this case we are not that lucky. However the Odoo source code (addons/stock/product.py) gives us the definition of this relation:

'route_ids': fields.many2many('stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes', domain="[('product_selectable', '=', True)]",
                                help="Depending on the modules installed, this will allow you to define the route of the product: whether it will be bought, manufactured, MTO/MTS,..."),

Which tells us that the table name is "stock_route_product".

The following query will give you the checkboxes set on a certain subset of products,

select pt.name, slr.name
from stock_route_product srp
inner join product_template pt on srp.product_id = pt.id
inner join stock_location_route slr on srp.route_id = slr.id
where pt.name like '%keyword%'
and slr.name in ('Make To Order', 'Buy');

Or for all products,

select pt.name, slr.name
from stock_route_product srp
inner join product_template pt on srp.product_id = pt.id
inner join stock_location_route slr on srp.route_id = slr.id
where slr.name in ('Make To Order', 'Buy');

Actually, following query is even more insightful, here you will see the missing checks displayed as NULL,

select pt_id, slr_id, srp.route_id, srp.product_id
from (
  select pt.id as pt_id, slr.id as slr_id
  from stock_location_route slr, product_template pt
  where slr.name in ('Make To Order', 'Buy')
) q
left join stock_route_product srp 
  on srp.route_id = q.slr_id 
  and srp.product_id = q.pt_id

Now then this is the list of missing records you need to insert in stock_route_product (using INSERT or import/export):

select pt_id, slr_id
from (
  select pt.id as pt_id, slr.id as slr_id
  from stock_location_route slr, product_template pt
  where slr.name in ('Make To Order', 'Buy')
) q
left join stock_route_product srp
  on srp.route_id = q.slr_id
  and srp.product_id = q.pt_id
where srp.route_id is null