[英]How to zero out inventory in OpenERP?
I have 1500+ products and 2000+ locations. 我有1500多种产品和2000多个地点。 I have updated the inventory with update inventory wizard in products and also I have processed some delivery orders and internal moves.
我已使用产品中的更新清单向导更新了库存,并且我已处理了一些交货订单和内部移动。 Now I want to zero out the inventory.
现在我想把库存归零。 I made a script to zero out the inventory.
我制作了一个脚本来清理库存。 The problem is that it takes too much time to update the inventory to zero as each product can be any where in 2000 locations.
问题在于,将库存更新为零需要花费太多时间,因为每个产品可以是2000个位置的任何产品。 Is there any OpenERP function which will return all locations that a product is available?
是否有任何OpenERP功能可以返回产品可用的所有位置?
To keep the data model simple ( KISS ) and avoid issues with cache invalidation, OpenERP does not keep a cache of the current inventory of products in each location. 为了简化数据模型( KISS )并避免缓存失效问题,OpenERP不会在每个位置保留当前产品库存的缓存。 This information is obtained by computing the double-entry balance of stock transactions entering and leaving each stock location.
该信息是通过计算进入和离开每个股票仓位的股票交易的复式余额来获得的。 This is very similar to the double-entry bookkeeping used for financial accounting.
这与用于财务会计的复式记账非常相似。
There are several ways to obtain this information programmatically using the OpenERP API, by querying the stock.move
model for each stock.location
. 有几种方法可以使用OpenERP API以编程方式获取此信息,方法是查询每个
stock.location
的stock.move
模型。 For starters you can have a look at the stock.fill.inventory
wizard class of the stock
module, which has an option to fill in the physical inventory with zeroed lines. 对于初学者,您可以查看
stock
模块的stock.fill.inventory
向导类 , 该类可以选择用零线填充物理库存。 The product.product
model also has a get_product_available
method that returns this information for a given set of products. product.product
模型还有一个get_product_available
方法,该方法为给定的一组产品返回此信息。
Then you can create the appropriate counterpart stock.move
entries to achieve a balance of 0 in each location, in a way that is very similar to what the standard stock.fill.inventory
wizard does. 然后,您可以创建相应的对应
stock.move
条目,以在每个位置实现0的平衡,其方式与标准stock.fill.inventory
向导的方式非常相似。
Alternatively, if you simply want to erase the whole inventory along with its history as a one-shot operation, there is a fast and dirty way. 或者,如果您只想将整个库存及其历史作为一次性操作删除,则会有一种快速而肮脏的方式。 You can do it using a direct SQL query on the database (eg using the
psql
command-line tool or pgadmin), simply wiping out the stock_move
and stock_picking
tables. 您可以使用数据库上的直接SQL查询(例如,使用
psql
命令行工具或pgadmin)来执行此操作,只需擦除stock_move
和stock_picking
表即可。
DON'T do this on a production database with real data! 不要在具有真实数据的生产数据库上执行此操作! This will WIPE OUT a part of your database
这将WIPE OUT成为数据库的一部分
Assuming you have installed the Sale Management module ( sale
) and are using OpenERP 6.1, the following should work to erase the history of stock transactions and the documents their originated from: 假设您已安装销售管理模块(
sale
)并使用OpenERP 6.1,则以下内容应有效删除库存交易的历史记录及其来源的文件:
Oh, and make a backup first! 哦,先做好备份 !
DELETE FROM stock_move; DELETE FROM mrp_production; DELETE FROM stock_picking; DELETE FROM sale_order; DELETE FROM procurement_order;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.