From 953a15d2a7391370414462402198780b06d45243 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 15 Dec 2010 11:22:38 +0530 Subject: [PATCH 1/7] [FIX]: stock: Put proper function to change state of move to "Available" insted of using write method bzr revid: rpa@tinyerp.com-20101215055238-9ftnx82ftlqrg9kh --- addons/stock/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 5b14cc0dc67..33b43ce6060 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2057,7 +2057,7 @@ class stock_move(osv.osv): if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): - self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) + self.action_assign(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.picking_id: wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) if move.move_dest_id.auto_validate: From bf62673f06e2eb0d2b5a8c4fd591877972767a0b Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Thu, 16 Dec 2010 12:01:49 +0530 Subject: [PATCH 2/7] [FIX]: Production orders ignore chained location at destination lp bug: https://launchpad.net/bugs/535401 fixed bzr revid: rpa@tinyerp.com-20101216063149-kwcm7j41ppej3gm8 --- addons/mrp/mrp.py | 7 +------ addons/mrp/stock.py | 7 +++++++ addons/stock/stock.py | 29 ++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 951dfcda0df..37b857de42d 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -664,8 +664,6 @@ class mrp_production(osv.osv): """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id, context=context) - - final_product_todo = [] produced_qty = 0 if production_mode == 'consume_produce': @@ -706,10 +704,7 @@ class mrp_production(osv.osv): stock_mov_obj.action_consume(cr, uid, [raw_product.id], consumed_qty, production.location_src_id.id, context=context) if production_mode == 'consume_produce': - # To produce remaining qty of final product - vals = {'state':'confirmed'} - final_product_todo = [x.id for x in production.move_created_ids] - stock_mov_obj.write(cr, uid, final_product_todo, vals) + produced_products = {} for produced_product in production.move_created_ids2: if produced_product.scrapped: diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 8758bc09cd5..f8fad71fc58 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -140,6 +140,13 @@ class StockMove(osv.osv): res.append(new_move) return {} + def trigger_move_state(self, cr, uid, move, state, context=None): + new_moves = super(StockMove, self).trigger_move_state(cr, uid, move, state, context=context) + if state == 'confirm': + new_moves =[x.id for x in new_moves] + self.write(cr, uid, new_moves, {'production_id': False}, context=context) + return new_moves + StockMove() diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0d8249b1b12..8f741ccfae5 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1745,6 +1745,7 @@ class stock_move(osv.osv): result.setdefault(m.picking_id, []) result[m.picking_id].append( (m, dest) ) return result + def _create_chained_picking(self, cr, uid, pick_name,picking,ptype,move, context=None): res_obj = self.pool.get('res.company') picking_obj = self.pool.get('stock.picking') @@ -1762,6 +1763,7 @@ class stock_move(osv.osv): 'date': picking.date, }) return pick_id + def action_confirm(self, cr, uid, ids, context=None): """ Confirms stock move. @return: List of ids. @@ -1804,9 +1806,10 @@ class stock_move(osv.osv): if pickid: wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr) if new_moves: - create_chained_picking(self, cr, uid, new_moves, context) - create_chained_picking(self, cr, uid, moves, context) - return [] + new_moves += create_chained_picking(self, cr, uid, new_moves, context) + return new_moves + all_moves = create_chained_picking(self, cr, uid, moves, context) + return all_moves def action_assign(self, cr, uid, ids, *args): """ Changes state to confirmed or waiting. @@ -2059,8 +2062,7 @@ class stock_move(osv.osv): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): - self.write(cr, uid, [move.id], {'move_history_ids': [(4, move.move_dest_id.id)]}) - #cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) + self.write(cr, uid, [move.id], {'stock_move_history_ids': [(4, move.move_dest_id.id)]}, context=context) if move.move_dest_id.state in ('waiting', 'confirmed'): self.action_assign(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.picking_id: @@ -2248,7 +2250,18 @@ class stock_move(osv.osv): self.write(cr, uid, [current_move], update_val) return res - def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): + def trigger_move_state(self, cr, uid, move, state, context=None): + if isinstance(move, (int, long)): + move = [move] + res = [] + if state == 'confirm': + res = self.action_confirm(cr, uid, move, context=context) + if state == 'assigned': + self.check_assign(cr, uid, move, context=context) + self.force_assign(cr, uid, move, context=context) + return res + + def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): """ Consumed product with specific quatity from specific source location @param cr: the database cursor @param uid: the user id @@ -2276,12 +2289,12 @@ class stock_move(osv.osv): quantity = move.product_qty uos_qty = quantity / move_qty * move.product_uos_qty + state = (move.state in ('confirm', 'assign') and move.state) or 'confirm' if quantity_rest > 0: default_val = { 'product_qty': quantity, 'product_uos_qty': uos_qty, - 'state': move.state, 'location_id': location_id or move.location_id.id, } if move.product_id.track_production and location_id: @@ -2314,6 +2327,8 @@ class stock_move(osv.osv): for (id, name) in product_obj.name_get(cr, uid, [new_move.product_id.id]): message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(new_move.product_qty) + "' "+ _("quantity.") self.log(cr, uid, new_move.id, message) + + self.trigger_move_state(cr, uid, res, state, context=context) self.action_done(cr, uid, res) return res From 876bcf590be102c0ac1cd0a0f0048fe20f7fe929 Mon Sep 17 00:00:00 2001 From: "rha@tinyerp.com" <> Date: Mon, 20 Dec 2010 18:37:36 +0530 Subject: [PATCH 3/7] [Fix]: Bug #691433 purchase.report view model does not work bzr revid: rha@tinyerp.com-20101220130736-lgn6zmsxpskzfw54 --- addons/purchase/report/purchase_report.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index f30d65d8f28..251876da416 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -99,7 +99,10 @@ class purchase_report(osv.osv): extract(epoch from age(l.date_planned,s.date_order))/(24*60*60)::decimal(16,2) as delay_pass, count(*) as nbr, (l.price_unit*l.product_qty*u.factor)::decimal(16,2) as price_total, - avg(100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))::decimal(16,2) as negociation, + avg(case when t.standard_price <= 0 then (100.0 * (l.price_unit*l.product_qty*u.factor)) + else + (100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor)) + end) as negociation, sum(t.standard_price*l.product_qty*u.factor)::decimal(16,2) as price_standard, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s From d776dc002561039d0e7f9b777ef613fd41d7a752 Mon Sep 17 00:00:00 2001 From: "rha@tinyerp.com" <> Date: Tue, 21 Dec 2010 12:33:04 +0530 Subject: [PATCH 4/7] [Merge] bzr revid: rha@tinyerp.com-20101221070304-dp0tb1lc8pqfb28e --- addons/product/i18n/product.pot | 1 - addons/product/i18n/vi.po | 1 - 2 files changed, 2 deletions(-) diff --git a/addons/product/i18n/product.pot b/addons/product/i18n/product.pot index 3c3416460cb..0583959553b 100644 --- a/addons/product/i18n/product.pot +++ b/addons/product/i18n/product.pot @@ -1401,7 +1401,6 @@ msgstr "" #. module: product #: model:product.pricelist,name:product.list0 -#: report:product.pricelist:0 msgid "Public Pricelist" msgstr "" diff --git a/addons/product/i18n/vi.po b/addons/product/i18n/vi.po index 867cff0a9ac..62c8ca5e0b1 100644 --- a/addons/product/i18n/vi.po +++ b/addons/product/i18n/vi.po @@ -1518,7 +1518,6 @@ msgstr "" #. module: product #: model:product.pricelist,name:product.list0 -#: report:product.pricelist:0 msgid "Public Pricelist" msgstr "Bảng giá công bố" From 40756ba216ab71753ee35852767c991b61c500d2 Mon Sep 17 00:00:00 2001 From: "rha@tinyerp.com" <> Date: Tue, 21 Dec 2010 16:44:06 +0530 Subject: [PATCH 5/7] [Fix]: Bug #692868 Custom Reports do not open bzr revid: rha@tinyerp.com-20101221111406-k7tny7cmx8v01uyr --- .../base_report_creator/base_report_creator.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py index 28228b4ab58..663df95047b 100644 --- a/addons/base_report_creator/base_report_creator.py +++ b/addons/base_report_creator/base_report_creator.py @@ -193,16 +193,17 @@ class report_creator(osv.osv): if context is None: context = {} data = context.get('report_id', False) + res = super(report_creator, self).read(cr, user, ids, fields, context, load) if (not context) or 'report_id' not in context: - return super(report_creator, self).read(cr, user, ids, fields, context, load) + return res ctx = context or {} wp = '' - if data: + for data in res: + if not data.get('sql_query'): + return res if self.model_set_id: wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))] - report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp) - sql_query = report[data] - cr.execute(sql_query) + cr.execute(data['sql_query']) res = cr.dictfetchall() fields_get = self.fields_get(cr, user, None, context) for r in res: @@ -216,7 +217,7 @@ class report_creator(osv.osv): related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0] r[k] = related_name - return res + return res def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ @@ -253,9 +254,8 @@ class report_creator(osv.osv): newargs += [("count(*) " + a[1] +" " + str(a[2]))] ctx = context or {} ctx['getid'] = True - report = self._sql_query_get(cr, user, [context_id], 'sql_query', None, ctx, where_plus = newargs, limit=limit, offset=offset) - query = report[context_id] - cr.execute(query, newargs2) + sql_query = report.sql_query + cr.execute(sql_query, newargs2) result = cr.fetchall() return map(lambda x: x[0], result) From 5cb326ed8183aeb55e0372beae52c853d9c68dce Mon Sep 17 00:00:00 2001 From: "rha@tinyerp.com" <> Date: Tue, 21 Dec 2010 18:38:49 +0530 Subject: [PATCH 6/7] [Fix]: Bug #692950 add a filter button Ready selected by default in Manufacturing order bzr revid: rha@tinyerp.com-20101221130849-2ydpumhtp7wr5lcb --- addons/mrp/mrp_view.xml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index e17c3370ac3..ba8647814f0 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -730,12 +730,15 @@ - + + - + help="Manufacturing Orders which are ready to start production."/> tree,form,calendar,graph,gantt - {'search_default_current':1} + {'search_default_ready':1} Manufacturing Orders are usually proposed automatically by OpenERP based on the bill of materials and the procurement rules, but you can also create manufacturing orders manually. OpenERP will handle the consumation of the raw materials (stock decrease) and the production of the finished products (stock increase) when the order is processed. From 48f64d6312199407ca1dd6d5297e50deaa59cf9c Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 22 Dec 2010 17:34:20 +0530 Subject: [PATCH 7/7] [FIX]: stock: Fixed picking name according to its type while creating chained picking lp bug: https://launchpad.net/bugs/663999 fixed bzr revid: rpa@tinyerp.com-20101222120420-smwbdjm204z556gm --- addons/stock/stock.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index cfaa17f4c5d..f2f428513f2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1763,7 +1763,7 @@ class stock_move(osv.osv): result[m.picking_id].append( (m, dest) ) return result - def _create_chained_picking(self, cr, uid, pick_name,picking,ptype,move, context=None): + def _create_chained_picking(self, cr, uid, pick_name, picking, ptype, move, context=None): res_obj = self.pool.get('res.company') picking_obj = self.pool.get('stock.picking') pick_id= picking_obj.create(cr, uid, { @@ -1796,11 +1796,18 @@ class stock_move(osv.osv): new_moves = [] if context is None: context = {} + seq_obj = self.pool.get('ir.sequence') for picking, todo in self._chain_compute(cr, uid, moves, context=context).items(): ptype = todo[0][1][5] and todo[0][1][5] or location_obj.picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0]) - pick_name = picking.name or '' if picking: - pickid = self._create_chained_picking(cr, uid, pick_name,picking,ptype,todo,context) + # name of new picking according to its type + new_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + ptype) + pickid = self._create_chained_picking(cr, uid, new_pick_name, picking, ptype, todo, context=context) + # Need to check name of old picking because it always considers picking as "OUT" when created from Sale Order + old_ptype = location_obj.picking_type_get(cr, uid, picking.move_lines[0].location_id, picking.move_lines[0].location_dest_id) + if old_ptype != picking.type: + old_pick_name = seq_obj.get(cr, uid, 'stock.picking.' + old_ptype) + self.pool.get('stock.picking').write(cr, uid, picking.id, {'name': old_pick_name}, context=context) else: pickid = False for move, (loc, dummy, delay, dummy, company_id, ptype) in todo: