所有产品的 Odoo 定制配置 [英] Odoo Make to Order Configuration for all products
问题描述
我正在开发 Odoo 8.0 我的销售和订购系统配置了 5473 种产品.我还配置了我们的供应商,并将它们链接到相应的产品.我已经确认供应商输入了地址字段,我们几乎准备好了.
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.
但是,要为 RFQ(请求报价)启用自动采购,我发现在采购选项卡下的任何产品上都有 route_id.一种是购买,一种是按订单生产.有人告诉我,为了让 RFQ 自动启动,需要启用 Buy 和 Make to Order 复选框.
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?
推荐答案
为了快速找到这样的东西,Odoo 有一个技巧":如果你点击右上角的用户名和关于 Odoo",你可以点击激活开发者模式".现在,当您转到产品视图时,单击编辑",并将鼠标悬停在字段标签上,它将显示有关该字段的信息.
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.
在这种情况下,将鼠标悬停在Routes"上告诉我们这是一个名为route_ids"的many2many"字段,将对象product.product"与stock_location_route"关联起来.
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".
通常相应的数据库表会被称为stock_location_route_product_rel",但在这种情况下,我们就没有那么幸运了.但是 Odoo 源代码(addons/stock/product.py) 给了我们这个关系的定义:
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,..."),
告诉我们表名是stock_route_product".
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');
或者对于所有产品,
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');
实际上,下面的查询更有见地,在这里你会看到缺失的检查显示为NULL,
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
现在这是您需要在 stock_route_product 中插入的缺失记录列表(使用 INSERT 或导入/导出):
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
这篇关于所有产品的 Odoo 定制配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!