From 2286f00b6a3191dc22d118f8db15952962d905be Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Wed, 12 Jan 2011 16:54:15 +0530 Subject: [PATCH 1/4] [FIX]:In procurement Fields in groupby must appear in the list of fields to read bzr revid: ksa@tinyerp.co.in-20110112112415-e06a92pte6ipqneg --- addons/procurement/procurement_view.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml index 618e8d9794c..c40338de9fb 100644 --- a/addons/procurement/procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -30,6 +30,7 @@ tree + @@ -246,8 +247,8 @@ From 1d0c02ed6038de77ea6de5f7dd074a04709d168d Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Thu, 13 Jan 2011 14:58:33 +0530 Subject: [PATCH 2/4] [ADD]: Add yml for procurement module bzr revid: ksa@tinyerp.co.in-20110113092833-nparci4p5qpk6o1o --- addons/procurement/__openerp__.py | 1 + addons/procurement/test/test_procurement.yml | 54 ++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 addons/procurement/test/test_procurement.yml diff --git a/addons/procurement/__openerp__.py b/addons/procurement/__openerp__.py index 1cdc1462f89..684c5ad2009 100644 --- a/addons/procurement/__openerp__.py +++ b/addons/procurement/__openerp__.py @@ -46,6 +46,7 @@ 'board_mrp_procurement_view.xml', ], 'demo_xml': ['stock_orderpoint.xml'], + 'test': ['test/test_procurement.yml'], 'installable': True, 'active': False, 'certificate': '', diff --git a/addons/procurement/test/test_procurement.yml b/addons/procurement/test/test_procurement.yml new file mode 100644 index 00000000000..05b5b4cf2ed --- /dev/null +++ b/addons/procurement/test/test_procurement.yml @@ -0,0 +1,54 @@ +- + In order to test the Procurement flow,I start by creating a new product 'Orange' +- + !record {model: product.product, id: product_product_orange0}: + categ_id: product.cat1 + name: Orange + procure_method: make_to_stock + seller_ids: + - delay: 1 + name: base.res_partner_asus + min_qty: 1.0 + product_uom: product.product_uom_kgm + supply_method: buy + type: product + uom_id: product.product_uom_kgm + uom_po_id: product.product_uom_kgm + property_stock_inventory: stock.location_inventory + property_stock_procurement: stock.location_procurement + property_stock_production: stock.location_production +- + I define Minimum stock rules for my stockable product "Orange". +- + !record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}: + company_id: base.main_company + location_id: stock.stock_location_stock + logic: max + name: OP/00002 + product_id: product_product_orange0 + product_max_qty: 10.0 + product_min_qty: 5.0 + product_uom: product.product_uom_kgm + qty_multiple: 1 + warehouse_id: stock.warehouse0 +- + The scheduler runs. +- + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order + search: "[]" +- + Apply Request for Procurement clicking on "Procurement Request". +- + !record {model: make.procurement, id: procurement_order_orange0}: + product_id: product_product_orange0 + qty: 10.0 + date_planned: '2010-04-20' + uom_id: product.product_uom_kgm + warehouse_id: stock.warehouse0 +- + Create procurement order for selected product. +- + !python {model: make.procurement}: | + ids = self.search(cr, uid, [('product_id','in',[ref('product_product_orange0')])]) + self.make_procurement(cr, uid, ids, context) From 46a066686d8b47b57021935e39a23c82e968713b Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Mon, 17 Jan 2011 12:08:18 +0530 Subject: [PATCH 3/4] [IMP]: Improvement for bug-701017 bzr revid: ksa@tinyerp.co.in-20110117063818-r8w887avp7lp34h0 --- addons/mrp/mrp.py | 6 +++++- addons/mrp/product.py | 23 +++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index a260efc8e36..46bca445692 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -342,7 +342,11 @@ class mrp_bom(osv.osv): if context is None: context = {} bom_data = self.read(cr, uid, id, [], context=context) - default.update({'name': bom_data['name'] + ' ' + _('Copy'), 'bom_id':False}) + default.update({'name': bom_data['name'] + ' ' + _('Copy')}) + if context.get('copy_from_product',False): + #Check for the BOM LINES(child BoM) + if not bom_data['bom_lines']: + return 0 return super(mrp_bom, self).copy_data(cr, uid, id, default, context=context) mrp_bom() diff --git a/addons/mrp/product.py b/addons/mrp/product.py index bb9bc27625f..48eef80dcf3 100644 --- a/addons/mrp/product.py +++ b/addons/mrp/product.py @@ -24,31 +24,31 @@ from tools.translate import _ class product_product(osv.osv): - _inherit = "product.product" + _inherit = "product.product" def get_product_accounts(self, cr, uid, product_id, context=None): """ To get the stock input account, stock output account and stock journal related to product. - @param product_id: product id + @param product_id: product id @return: dictionary which contains information regarding stock input account, stock output account and stock journal """ product_obj = self.pool.get('product.product').browse(cr, uid, product_id, False) res = super(product_product,self).get_product_accounts(cr, uid, product_id, context=context) - stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False + stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False if not stock_input_acc: stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False - + stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False if not stock_output_acc: stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False - + res.update({'stock_account_input': stock_input_acc}) res.update({'stock_account_output': stock_output_acc}) - res.update({'stock_journal': journal_id}) - + res.update({'stock_journal': journal_id}) + return res - + _columns = { "bom_ids": fields.one2many('mrp.bom', 'product_id','Bill of Materials'), @@ -90,4 +90,11 @@ class product_product(osv.osv): for bom in bom_obj.browse(cr, uid, bom_ids, context=context): _compute_price(bom) + def copy(self, cr, uid, id, default=None, context=None): + if context is None: + context = {} + context.update({'copy_from_product': True}) + return super(product_product, self).copy(cr, uid, id, default=default, + context=context) + product_product() From da1ea6e05fc63936cb0fa3558c8735a83f659337 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Mon, 17 Jan 2011 18:43:39 +0530 Subject: [PATCH 4/4] [FIX]:regression - cannot specify dedicated inventory accounts for periodical inventory or production lp bug: https://launchpad.net/bugs/697273 fixed bzr revid: ksa@tinyerp.co.in-20110117131339-i57z5w9plal1vw9c --- addons/stock/stock.py | 16 +++++++++++++--- addons/stock/stock_view.xml | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 68b6edb5f8d..4e9a8a2099b 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -208,6 +208,8 @@ class stock_location(osv.osv): 'stock_virtual_value': fields.function(_product_value, method=True, type='float', string='Virtual Stock Value', multi="stock", digits_compute=dp.get_precision('Account')), 'company_id': fields.many2one('res.company', 'Company', select=1, help='Let this field empty if this location is shared between all companies'), 'scrap_location': fields.boolean('Scrap Location', help='Check this box to allow using this location to put scrapped/damaged goods.'), + 'valuation_in_account_id': fields.many2one('account.account', 'Valuation In Account',domain = [('type','=','regular')], help='when there is an incoming move for the location, we have to use this field of that location instead of account from product/product category.'), + 'valuation_out_account_id': fields.many2one('account.account', 'Valuation Out Account',domain = [('type','=','regular')], help='when there is an outgoing move for the location, we have to use this field of that location instead of account from product/product category.'), } _defaults = { 'active': True, @@ -1976,8 +1978,16 @@ class stock_move(osv.osv): """ product_obj=self.pool.get('product.product') accounts = product_obj.get_product_accounts(cr, uid, move.product_id.id, context) - acc_src = accounts['stock_account_input'] - acc_dest = accounts['stock_account_output'] + if move.location_id.valuation_out_account_id: + acc_src = move.location_id.valuation_out_account_id.id + else: + acc_src = accounts['stock_account_input'] + + if move.location_dest_id.valuation_in_account_id: + acc_dest = move.location_dest_id.valuation_in_account_id.id + else: + acc_dest = accounts['stock_account_output'] + acc_variation = accounts.get('property_stock_variation', False) journal_id = accounts['stock_journal'] @@ -2585,7 +2595,7 @@ class stock_inventory(osv.osv): account_move_data_l = account_move_obj.read(cr, uid, account_move_ids, ['state'], context=context) for account_move in account_move_data_l: if account_move['state'] == 'posted': - raise osv.except_osv(_('UserError'), + raise osv.except_osv(_('UserError'), _('You can not cancel inventory which has any account move with posted state.')) account_move_obj.unlink(cr, uid, [account_move['id']], context=context) self.write(cr, uid, [inv.id], {'state': 'cancel'}, context=context) diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 85c1231b75a..aede7188c02 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -410,7 +410,7 @@ {'full':'1',"search_default_available":1} This is the list of all the production lots (serial numbers) you recorded. When you select a lot, you can get the upstream or downstream traceability of the products contained in lot. By default, the list is filtred on the serial numbers that are available in your warehouse but you can uncheck the 'Available' button to get all the lots you produced, received or delivered to customers. - @@ -493,6 +493,8 @@ + +