From 7d7fe62ca8147a8d6ebd323034a64d7cc076a0c8 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 25 Jan 2013 16:49:41 +0100 Subject: [PATCH 01/56] [IMP] procurement: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130125154941-8jbzke0diaqhf5j3 --- addons/procurement/schedulers.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 3cb34d6bdff..76b31cc6da3 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -62,8 +62,7 @@ class procurement_order(osv.osv): procurement_obj = self.pool.get('procurement.order') if not ids: ids = procurement_obj.search(cr, uid, [('state', '=', 'exception')], order="date_planned") - for id in ids: - wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr) + self.signal_button_restart(cr, uid, ids) if use_new_cursor: cr.commit() company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id @@ -78,7 +77,7 @@ class procurement_order(osv.osv): ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_order')], offset=offset, limit=500, order='priority, date_planned', context=context) for proc in procurement_obj.browse(cr, uid, ids, context=context): if maxdate >= proc.date_planned: - wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) + self.signal_button_check(cr, uid, [proc.id]) else: offset += 1 report_later += 1 @@ -100,7 +99,7 @@ class procurement_order(osv.osv): ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_stock')], offset=offset) for proc in procurement_obj.browse(cr, uid, ids): if maxdate >= proc.date_planned: - wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) + self.signal_button_check(cr, uid, [proc.id]) report_ids.append(proc.id) else: report_later += 1 @@ -178,8 +177,8 @@ class procurement_order(osv.osv): proc_id = proc_obj.create(cr, uid, self._prepare_automatic_op_procurement(cr, uid, product, warehouse, location_id, context=context), context=context) - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) + self.signal_button_confirm(cr, uid, [proc_id]) + self.signal_button_check(cr, uid, [proc_id]) return True def _get_orderpoint_date_planned(self, cr, uid, orderpoint, start_date, context=None): @@ -254,7 +253,7 @@ class procurement_order(osv.osv): to_generate = qty for proc_data in procure_datas: if to_generate >= proc_data['product_qty']: - wf_service.trg_validate(uid, 'procurement.order', proc_data['id'], 'button_confirm', cr) + self.signal_button_confirm(cr, uid, [proc_data['id']]) procurement_obj.write(cr, uid, [proc_data['id']], {'origin': op.name}, context=context) to_generate -= proc_data['product_qty'] if not to_generate: @@ -265,10 +264,8 @@ class procurement_order(osv.osv): proc_id = procurement_obj.create(cr, uid, self._prepare_orderpoint_procurement(cr, uid, op, qty, context=context), context=context) - wf_service.trg_validate(uid, 'procurement.order', proc_id, - 'button_confirm', cr) - wf_service.trg_validate(uid, 'procurement.order', proc_id, - 'button_check', cr) + self.signal_button_confirm(cr, uid, [proc_id]) + self.signal_button_check(cr, uid, [proc_id]) orderpoint_obj.write(cr, uid, [op.id], {'procurement_id': proc_id}, context=context) offset += len(ids) @@ -279,6 +276,4 @@ class procurement_order(osv.osv): cr.close() return {} -procurement_order() - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From a2679597a0f3f3eaf6277e030ca2a9b44763f873 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 25 Jan 2013 17:53:55 +0100 Subject: [PATCH 02/56] [IMP] purchase: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130125165355-78o1utblskn0sa5e --- addons/purchase/purchase.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 799601acb64..bf3686d5a34 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -22,6 +22,7 @@ import time from datetime import datetime from dateutil.relativedelta import relativedelta +from operator import attrgetter from openerp.osv import fields, osv from openerp import netsvc @@ -260,9 +261,7 @@ class purchase_order(osv.osv): raise osv.except_osv(_('Invalid Action!'), _('In order to delete a purchase order, you must cancel it first.')) # automatically sending subflow.delete upon deletion - wf_service = netsvc.LocalService("workflow") - for id in unlink_ids: - wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr) + self.signal_purchase_cancel(cr, uid, unlink_ids) return super(purchase_order, self).unlink(cr, uid, unlink_ids, context=context) @@ -439,8 +438,7 @@ class purchase_order(osv.osv): This function prints the request for quotation and mark it as sent, so that we can see more easily the next step of the workflow ''' assert len(ids) == 1, 'This option should only be used for a single id at a time' - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', ids[0], 'send_rfq', cr) + self.signal_send_rfq(cr, uid, ids) datas = { 'model': 'purchase.order', 'ids': ids, @@ -571,26 +569,24 @@ class purchase_order(osv.osv): return False def action_cancel(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") for purchase in self.browse(cr, uid, ids, context=context): for pick in purchase.picking_ids: if pick.state not in ('draft','cancel'): raise osv.except_osv( _('Unable to cancel this purchase order.'), _('First cancel all receptions related to this purchase order.')) - for pick in purchase.picking_ids: - wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr) + self.pool.get('stock.picking') \ + .signal_button_cancel(cr, uid, map(attrgetter('id'), purchase.picking_ids)) for inv in purchase.invoice_ids: if inv and inv.state not in ('cancel','draft'): raise osv.except_osv( _('Unable to cancel this purchase order.'), _('You must first cancel all receptions related to this purchase order.')) - if inv: - wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr) + self.pool.get('account.invoice') \ + .signal_invoice_cancel(cr, uid, map(attrgetter('id'), purchase.invoice_ids)) self.write(cr,uid,ids,{'state':'cancel'}) - for (id, name) in self.name_get(cr, uid, ids): - wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr) + self.signal_purchase_cancel(cr, uid, ids) return True def _prepare_order_picking(self, cr, uid, order, context=None): @@ -648,11 +644,11 @@ class purchase_order(osv.osv): will be added. A new picking will be created if omitted. :return: list of IDs of pickings used/created for the given order lines (usually just one) """ + stock_picking = self.pool.get('stock.picking') if not picking_id: - picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context)) + picking_id = stock_picking.create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context)) todo_moves = [] stock_move = self.pool.get('stock.move') - wf_service = netsvc.LocalService("workflow") for order_line in order_lines: if not order_line.product_id: continue @@ -663,7 +659,7 @@ class purchase_order(osv.osv): todo_moves.append(move) stock_move.action_confirm(cr, uid, todo_moves) stock_move.force_assign(cr, uid, todo_moves) - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) + stock_picking.signal_button_confirm(cr, uid, [picking_id]) return [picking_id] def action_picking_create(self, cr, uid, ids, context=None): @@ -714,7 +710,6 @@ class purchase_order(osv.osv): """ #TOFIX: merged order line should be unlink - wf_service = netsvc.LocalService("workflow") def make_key(br, fields): list_key = [] for field in fields: @@ -782,6 +777,7 @@ class purchase_order(osv.osv): allorders = [] orders_info = {} + wf_service = netsvc.LocalService("workflow") for order_key, (order_data, old_ids) in new_orders.iteritems(): # skip merges with only one order if len(old_ids) < 2: @@ -802,7 +798,7 @@ class purchase_order(osv.osv): # make triggers pointing to the old orders point to the new order for old_id in old_ids: wf_service.trg_redirect(uid, 'purchase.order', old_id, neworder_id, cr) - wf_service.trg_validate(uid, 'purchase.order', old_id, 'purchase_cancel', cr) + self.signal_purchase_cancel(cr, uid, [old_id]) # TODO Is it necessary to interleave the calls? return orders_info @@ -1169,8 +1165,7 @@ class mail_mail(osv.Model): def _postprocess_sent_message(self, cr, uid, mail, context=None): if mail.model == 'purchase.order': - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', mail.res_id, 'send_rfq', cr) + self.pool.get('purchase.order').signal_send_rfq(cr, uid, [mail.res_id]) return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context) @@ -1192,8 +1187,7 @@ class mail_compose_message(osv.Model): context = context or {} if context.get('default_model') == 'purchase.order' and context.get('default_res_id'): context = dict(context, mail_post_autofollow=True) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', context['default_res_id'], 'send_rfq', cr) + self.pool.get('purchase.order').signal_send_rfq(cr, uid, [context['default_res_id']]) return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 11632909ae3e6952d4f26469077819ad57134985 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 25 Jan 2013 22:17:51 +0100 Subject: [PATCH 03/56] [FIX] lunch: passing self in a super call. bzr revid: vmt@openerp.com-20130125211751-725w3trha283ypa2 --- addons/lunch/lunch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/lunch/lunch.py b/addons/lunch/lunch.py index 0f9033fce38..022eb5208eb 100644 --- a/addons/lunch/lunch.py +++ b/addons/lunch/lunch.py @@ -159,7 +159,7 @@ class lunch_order(osv.Model): def specific_function(cr, uid, ids, context=None): return self.add_preference(cr, uid, ids, pref_id, context=context) return specific_function - return super(lunch_order,self).__getattr__(self,attr) + return super(lunch_order, self).__getattr__(attr) def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): """ From 494b2481e2ce798364eb1548b1e57d9e1e9c2d39 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 10:17:16 +0100 Subject: [PATCH 04/56] [IMP] purchase: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128091716-ni5zb1qp4sib58rm --- addons/purchase/test/process/rfq2order2done.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/purchase/test/process/rfq2order2done.yml b/addons/purchase/test/process/rfq2order2done.yml index 4bf55d61973..be68a8ca01e 100644 --- a/addons/purchase/test/process/rfq2order2done.yml +++ b/addons/purchase/test/process/rfq2order2done.yml @@ -62,8 +62,7 @@ import netsvc invoice_ids = [x.id for x in self.browse(cr, uid, ref("purchase_order_1")).invoice_ids] wf_service = netsvc.LocalService("workflow") - for invoice in invoice_ids: - wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_open', cr) + self.pool.get('account.invoice').signal_invoice_open(cr, uid, invoice_ids) - I check that purchase order is invoiced. - From 86680d853b12bd4564ab7d0792eae7534bdbbd9f Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 10:29:30 +0100 Subject: [PATCH 05/56] [IMP] account_payment: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128092930-6lhgyprwirpt6y3z --- addons/account_payment/account_payment.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index d67db60e590..c57c83aa765 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -135,9 +135,8 @@ class payment_order(osv.osv): return True def set_done(self, cr, uid, ids, *args): - wf_service = netsvc.LocalService("workflow") self.write(cr, uid, ids, {'date_done': time.strftime('%Y-%m-%d')}) - wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr) + self.signal_done(cr, uid, [ids[0]]) return True def copy(self, cr, uid, id, default=None, context=None): From f6fd7368a283439f3d7ca8110acd49066dcac18b Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 11:00:38 +0100 Subject: [PATCH 06/56] [IMP] procurement: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128100038-6dyftmdm8tfn6j5k --- addons/procurement/procurement.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 50efe0f500e..21c260b99cd 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -19,10 +19,12 @@ # ############################################################################## +from operator import attrgetter +import time + from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp import netsvc -import time import openerp.addons.decimal_precision as dp # Procurement @@ -42,7 +44,6 @@ class mrp_property_group(osv.osv): 'name': fields.char('Property Group', size=64, required=True), 'description': fields.text('Description'), } -mrp_property_group() class mrp_property(osv.osv): """ @@ -59,7 +60,6 @@ class mrp_property(osv.osv): _defaults = { 'composition': lambda *a: 'min', } -mrp_property() class StockMove(osv.osv): _inherit = 'stock.move' @@ -72,7 +72,6 @@ class StockMove(osv.osv): default['procurements'] = [] return super(StockMove, self).copy(cr, uid, id, default, context=context) -StockMove() class procurement_order(osv.osv): """ @@ -456,15 +455,13 @@ class procurement_order(osv.osv): class StockPicking(osv.osv): _inherit = 'stock.picking' - def test_finished(self, cursor, user, ids): + def test_finished(self, cr, uid, ids): wf_service = netsvc.LocalService("workflow") - res = super(StockPicking, self).test_finished(cursor, user, ids) - for picking in self.browse(cursor, user, ids): + res = super(StockPicking, self).test_finished(cr, uid, ids) + for picking in self.browse(cr, uid, ids): for move in picking.move_lines: if move.state == 'done' and move.procurements: - for procurement in move.procurements: - wf_service.trg_validate(user, 'procurement.order', - procurement.id, 'button_check', cursor) + self.pool.get('procurement.order').signal_button_check(cr, uid, map(attrgetter('id'), move.procurements)) return res class stock_warehouse_orderpoint(osv.osv): From 99664df35a52019dab329b993801ee1642b0704b Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 12:39:54 +0100 Subject: [PATCH 07/56] [IMP] stock_location: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128113954-i60z7w4mygprra40 --- addons/stock_location/procurement_pull.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/stock_location/procurement_pull.py b/addons/stock_location/procurement_pull.py index eb5235d35ba..9f5dfb77375 100644 --- a/addons/stock_location/procurement_pull.py +++ b/addons/stock_location/procurement_pull.py @@ -49,7 +49,6 @@ class procurement_order(osv.osv): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') - wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: @@ -109,9 +108,8 @@ class procurement_order(osv.osv): 'procure_method': line.procure_method, 'move_id': move_id, }) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) + self.pool.get('stock.picking').signal_button_confirm(cr, uid, [picking_id]) + self.signal_button_confirm(cr, uid, [proc_id]) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) @@ -119,9 +117,8 @@ class procurement_order(osv.osv): self.write(cr, uid, [proc.id], {'state':'running', 'message': msg}) self.message_post(cr, uid, [proc.id], body=msg, context=context) # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed) - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) + self.signal_button_check(cr, uid, [proc_id]) # TODO is it necessary to interleave the calls? return False -procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 781e6737acc114b7a76d711aa7e31ba78dd401b3 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 13:01:47 +0100 Subject: [PATCH 08/56] [IMP] account_followup: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128120147-oj7pvl2015x4764v --- addons/account_followup/tests/test_account_followup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/account_followup/tests/test_account_followup.py b/addons/account_followup/tests/test_account_followup.py index 14f458de98d..8ddf3f82288 100644 --- a/addons/account_followup/tests/test_account_followup.py +++ b/addons/account_followup/tests/test_account_followup.py @@ -44,8 +44,7 @@ class TestAccountFollowup(TransactionCase): 'quantity': 5, 'price_unit':200 })]}) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.invoice', self.invoice_id, 'invoice_open', cr) + self.registry('account.invoice').signal_invoice_open(cr, uid, [self.invoice_id]) self.voucher = self.registry("account.voucher") From 8d50446d278643bf645107744a6ba12108c9eea1 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 15:16:23 +0100 Subject: [PATCH 09/56] [IMP] hr_holidays: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128141623-4rxcgqx7t33yydbp --- addons/hr_holidays/hr_holidays.py | 21 +++++++++------------ addons/hr_holidays/test/test_hr_holiday.yml | 3 +-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index c7d7867911d..234897809e1 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -24,7 +24,7 @@ import datetime import time from itertools import groupby -from operator import itemgetter +from operator import attrgetter, itemgetter import math from openerp import netsvc @@ -370,11 +370,11 @@ class hr_holidays(osv.osv): 'employee_id': emp.id } leave_ids.append(self.create(cr, uid, vals, context=None)) - wf_service = netsvc.LocalService("workflow") for leave_id in leave_ids: - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr) + # TODO is it necessary to interleave the calls? + self.signal_confirm(cr, uid, [leave_id]) + self.signal_validate(cr, uid, [leave_id]) + self.signal_second_validate(cr, uid, [leave_id]) return True def holidays_confirm(self, cr, uid, ids, context=None): @@ -404,9 +404,7 @@ class hr_holidays(osv.osv): meeting_obj.unlink(cr, uid, [record.meeting_id.id]) # If a category that created several holidays, cancel all related - wf_service = netsvc.LocalService("workflow") - for request in record.linked_request_ids or []: - wf_service.trg_validate(uid, 'hr.holidays', request.id, 'refuse', cr) + self.signal_refuse(cr, uid, map(attrgetter('id'), record.linked_request_ids or [])) self._remove_resource_leave(cr, uid, ids, context=context) return True @@ -478,10 +476,9 @@ class hr_employee(osv.osv): leave_id = holiday_obj.create(cr, uid, {'name': _('Leave Request for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'remove', 'holiday_type': 'employee', 'number_of_days_temp': abs(diff)}, context=context) else: return False - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr) + holidays_obj.signal_confirm(cr, uid, [leave_id]) + holidays_obj.signal_validate(cr, uid, [leave_id]) + holidays_obj.signal_second_validate(cr, uid, [leave_id]) return True def _get_remaining_days(self, cr, uid, ids, name, args, context=None): diff --git a/addons/hr_holidays/test/test_hr_holiday.yml b/addons/hr_holidays/test/test_hr_holiday.yml index f0e85d552cb..e78c2fd08bc 100644 --- a/addons/hr_holidays/test/test_hr_holiday.yml +++ b/addons/hr_holidays/test/test_hr_holiday.yml @@ -19,9 +19,8 @@ - !python {model: hr.holidays}: | import netsvc - wf_service = netsvc.LocalService("workflow") self.set_to_draft(cr, uid, [ref('hr_holidays_employee1_cl')]) - wf_service.trg_validate(uid, 'hr.holidays', ref('hr_holidays_employee1_cl'), 'confirm', cr) + self.signal_confirm(cr, uid, [ref('hr_holidays_employee1_cl')]) - I validate the holiday request by clicking on "To Approve" button. - From ca919bec2c979a70e615f5023b6241b36b2c0ba1 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 15:51:43 +0100 Subject: [PATCH 10/56] [IMP] account_voucher: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128145143-w68s6z1kuulqk6ig --- addons/account_voucher/account_voucher.py | 8 ++------ addons/account_voucher/test/case1_usd_usd.yml | 8 ++------ addons/account_voucher/test/case2_suppl_usd_eur.yml | 8 ++------ .../account_voucher/test/case2_usd_eur_debtor_in_eur.yml | 6 ++---- .../account_voucher/test/case2_usd_eur_debtor_in_usd.yml | 8 ++------ addons/account_voucher/test/case3_eur_eur.yml | 8 ++------ addons/account_voucher/test/case4_cad_chf.yml | 3 +-- addons/account_voucher/test/sales_payment.yml | 3 +-- addons/account_voucher/test/sales_receipt.yml | 3 +-- 9 files changed, 15 insertions(+), 40 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index de9cebdd09b..2046d787ef3 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -820,10 +820,7 @@ class account_voucher(osv.osv): return vals def button_proforma_voucher(self, cr, uid, ids, context=None): - context = context or {} - wf_service = netsvc.LocalService("workflow") - for vid in ids: - wf_service.trg_validate(uid, 'account.voucher', vid, 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, ids) return {'type': 'ir.actions.act_window_close'} def proforma_voucher(self, cr, uid, ids, context=None): @@ -1506,7 +1503,6 @@ class account_bank_statement(osv.osv): def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None): voucher_obj = self.pool.get('account.voucher') - wf_service = netsvc.LocalService("workflow") move_line_obj = self.pool.get('account.move.line') bank_st_line_obj = self.pool.get('account.bank.statement.line') st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context) @@ -1514,7 +1510,7 @@ class account_bank_statement(osv.osv): voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number}, context=context) if st_line.voucher_id.state == 'cancel': voucher_obj.action_cancel_draft(cr, uid, [st_line.voucher_id.id], context=context) - wf_service.trg_validate(uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr) + voucher_obj.signal_proforma_voucher(cr, uid, [st_line.voucher_id.id]) v = voucher_obj.browse(cr, uid, st_line.voucher_id.id, context=context) bank_st_line_obj.write(cr, uid, [st_line_id], { diff --git a/addons/account_voucher/test/case1_usd_usd.yml b/addons/account_voucher/test/case1_usd_usd.yml index 0f4c2058fc7..fd1945691ba 100644 --- a/addons/account_voucher/test/case1_usd_usd.yml +++ b/addons/account_voucher/test/case1_usd_usd.yml @@ -182,10 +182,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my first voucher is valid - @@ -279,10 +277,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my second voucher is valid - diff --git a/addons/account_voucher/test/case2_suppl_usd_eur.yml b/addons/account_voucher/test/case2_suppl_usd_eur.yml index b32228032d3..91fb99f6360 100644 --- a/addons/account_voucher/test/case2_suppl_usd_eur.yml +++ b/addons/account_voucher/test/case2_suppl_usd_eur.yml @@ -161,10 +161,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my voucher is valid - @@ -266,10 +264,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that my voucher state is posted - diff --git a/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml b/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml index 275e4c58835..2afdc8ad31b 100644 --- a/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml +++ b/addons/account_voucher/test/case2_usd_eur_debtor_in_eur.yml @@ -181,8 +181,7 @@ !python {model: account.voucher}: | import netsvc voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my voucher is valid - @@ -256,8 +255,7 @@ !python {model: account.voucher}: | import netsvc voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that my voucher state is posted - diff --git a/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml b/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml index 667882e3a32..b049fc7692e 100644 --- a/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml +++ b/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml @@ -179,10 +179,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my voucher is valid - @@ -269,10 +267,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that my voucher state is posted - diff --git a/addons/account_voucher/test/case3_eur_eur.yml b/addons/account_voucher/test/case3_eur_eur.yml index f2f9461c31e..d0b18a5231b 100644 --- a/addons/account_voucher/test/case3_eur_eur.yml +++ b/addons/account_voucher/test/case3_eur_eur.yml @@ -141,10 +141,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my first voucher is valid - @@ -231,10 +229,8 @@ I confirm the voucher - !python {model: account.voucher}: | - import netsvc voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my second voucher is valid - diff --git a/addons/account_voucher/test/case4_cad_chf.yml b/addons/account_voucher/test/case4_cad_chf.yml index bc33e387a85..e8fe4c8cf9b 100644 --- a/addons/account_voucher/test/case4_cad_chf.yml +++ b/addons/account_voucher/test/case4_cad_chf.yml @@ -143,8 +143,7 @@ !python {model: account.voucher}: | import netsvc voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))]) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, voucher) - I check that the move of my voucher is valid - diff --git a/addons/account_voucher/test/sales_payment.yml b/addons/account_voucher/test/sales_payment.yml index b71e42add0b..e7ed61c2cb2 100644 --- a/addons/account_voucher/test/sales_payment.yml +++ b/addons/account_voucher/test/sales_payment.yml @@ -61,8 +61,7 @@ id = self.create(cr, uid, vals) voucher_id = self.browse(cr, uid, id) assert (voucher_id.state=='draft'), "Voucher is not in draft state" - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, [voucher_id.id]) - Finally i will Confirm the state of the invoice is paid diff --git a/addons/account_voucher/test/sales_receipt.yml b/addons/account_voucher/test/sales_receipt.yml index cf4bc5c46d3..af10777d98a 100644 --- a/addons/account_voucher/test/sales_receipt.yml +++ b/addons/account_voucher/test/sales_receipt.yml @@ -65,8 +65,7 @@ id = self.create(cr, uid, vals) voucher_id = self.browse(cr, uid, id) assert (voucher_id.state=='draft'), "Voucher is not in draft state" - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr) + self.signal_proforma_voucher(cr, uid, [voucher_id.id]) - I check that move lines are reconciled meaning voucher is paid - From 752649aa77a350b60e9cad39436f7c90b2b34652 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 16:29:16 +0100 Subject: [PATCH 11/56] [IMP] l10n_in_hr_payroll: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128152916-kt23l68420hkg49y --- addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py b/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py index 76fc1247de6..da98bbe681a 100644 --- a/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py +++ b/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py @@ -198,8 +198,9 @@ class hr_payslip_run(osv.osv): advice_id = advice_pool.create(cr, uid, advice_data, context=context) slip_ids = [] for slip_id in run.slip_ids: - wf_service.trg_validate(uid, 'hr.payslip', slip_id.id, 'hr_verify_sheet', cr) - wf_service.trg_validate(uid, 'hr.payslip', slip_id.id, 'process_sheet', cr) + # TODO is it necessary to interleave the calls ? + payslip_pool.signal_hr_verify_sheet(cr, uid, [slip_id.id]) + payslip_pool.signal_process_sheet(cr, uid, [slip_id.id]) slip_ids.append(slip_id.id) for slip in payslip_pool.browse(cr, uid, slip_ids, context=context): From 48a371d2b2b31544ed39b567b90c87a2da4ba9d1 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 16:29:29 +0100 Subject: [PATCH 12/56] [IMP] stock: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128152929-6rpoaccy5huw8kdq --- addons/stock/stock.py | 22 ++++++++------------- addons/stock/wizard/stock_return_picking.py | 3 +-- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7198c89e286..2d351d9302e 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -759,10 +759,9 @@ class stock_picking(osv.osv): """ Changes state of picking to available if all moves are confirmed. @return: True """ - wf_service = netsvc.LocalService("workflow") for pick in self.browse(cr, uid, ids): if pick.state == 'draft': - wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_confirm', cr) + self.signal_button_confirm(cr, uid, [pick.id]) move_ids = [x.id for x in pick.move_lines if x.state == 'confirmed'] if not move_ids: raise osv.except_osv(_('Warning!'),_('Not enough stock, unable to reserve the products.')) @@ -784,12 +783,10 @@ class stock_picking(osv.osv): """ Confirms picking directly from draft state. @return: True """ - wf_service = netsvc.LocalService("workflow") for pick in self.browse(cr, uid, ids): if not pick.move_lines: raise osv.except_osv(_('Error!'),_('You cannot process picking without stock moves.')) - wf_service.trg_validate(uid, 'stock.picking', pick.id, - 'button_confirm', cr) + self.signal_button_confirm(cr, uid, [pick.id]) return True def draft_validate(self, cr, uid, ids, context=None): @@ -1345,18 +1342,18 @@ class stock_picking(osv.osv): # At first we confirm the new picking (if necessary) if new_picking: - wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) + self.signal_button_confirm(cr, uid, [new_picking]) # Then we finish the good picking self.write(cr, uid, [pick.id], {'backorder_id': new_picking}) self.action_move(cr, uid, [new_picking], context=context) - wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr) + self.signal_button_done(cr, uid, [new_picking]) wf_service.trg_write(uid, 'stock.picking', pick.id, cr) delivered_pack_id = new_picking back_order_name = self.browse(cr, uid, delivered_pack_id, context=context).name self.message_post(cr, uid, ids, body=_("Back order %s has been created.") % (back_order_name), context=context) else: self.action_move(cr, uid, [pick.id], context=context) - wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr) + self.signal_button_done(cr, uid, [pick.id]) delivered_pack_id = pick.id delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context) @@ -2037,7 +2034,6 @@ class stock_move(osv.osv): res_obj = self.pool.get('res.company') location_obj = self.pool.get('stock.location') move_obj = self.pool.get('stock.move') - wf_service = netsvc.LocalService("workflow") new_moves = [] if context is None: context = {} @@ -2073,7 +2069,7 @@ class stock_move(osv.osv): }) new_moves.append(self.browse(cr, uid, [new_id])[0]) if pickid: - wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr) + self.signal_button_confirm(cr, uid, [pickid]) if new_moves: new_moves += self.create_chained_picking(cr, uid, new_moves, context) return new_moves @@ -2195,6 +2191,7 @@ class stock_move(osv.osv): return True if context is None: context = {} + wf_service = netsvc.LocalService("workflow") pickings = set() for move in self.browse(cr, uid, ids, context=context): if move.state in ('confirmed', 'waiting', 'assigned', 'draft'): @@ -2203,7 +2200,6 @@ class stock_move(osv.osv): if move.move_dest_id and move.move_dest_id.state == 'waiting': self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if context.get('call_unlink',False) and move.move_dest_id.picking_id: - wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) self.write(cr, uid, ids, {'state': 'cancel', 'move_dest_id': False}) if not context.get('call_unlink',False): @@ -2211,7 +2207,6 @@ class stock_move(osv.osv): if all(move.state == 'cancel' for move in pick.move_lines): self.pool.get('stock.picking').write(cr, uid, [pick.id], {'state': 'cancel'}) - wf_service = netsvc.LocalService("workflow") for id in ids: wf_service.trg_trigger(uid, 'stock.move', id, cr) return True @@ -2633,7 +2628,6 @@ class stock_move(osv.osv): product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') uom_obj = self.pool.get('product.uom') - wf_service = netsvc.LocalService("workflow") if context is None: context = {} @@ -2734,7 +2728,7 @@ class stock_move(osv.osv): res = cr.fetchall() if len(res) == len(move.picking_id.move_lines): picking_obj.action_move(cr, uid, [move.picking_id.id]) - wf_service.trg_validate(uid, 'stock.picking', move.picking_id.id, 'button_done', cr) + picking_obj.signal_button_done(cr, uid, [move.picking_id.id]) return [move.id for move in complete] diff --git a/addons/stock/wizard/stock_return_picking.py b/addons/stock/wizard/stock_return_picking.py index 7c6f0655e7a..bc149f86176 100644 --- a/addons/stock/wizard/stock_return_picking.py +++ b/addons/stock/wizard/stock_return_picking.py @@ -151,7 +151,6 @@ class stock_return_picking(osv.osv_memory): data_obj = self.pool.get('stock.return.picking.memory') act_obj = self.pool.get('ir.actions.act_window') model_obj = self.pool.get('ir.model.data') - wf_service = netsvc.LocalService("workflow") pick = pick_obj.browse(cr, uid, record_id, context=context) data = self.read(cr, uid, ids[0], context=context) date_cur = time.strftime('%Y-%m-%d %H:%M:%S') @@ -206,7 +205,7 @@ class stock_return_picking(osv.osv_memory): if set_invoice_state_to_none: pick_obj.write(cr, uid, [pick.id], {'invoice_state':'none'}, context=context) - wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) + pick_obj.signal_button_confirm(cr, uid, [new_picking]) pick_obj.force_assign(cr, uid, [new_picking], context) # Update view id in context, lp:702939 model_list = { From 45ba35783f556c851e1a6791ea79f309ff43d98c Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 28 Jan 2013 17:34:03 +0100 Subject: [PATCH 13/56] [IMP] mrp_operations: use the new signal_xxx methods instead of trg_validate. bzr revid: vmt@openerp.com-20130128163403-dmbb0a1y0ejbt66t --- addons/mrp_operations/mrp_operations.py | 46 +++++++++---------- .../test/workcenter_operations.yml | 32 ++++--------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 1ce60946f6c..a60b348559c 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -118,16 +118,15 @@ class mrp_production_workcenter_line(osv.osv): @param action: Action to perform. @return: Nothing """ - wf_service = netsvc.LocalService("workflow") prod_obj_pool = self.pool.get('mrp.production') oper_obj = self.browse(cr, uid, ids)[0] prod_obj = oper_obj.production_id if action == 'start': if prod_obj.state =='confirmed': prod_obj_pool.force_production(cr, uid, [prod_obj.id]) - wf_service.trg_validate(uid, 'mrp.production', prod_obj.id, 'button_produce', cr) + prod_obj_pool.signal_button_produce(cr, uid, [prod_obj.id]) elif prod_obj.state =='ready': - wf_service.trg_validate(uid, 'mrp.production', prod_obj.id, 'button_produce', cr) + prod_obj_pool.signal_button_produce(cr, uid, [prod_obj.id]) elif prod_obj.state =='in_production': return else: @@ -143,7 +142,7 @@ class mrp_production_workcenter_line(osv.osv): for production in prod_obj_pool.browse(cr, uid, [prod_obj.id], context= None): if production.move_lines or production.move_created_ids: prod_obj_pool.action_produce(cr,uid, production.id, production.product_qty, 'consume_produce', context = None) - wf_service.trg_validate(uid, 'mrp.production', oper_obj.production_id.id, 'button_produce_done', cr) + prod_obj_pool.signal_button_produce_done(cr, uid, [oper_obj.production_id.id]) return def write(self, cr, uid, ids, vals, context=None, update=True): @@ -228,23 +227,21 @@ class mrp_production(osv.osv): @return: Super method """ obj = self.browse(cr, uid, ids)[0] - wf_service = netsvc.LocalService("workflow") + workcenter_pool = self.pool.get('mrp.production.workcenter.line') for workcenter_line in obj.workcenter_lines: if workcenter_line.state == 'draft': - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_start_working', cr) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_done', cr) + workcenter_pool.signal_button_start_working(cr, uid, [workcenter_line.id]) + workcenter_pool.signal_button_done(cr, uid, [workcenter_line.id]) return super(mrp_production,self).action_production_end(cr, uid, ids) def action_in_production(self, cr, uid, ids): """ Changes state to In Production and writes starting date. @return: True """ - obj = self.browse(cr, uid, ids)[0] workcenter_pool = self.pool.get('mrp.production.workcenter.line') - wf_service = netsvc.LocalService("workflow") for prod in self.browse(cr, uid, ids): if prod.workcenter_lines: - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', prod.workcenter_lines[0].id, 'button_start_working', cr) + workcenter_pool.signal_button_start_working(cr, uid, [prod.workcenter_lines[0].id]) return super(mrp_production,self).action_in_production(cr, uid, ids) def action_cancel(self, cr, uid, ids, context=None): @@ -252,9 +249,8 @@ class mrp_production(osv.osv): @return: Super method """ obj = self.browse(cr, uid, ids,context=context)[0] - wf_service = netsvc.LocalService("workflow") for workcenter_line in obj.workcenter_lines: - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_cancel', cr) + workcenter_pool.signal_button_cancel(cr, uid, [workcenter_line.id]) return super(mrp_production,self).action_cancel(cr,uid,ids,context=context) def _compute_planned_workcenter(self, cr, uid, ids, context=None, mini=False): @@ -503,35 +499,35 @@ class mrp_operations_operation(osv.osv): return super(mrp_operations_operation, self).write(cr, uid, ids, vals, context=context) def create(self, cr, uid, vals, context=None): + workcenter_pool = self.pool.get('mrp.production.workcenter.line') wf_service = netsvc.LocalService('workflow') code_ids=self.pool.get('mrp_operations.operation.code').search(cr,uid,[('id','=',vals['code_id'])]) code=self.pool.get('mrp_operations.operation.code').browse(cr, uid, code_ids, context=context)[0] - wc_op_id=self.pool.get('mrp.production.workcenter.line').search(cr,uid,[('workcenter_id','=',vals['workcenter_id']),('production_id','=',vals['production_id'])]) + wc_op_id=workcenter_pool.search(cr,uid,[('workcenter_id','=',vals['workcenter_id']),('production_id','=',vals['production_id'])]) if code.start_stop in ('start','done','pause','cancel','resume'): if not wc_op_id: production_obj=self.pool.get('mrp.production').browse(cr, uid, vals['production_id'], context=context) - wc_op_id.append(self.pool.get('mrp.production.workcenter.line').create(cr,uid,{'production_id':vals['production_id'],'name':production_obj.product_id.name,'workcenter_id':vals['workcenter_id']})) + wc_op_id.append(workcenter_pool.create(cr,uid,{'production_id':vals['production_id'],'name':production_obj.product_id.name,'workcenter_id':vals['workcenter_id']})) if code.start_stop=='start': - self.pool.get('mrp.production.workcenter.line').action_start_working(cr,uid,wc_op_id) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_start_working', cr) - + workcenter_pool.action_start_working(cr,uid,wc_op_id) + workcenter_pool.signal_button_start_working(cr, uid, [wc_op_id[0]]) if code.start_stop=='done': - self.pool.get('mrp.production.workcenter.line').action_done(cr,uid,wc_op_id) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_done', cr) + workcenter_pool.action_done(cr,uid,wc_op_id) + workcenter_pool.signal_button_done(cr, uid, [wc_op_id[0]]) self.pool.get('mrp.production').write(cr,uid,vals['production_id'],{'date_finished':datetime.now().strftime('%Y-%m-%d %H:%M:%S')}) if code.start_stop=='pause': - self.pool.get('mrp.production.workcenter.line').action_pause(cr,uid,wc_op_id) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_pause', cr) + workcenter_pool.action_pause(cr,uid,wc_op_id) + workcenter_pool.signal_button_pause(cr, uid, [wc_op_id[0]]) if code.start_stop=='resume': - self.pool.get('mrp.production.workcenter.line').action_resume(cr,uid,wc_op_id) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_resume', cr) + workcenter_pool.action_resume(cr,uid,wc_op_id) + workcenter_pool.signal_button_resume(cr, uid, [wc_op_id[0]]) if code.start_stop=='cancel': - self.pool.get('mrp.production.workcenter.line').action_cancel(cr,uid,wc_op_id) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', wc_op_id[0], 'button_cancel', cr) + workcenter_pool.action_cancel(cr,uid,wc_op_id) + workcenter_pool.signal_button_cancel(cr, uid, [wc_op_id[0]]) if not self.check_operation(cr, uid, vals): return diff --git a/addons/mrp_operations/test/workcenter_operations.yml b/addons/mrp_operations/test/workcenter_operations.yml index c1449657967..4754bb463ff 100644 --- a/addons/mrp_operations/test/workcenter_operations.yml +++ b/addons/mrp_operations/test/workcenter_operations.yml @@ -39,62 +39,48 @@ Production start on first work center, so I start work operation on first work center. - !python {model: mrp.production}: | - import netsvc order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_start_working', cr) + self.pool.get('mrp.production.workcenter.line').signal_button_start_working(cr, uid, [order.workcenter_lines[0].id]) - Now I pause first work operation due to technical fault of work center. - !python {model: mrp.production}: | - import netsvc order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_pause', cr) + self.pool.get('mrp.production.workcenter.line').signal_button_pause(cr, uid, [order.workcenter_lines[0].id]) - I resume first work operation. - !python {model: mrp.production}: | - import netsvc order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_resume', cr) + self.pool.get('mrp.production.workcenter.line').signal_button_resume(cr, uid, [order.workcenter_lines[0].id]) - I cancel first work operation. - !python {model: mrp.production}: | - import netsvc order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_cancel', cr) + self.pool.get('mrp.production.workcenter.line').signal_button_cancel(cr, uid, [order.workcenter_lines[0].id]) - I reset first work operation and start after resolving techninal fault of work center. - !python {model: mrp.production}: | - import netsvc order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_draft', cr) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_start_working', cr) + self.pool.get('mrp.production.workcenter.line').signal_button_draft(cr, uid, [order.workcenter_lines[0].id]) + self.pool.get('mrp.production.workcenter.line').signal_button_start_working(cr, uid, [order.workcenter_lines[0].id]) - I close first work operation as this work center completed its process. - !python {model: mrp.production}: | - import netsvc order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order.workcenter_lines[0].id, 'button_done', cr) + self.pool.get('mrp.production.workcenter.line').signal_button_done(cr, uid, [order.workcenter_lines[0].id]) - Now I close other operations one by one which are in start state. - !python {model: mrp.production}: | - import netsvc order = self.browse(cr, uid, ref("mrp.mrp_production_1"), context=context) - wf_service = netsvc.LocalService("workflow") for work_line in order.workcenter_lines[1:]: - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', work_line.id, 'button_start_working', cr) - wf_service.trg_validate(uid, 'mrp.production.workcenter.line', work_line.id, 'button_done', cr) + self.pool.get('mrp.production.workcenter.line').signal_button_start_working(cr, uid, [work_line.id]) + self.pool.get('mrp.production.workcenter.line').signal_button_done(cr, uid, [work_line.id]) - I check that the production order is now done. From 830acb128d8451bebb48c7ab14367d7488a12d57 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 29 Jan 2013 13:28:08 +0100 Subject: [PATCH 14/56] [IMP] purchase: use the new ORM methods create_workflow, delete_workflow, redirect_workflow. bzr revid: vmt@openerp.com-20130129122808-etp3ytphzn2cxnr1 --- addons/purchase/purchase.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index bf3686d5a34..a45da4a2d61 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -487,8 +487,8 @@ class purchase_order(osv.osv): wf_service = netsvc.LocalService("workflow") for p_id in ids: # Deleting the existing instance of workflow for PO - wf_service.trg_delete(uid, 'purchase.order', p_id, cr) - wf_service.trg_create(uid, 'purchase.order', p_id, cr) + self.delete_workflow(cr, uid, [p_id]) # TODO is it necessary to interleave the calls? + self.create_workflow(cr, uid, [p_id]) return True def action_invoice_create(self, cr, uid, ids, context=None): @@ -797,7 +797,7 @@ class purchase_order(osv.osv): # make triggers pointing to the old orders point to the new order for old_id in old_ids: - wf_service.trg_redirect(uid, 'purchase.order', old_id, neworder_id, cr) + self.redirect_workflow(cr, uid, [(old_id, neworder_id)]) self.signal_purchase_cancel(cr, uid, [old_id]) # TODO Is it necessary to interleave the calls? return orders_info From 02a2c8574d101354899ca139221327a36e54a4a1 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Wed, 30 Jan 2013 15:29:03 +0530 Subject: [PATCH 15/56] [IMP] hr_holidays:use the new ORM methods create_workflow, delete_workflow, redirect_workflow. bzr revid: cha@tinyerp.com-20130130095903-6exhtm6uruk0ek30 --- addons/hr_holidays/hr_holidays.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 234897809e1..ce30951f7a9 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -304,10 +304,9 @@ class hr_holidays(osv.osv): 'manager_id': False, 'manager_id2': False, }) - wf_service = netsvc.LocalService("workflow") for id in ids: - wf_service.trg_delete(uid, 'hr.holidays', id, cr) - wf_service.trg_create(uid, 'hr.holidays', id, cr) + self.delete_workflow(cr, uid, [id]) + self.create_workflow(cr, uid, [id]) to_unlink = [] for record in self.browse(cr, uid, ids, context=context): for record2 in record.linked_request_ids: From 19368fb65c24bf21852e50eeae5fb0767f1c1fce Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 10:16:08 +0530 Subject: [PATCH 16/56] [IMP] sale: use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131044608-h5dj2xfqyo8ewm6k --- addons/sale/sale.py | 19 ++++++------------- addons/sale/wizard/sale_line_invoice.py | 3 +-- addons/sale/wizard/sale_make_invoice.py | 6 ++---- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 66653c61849..93556a3e7d5 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -418,8 +418,7 @@ class sale_order(osv.osv): This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow ''' assert len(ids) == 1, 'This option should only be used for a single id at a time' - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'sale.order', ids[0], 'quotation_sent', cr) + self.signal_quotation_sent(cr, uid, [ids[0]]) datas = { 'model': 'sale.order', 'ids': ids, @@ -432,12 +431,10 @@ class sale_order(osv.osv): view of one of the newly created invoices """ mod_obj = self.pool.get('ir.model.data') - wf_service = netsvc.LocalService("workflow") - + # create invoices through the sales orders' workflow inv_ids0 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids) - for id in ids: - wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) + self.signal_manual_invoice(cr, uid, ids) inv_ids1 = set(inv.id for sale in self.browse(cr, uid, ids, context) for inv in sale.invoice_ids) # determine newly created invoices new_inv_ids = list(inv_ids1 - inv_ids0) @@ -555,7 +552,6 @@ class sale_order(osv.osv): return True def action_cancel(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") if context is None: context = {} sale_order_line_obj = self.pool.get('sale.order.line') @@ -566,8 +562,7 @@ class sale_order(osv.osv): _('Cannot cancel this sales order!'), _('First cancel all invoices attached to this sales order.')) for r in self.read(cr, uid, ids, ['invoice_ids']): - for inv in r['invoice_ids']: - wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr) + self.pool.get('account.invoice').signal_invoice_cancel(cr, uid, r['invoice_ids']) sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line], {'state': 'cancel'}) self.write(cr, uid, ids, {'state': 'cancel'}) @@ -575,8 +570,7 @@ class sale_order(osv.osv): def action_button_confirm(self, cr, uid, ids, context=None): assert len(ids) == 1, 'This option should only be used for a single id at a time.' - wf_service = netsvc.LocalService('workflow') - wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr) + self.signal_order_confirm(cr, uid, ids) # redisplay the record as a sales order view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form') @@ -992,8 +986,7 @@ class mail_compose_message(osv.Model): context = context or {} if context.get('default_model') == 'sale.order' and context.get('default_res_id') and context.get('mark_so_as_sent'): context = dict(context, mail_post_autofollow=True) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'sale.order', context['default_res_id'], 'quotation_sent', cr) + self.pool.get('sale.order').signal_quotation_sent(cr, uid, context['default_res_id']) return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py index 4aa58088129..4b18c9a4b39 100644 --- a/addons/sale/wizard/sale_line_invoice.py +++ b/addons/sale/wizard/sale_line_invoice.py @@ -80,7 +80,6 @@ class sale_order_line_make_invoice(osv.osv_memory): sales_order_line_obj = self.pool.get('sale.order.line') sales_order_obj = self.pool.get('sale.order') - wf_service = netsvc.LocalService('workflow') for line in sales_order_line_obj.browse(cr, uid, context.get('active_ids', []), context=context): if (not line.invoiced) and (line.state not in ('draft', 'cancel')): if not line.order_id.id in invoices: @@ -103,7 +102,7 @@ class sale_order_line_make_invoice(osv.osv_memory): flag = False break if flag: - wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'manual_invoice', cr) + sales_order_obj.signal_manual_invoice(cr, uid, line.order_id.id) sales_order_obj.write(cr, uid, [line.order_id.id], {'state': 'progress'}) if not invoices: diff --git a/addons/sale/wizard/sale_make_invoice.py b/addons/sale/wizard/sale_make_invoice.py index d60adbb7b25..608ae0493df 100644 --- a/addons/sale/wizard/sale_make_invoice.py +++ b/addons/sale/wizard/sale_make_invoice.py @@ -52,10 +52,8 @@ class sale_make_invoice(osv.osv_memory): context = {} data = self.read(cr, uid, ids)[0] order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_inv = data['invoice_date']) - wf_service = netsvc.LocalService("workflow") - for id in context.get(('active_ids'), []): - wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr) - + order_obj.signal_manual_invoice(cr, uid, context.get(('active_ids'), [])) + for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context): for i in o.invoice_ids: newinv.append(i.id) From 4fa593ade57fd184f70829d7b70c46ed80ae41be Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 10:42:29 +0530 Subject: [PATCH 17/56] [IMP] sale: for yml use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131051229-r530h3eawm5bm62s --- addons/sale/test/cancel_order.yml | 5 +---- addons/sale/test/manual_order_policy.yml | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/sale/test/cancel_order.yml b/addons/sale/test/cancel_order.yml index cde3a5b34f2..d9d76f19935 100644 --- a/addons/sale/test/cancel_order.yml +++ b/addons/sale/test/cancel_order.yml @@ -51,11 +51,8 @@ I cancel all the invoices. - !python {model: sale.order}: | - import netsvc invoice_ids = self.browse(cr, uid, ref("sale_order_8")).invoice_ids - wf_service = netsvc.LocalService("workflow") - for invoice in invoice_ids: - wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_cancel', cr) + self.pool.get('account.invoice').signal_invoice_cancel(cr, uid, invoice_ids) - I check order status in "Invoice Exception" and related invoice is in cancel state. - diff --git a/addons/sale/test/manual_order_policy.yml b/addons/sale/test/manual_order_policy.yml index 5fe29950176..905f04b01f5 100644 --- a/addons/sale/test/manual_order_policy.yml +++ b/addons/sale/test/manual_order_policy.yml @@ -41,11 +41,8 @@ I open the Invoice. - !python {model: sale.order}: | - import netsvc - wf_service = netsvc.LocalService("workflow") so = self.browse(cr, uid, ref("sale_order_2")) - for invoice in so.invoice_ids: - wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr) + self.pool.get('account.invoice').signal_invoice_open(cr, uid, so.invoice_ids) - I pay the invoice. - From 2ac6d7876f813ece0e13d632b125119f96e035b7 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 11:13:37 +0530 Subject: [PATCH 18/56] [IMP] sale_stock: use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131054337-iph87376e9bhoqpy --- addons/sale_stock/sale_stock.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 1b5ddefbe74..6f891a047a1 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -194,7 +194,6 @@ class sale_order(osv.osv): return res def action_cancel(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") if context is None: context = {} sale_order_line_obj = self.pool.get('sale.order.line') @@ -209,11 +208,9 @@ class sale_order(osv.osv): for mov in pick.move_lines: proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)]) if proc_ids: - for proc in proc_ids: - wf_service.trg_validate(uid, 'procurement.order', proc, 'button_check', cr) + self.pool.get('procurement.order').signal_button_check(cr, uid, proc_ids) for r in self.read(cr, uid, ids, ['picking_ids']): - for pick in r['picking_ids']: - wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr) + self.pool.get('stock.picking').signal_button_cancel(cr, uid, r['picking_ids']) return super(sale_order, self).action_cancel(cr, uid, ids, context=context) def action_wait(self, cr, uid, ids, context=None): @@ -396,11 +393,9 @@ class sale_order(osv.osv): line.write({'procurement_id': proc_id}) self.ship_recreate(cr, uid, order, line, move_id, proc_id) - wf_service = netsvc.LocalService("workflow") if picking_id: - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) - for proc_id in proc_ids: - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) + self.pool.get('stock.picking').signal_button_confirm(cr, uid, [picking_id]) + self.pool.get('procurement.order').signal_button_confirm(cr, uid, proc_ids) val = {} if order.state == 'shipping_except': From 3dfaff6bc3cbe4ad4f479ec6dfb549389126a9cd Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 11:45:33 +0530 Subject: [PATCH 19/56] [IMP] sale_stock: for yml use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131061533-ivbzasitl9a2mi04 --- addons/sale_stock/sale_stock.py | 1 - addons/sale_stock/test/cancel_order_sale_stock.yml | 8 ++------ addons/sale_stock/test/picking_order_policy.yml | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 6f891a047a1..f63282b7a16 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -23,7 +23,6 @@ from datetime import datetime, timedelta from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare from dateutil.relativedelta import relativedelta from openerp.osv import fields, osv -from openerp import netsvc from openerp.tools.translate import _ class sale_shop(osv.osv): diff --git a/addons/sale_stock/test/cancel_order_sale_stock.yml b/addons/sale_stock/test/cancel_order_sale_stock.yml index 6805a90ca80..9081cac9fa3 100644 --- a/addons/sale_stock/test/cancel_order_sale_stock.yml +++ b/addons/sale_stock/test/cancel_order_sale_stock.yml @@ -17,11 +17,9 @@ Now I cancel latest shipment. - !python {model: stock.picking}: | - import netsvc delivery_orders = self.search(cr, uid, [('sale_id','=',ref("sale.sale_order_8"))]) last_delivery_order_id = delivery_orders[0] - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'stock.picking', last_delivery_order_id, 'button_cancel', cr) + self.pool.get('stock.picking').signal_button_cancel(cr, uid, [last_delivery_order_id]) - I run the scheduler. - @@ -50,11 +48,9 @@ To cancel the sale order from Invoice Exception, I have to cancel the invoice of sale order. - !python {model: sale.order}: | - import netsvc invoice_ids = self.browse(cr, uid, ref("sale.sale_order_8")).invoice_ids - wf_service = netsvc.LocalService("workflow") first_invoice_id = invoice_ids[0] - wf_service.trg_validate(uid, 'account.invoice', first_invoice_id.id, 'invoice_cancel', cr) + self.pool.get('account.invoice').signal_invoice_cancel(cr, uid, [first_invoice_id.id]) - I check order status in "Invoice Exception" and related invoice is in cancel state. - diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml index 800c131e288..a28326598ac 100644 --- a/addons/sale_stock/test/picking_order_policy.yml +++ b/addons/sale_stock/test/picking_order_policy.yml @@ -132,11 +132,9 @@ I open the Invoice. - !python {model: sale.order}: | - import netsvc - wf_service = netsvc.LocalService("workflow") so = self.browse(cr, uid, ref("sale.sale_order_6")) for invoice in so.invoice_ids: - wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr) + self.pool.get('account.invoice').signal_invoice_open(cr, uid, [invoice.id]) - I pay the invoice - From ba02e50efacdc621130aff19e02c6d0e69c07a7d Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 12:03:33 +0530 Subject: [PATCH 20/56] [IMP] hr_payroll: use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131063333-jhcpvbingaqxroiq --- addons/hr_payroll/hr_payroll.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index b711ed1a9c4..06af3054b68 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -26,7 +26,6 @@ from datetime import datetime from datetime import timedelta from dateutil import relativedelta -from openerp import netsvc from openerp.osv import fields, osv from openerp import tools from openerp.tools.translate import _ @@ -331,13 +330,12 @@ class hr_payslip(osv.osv): def refund_sheet(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') - wf_service = netsvc.LocalService("workflow") for payslip in self.browse(cr, uid, ids, context=context): id_copy = self.copy(cr, uid, payslip.id, {'credit_note': True, 'name': _('Refund: ')+payslip.name}, context=context) self.compute_sheet(cr, uid, [id_copy], context=context) - wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'hr_verify_sheet', cr) - wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'process_sheet', cr) - + self.signal_hr_verify_sheet(cr, uid, [id_copy]) + self.signal_process_sheet(cr, uid, [id_copy]) + form_id = mod_obj.get_object_reference(cr, uid, 'hr_payroll', 'view_hr_payslip_form') form_res = form_id and form_id[1] or False tree_id = mod_obj.get_object_reference(cr, uid, 'hr_payroll', 'view_hr_payslip_tree') From da43da8f3b54be5c4e5392f567d51057d2b250c9 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 14:54:40 +0530 Subject: [PATCH 21/56] [IMP] hr_timesheet_sheet: use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131092440-gxhz5y5rxkfuy9k3 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index c473670b014..d9b76dcfb89 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -93,8 +93,7 @@ class hr_timesheet_sheet(osv.osv): self.check_employee_attendance_state(cr, uid, sheet.id, context=context) di = sheet.user_id.company_id.timesheet_max_difference if (abs(sheet.total_difference) < di) or not di: - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'hr_timesheet_sheet.sheet', sheet.id, 'confirm', cr) + self.signal_confirm(cr, uid, [sheet.id]) else: raise osv.except_osv(_('Warning!'), _('Please verify that the total difference of the sheet is lower than %.2f.') %(di,)) return True @@ -192,9 +191,8 @@ class hr_timesheet_sheet(osv.osv): def action_set_to_draft(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'draft'}) - wf_service = netsvc.LocalService('workflow') for id in ids: - wf_service.trg_create(uid, self._name, id, cr) + self.create_workflow(cr, uid, [id]) return True def name_get(self, cr, uid, ids, context=None): From 4b7ad7da5633f31b1b06237a8e1a4f5985f12555 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 14:59:50 +0530 Subject: [PATCH 22/56] [IMP] removed unused import bzr revid: cha@tinyerp.com-20130131092950-mm2xjuv2j2t0gk7v --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index d9b76dcfb89..5948c02bc5e 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -25,7 +25,6 @@ from dateutil.relativedelta import relativedelta from openerp.osv import fields, osv from openerp.tools.translate import _ -from openerp import netsvc class hr_timesheet_sheet(osv.osv): _name = "hr_timesheet_sheet.sheet" From d43fa7273659c2600c74d6b8b6ac4a6c62c9f2f2 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 15:09:01 +0530 Subject: [PATCH 23/56] [FIX] l10n_in_hr_payroll: removed unused imports. bzr revid: cha@tinyerp.com-20130131093901-423rr2g3h5ke0vpb --- addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py b/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py index da98bbe681a..6a7638d919a 100644 --- a/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py +++ b/addons/l10n_in_hr_payroll/l10n_in_hr_payroll.py @@ -26,7 +26,6 @@ from calendar import isleap from openerp.tools.translate import _ from openerp.osv import fields, osv -from openerp import netsvc import openerp.addons.decimal_precision as dp DATETIME_FORMAT = "%Y-%m-%d" @@ -179,7 +178,6 @@ class hr_payslip_run(osv.osv): return res def create_advice(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") payslip_pool = self.pool.get('hr.payslip') payslip_line_pool = self.pool.get('hr.payslip.line') advice_pool = self.pool.get('hr.payroll.advice') From 4ce0098aa72d05fbfa332c61b694228eb5bf95fd Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 15:17:28 +0530 Subject: [PATCH 24/56] [FIX] purchase: removed unused imports. bzr revid: cha@tinyerp.com-20130131094728-944bmu3sa1dmbhzy --- addons/purchase/purchase.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index a45da4a2d61..e76bf4a0358 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -25,7 +25,6 @@ from dateutil.relativedelta import relativedelta from operator import attrgetter from openerp.osv import fields, osv -from openerp import netsvc from openerp import pooler from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp @@ -484,7 +483,6 @@ class purchase_order(osv.osv): if not len(ids): return False self.write(cr, uid, ids, {'state':'draft','shipped':0}) - wf_service = netsvc.LocalService("workflow") for p_id in ids: # Deleting the existing instance of workflow for PO self.delete_workflow(cr, uid, [p_id]) # TODO is it necessary to interleave the calls? @@ -777,7 +775,6 @@ class purchase_order(osv.osv): allorders = [] orders_info = {} - wf_service = netsvc.LocalService("workflow") for order_key, (order_data, old_ids) in new_orders.iteritems(): # skip merges with only one order if len(old_ids) < 2: From de90c600cdc9771494b17504ddc63024f5d18f6c Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 15:25:41 +0530 Subject: [PATCH 25/56] [FIX] purchase: removed unused imports from yml. bzr revid: cha@tinyerp.com-20130131095541-2p4hocnztgrkvp98 --- addons/purchase/test/process/rfq2order2done.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/purchase/test/process/rfq2order2done.yml b/addons/purchase/test/process/rfq2order2done.yml index be68a8ca01e..ff9158b3c09 100644 --- a/addons/purchase/test/process/rfq2order2done.yml +++ b/addons/purchase/test/process/rfq2order2done.yml @@ -59,9 +59,7 @@ I Validate Invoice of Purchase Order. - !python {model: purchase.order}: | - import netsvc invoice_ids = [x.id for x in self.browse(cr, uid, ref("purchase_order_1")).invoice_ids] - wf_service = netsvc.LocalService("workflow") self.pool.get('account.invoice').signal_invoice_open(cr, uid, invoice_ids) - I check that purchase order is invoiced. From 8045a7556d4fcef4a9640828e84fb799370d9a18 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 16:00:15 +0530 Subject: [PATCH 26/56] [IMP] purchase_requisition: use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131103015-ooa3nr4j6qllpfgk --- addons/purchase_requisition/purchase_requisition.py | 4 +--- addons/purchase_requisition/test/purchase_requisition.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index f773bbd8505..79b8cce4bd5 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -22,7 +22,6 @@ from datetime import datetime from dateutil.relativedelta import relativedelta import time -from openerp import netsvc from openerp.osv import fields,osv from openerp.tools.translate import _ @@ -211,8 +210,7 @@ class purchase_order(osv.osv): proc_ids = proc_obj.search(cr, uid, [('purchase_id', '=', order.id)]) if proc_ids and po.state=='confirmed': proc_obj.write(cr, uid, proc_ids, {'purchase_id': po.id}) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', order.id, 'purchase_cancel', cr) + self.signal_purchase_cancel(cr, uid, [order.id]) po.requisition_id.tender_done(context=context) return res diff --git a/addons/purchase_requisition/test/purchase_requisition.yml b/addons/purchase_requisition/test/purchase_requisition.yml index 38e66788dcf..f23737d21b8 100644 --- a/addons/purchase_requisition/test/purchase_requisition.yml +++ b/addons/purchase_requisition/test/purchase_requisition.yml @@ -69,10 +69,8 @@ I confirmed RFQ which has best price. - !python {model: purchase.order}: | - import netsvc - wf_service = netsvc.LocalService("workflow") purchase = self.browse(cr, uid, ref('rfq2'), context=context) - wf_service.trg_validate(uid, 'purchase.order', purchase.id, 'purchase_confirm', cr) + self.signal_purchase_confirm(cr, uid, [purchase.id]) - I check status of requisition after confirmed best RFQ. From fc374647a9c0dad7411992d799132c0475fbaf38 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 16:49:52 +0530 Subject: [PATCH 27/56] [IMP] procurement: use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130131111952-tnq7iiwj9u5opyge --- addons/procurement/procurement.py | 1 - addons/procurement/schedulers.py | 3 --- addons/procurement/wizard/make_procurement_product.py | 6 ++---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 21c260b99cd..30d870647e2 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -456,7 +456,6 @@ class procurement_order(osv.osv): class StockPicking(osv.osv): _inherit = 'stock.picking' def test_finished(self, cr, uid, ids): - wf_service = netsvc.LocalService("workflow") res = super(StockPicking, self).test_finished(cr, uid, ids) for picking in self.browse(cr, uid, ids): for move in picking.move_lines: diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 76b31cc6da3..c09d9a22a16 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -57,7 +57,6 @@ class procurement_order(osv.osv): try: if use_new_cursor: cr = pooler.get_db(use_new_cursor).cursor() - wf_service = netsvc.LocalService("workflow") procurement_obj = self.pool.get('procurement.order') if not ids: @@ -154,7 +153,6 @@ class procurement_order(osv.osv): product_obj = self.pool.get('product.product') proc_obj = self.pool.get('procurement.order') warehouse_obj = self.pool.get('stock.warehouse') - wf_service = netsvc.LocalService("workflow") warehouse_ids = warehouse_obj.search(cr, uid, [], context=context) products_ids = product_obj.search(cr, uid, [('purchase_ok', '=', True)], order='id', context=context) @@ -224,7 +222,6 @@ class procurement_order(osv.osv): orderpoint_obj = self.pool.get('stock.warehouse.orderpoint') procurement_obj = self.pool.get('procurement.order') - wf_service = netsvc.LocalService("workflow") offset = 0 ids = [1] if automatic: diff --git a/addons/procurement/wizard/make_procurement_product.py b/addons/procurement/wizard/make_procurement_product.py index 34a146289f6..fa159780af2 100644 --- a/addons/procurement/wizard/make_procurement_product.py +++ b/addons/procurement/wizard/make_procurement_product.py @@ -19,7 +19,6 @@ # ############################################################################## -from openerp import netsvc from openerp.osv import fields, osv @@ -64,7 +63,6 @@ class make_procurement(osv.osv_memory): user = self.pool.get('res.users').browse(cr, uid, uid, context=context).login wh_obj = self.pool.get('stock.warehouse') procurement_obj = self.pool.get('procurement.order') - wf_service = netsvc.LocalService("workflow") data_obj = self.pool.get('ir.model.data') for proc in self.browse(cr, uid, ids, context=context): @@ -78,8 +76,8 @@ class make_procurement(osv.osv_memory): 'location_id': wh.lot_stock_id.id, 'procure_method':'make_to_order', }) - - wf_service.trg_validate(uid, 'procurement.order', procure_id, 'button_confirm', cr) + + self.pool.get('procurement.order').signal_button_confirm(cr, uid, [procure_id]) id2 = data_obj._get_id(cr, uid, 'procurement', 'procurement_tree_view') From d4328ba8d57010a669efc1724264fba534f88b46 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 17:29:54 +0530 Subject: [PATCH 28/56] [IMP] account_voucher: : use the new ORM methods create_workflow, delete_workflow, redirect_workflow. bzr revid: cha@tinyerp.com-20130131115954-54u8z5ibntrs4sco --- addons/account_voucher/account_voucher.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 2046d787ef3..2e808e26b75 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -22,7 +22,6 @@ import time from lxml import etree -from openerp import netsvc from openerp.osv import fields, osv import openerp.addons.decimal_precision as dp from openerp.tools.translate import _ @@ -828,9 +827,7 @@ class account_voucher(osv.osv): return True def action_cancel_draft(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") - for voucher_id in ids: - wf_service.trg_create(uid, 'account.voucher', voucher_id, cr) + self.create_workflow(cr, uid, ids) self.write(cr, uid, ids, {'state':'draft'}) return True From eebaf0767ed79a70cc999ff32cae325bc81aa839 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Thu, 31 Jan 2013 17:30:47 +0530 Subject: [PATCH 29/56] [IMP] mrp_operation: use the new ORM methods create_workflow, delete_workflow, redirect_workflow. bzr revid: tta@openerp.com-20130131120047-9ehhi00keo0p6gjq --- addons/mrp_operations/mrp_operations.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index a60b348559c..cce27d3a6c2 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -500,7 +500,6 @@ class mrp_operations_operation(osv.osv): def create(self, cr, uid, vals, context=None): workcenter_pool = self.pool.get('mrp.production.workcenter.line') - wf_service = netsvc.LocalService('workflow') code_ids=self.pool.get('mrp_operations.operation.code').search(cr,uid,[('id','=',vals['code_id'])]) code=self.pool.get('mrp_operations.operation.code').browse(cr, uid, code_ids, context=context)[0] wc_op_id=workcenter_pool.search(cr,uid,[('workcenter_id','=',vals['workcenter_id']),('production_id','=',vals['production_id'])]) @@ -545,10 +544,9 @@ class mrp_operations_operation(osv.osv): return super(mrp_operations_operation, self).create(cr, uid, vals, context=context) def initialize_workflow_instance(self, cr, uid, context=None): - wf_service = netsvc.LocalService("workflow") - line_ids = self.pool.get('mrp.production.workcenter.line').search(cr, uid, [], context=context) - for line_id in line_ids: - wf_service.trg_create(uid, 'mrp.production.workcenter.line', line_id, cr) + mrp_production_workcenter_line = self.pool.get('mrp.production.workcenter.line') + line_ids = mrp_production_workcenter_line.search(cr, uid, [], context=context) + mrp_production_workcenter_line.create_workflow(cr, uid, line_ids) return True _columns={ From 401b039e809598fc9e242f9dda1a34545430219d Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Thu, 31 Jan 2013 17:49:15 +0530 Subject: [PATCH 30/56] [IMP] mrp: use the new signal_xxx method instead of trg_validate. bzr revid: tta@openerp.com-20130131121915-gahj7t5ob6s2y0q8 --- addons/mrp/mrp.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 44fbaafbcfe..b8081f461d6 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -27,7 +27,6 @@ from openerp.osv import fields, osv from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP from openerp.tools import float_compare from openerp.tools.translate import _ -from openerp import netsvc from openerp import tools #---------------------------------------------------------- @@ -775,8 +774,7 @@ class mrp_production(osv.osv): for new_parent_id in new_parent_ids: stock_mov_obj.write(cr, uid, [raw_product.id], {'move_history_ids': [(4,new_parent_id)]}) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce_done', cr) + self.signal_button_produce_done(cr, uid, [production_id]) return True def _costs_generate(self, cr, uid, production): @@ -844,7 +842,6 @@ class mrp_production(osv.osv): return True def _make_production_line_procurement(self, cr, uid, production_line, shipment_move_id, context=None): - wf_service = netsvc.LocalService("workflow") procurement_order = self.pool.get('procurement.order') production = production_line.production_id location_id = production.location_src_id.id @@ -864,7 +861,7 @@ class mrp_production(osv.osv): 'move_id': shipment_move_id, 'company_id': production.company_id.id, }) - wf_service.trg_validate(uid, procurement_order._name, procurement_id, 'button_confirm', cr) + self.signal_button_confirm(cr, uid, [procurement_id]) return procurement_id def _make_production_internal_shipment_line(self, cr, uid, production_line, shipment_id, parent_move_id, destination_location_id=False, context=None): @@ -977,7 +974,6 @@ class mrp_production(osv.osv): @return: Newly generated Shipment Id. """ shipment_id = False - wf_service = netsvc.LocalService("workflow") uncompute_ids = filter(lambda x:x, [not x.product_lines and x.id or False for x in self.browse(cr, uid, ids, context=context)]) self.action_compute(cr, uid, uncompute_ids, context=context) for production in self.browse(cr, uid, ids, context=context): @@ -995,7 +991,7 @@ class mrp_production(osv.osv): destination_location_id=source_location_id, context=context) self._make_production_line_procurement(cr, uid, line, shipment_move_id, context=context) - wf_service.trg_validate(uid, 'stock.picking', shipment_id, 'button_confirm', cr) + self.registry('stock.picking').signal_button_confirm(cr, uid, [shipment_id]) production.write({'state':'confirmed'}, context=context) return shipment_id From 9a1d53ba2dbd3f5c7e42696f3aef8e4963754013 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Thu, 31 Jan 2013 18:01:22 +0530 Subject: [PATCH 31/56] [IMP] account_payment: : use the new ORM methods create_workflow, delete_workflow, redirect_workflow. bzr revid: cha@tinyerp.com-20130131123122-td7ebesygpa605y0 --- addons/account_payment/account_payment.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index c57c83aa765..bf0377111a8 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -23,7 +23,6 @@ import logging import time from openerp.osv import fields, osv -from openerp import netsvc _logger = logging.getLogger(__name__) @@ -120,9 +119,7 @@ class payment_order(osv.osv): def set_to_draft(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'draft'}) - wf_service = netsvc.LocalService("workflow") - for id in ids: - wf_service.trg_create(uid, 'payment.order', id, cr) + self.create_workflow(cr, uid, ids) return True def action_open(self, cr, uid, ids, *args): From c35416245f1932361e65fb7cfbe75a0aee3c1372 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Thu, 31 Jan 2013 18:18:41 +0530 Subject: [PATCH 32/56] [IMP] mrp_repain: use the new signal_xxx method instead of trg_validate. bzr revid: tta@openerp.com-20130131124841-ej81d0ethz8859r0 --- addons/mrp_repair/mrp_repair.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 8c43158a876..7bb12b0402a 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -20,7 +20,6 @@ ############################################################################## from openerp.osv import fields,osv -from openerp import netsvc from datetime import datetime from dateutil.relativedelta import relativedelta from openerp.tools.translate import _ @@ -314,9 +313,7 @@ class mrp_repair(osv.osv): for repair in self.browse(cr, uid, ids): mrp_line_obj.write(cr, uid, [l.id for l in repair.operations], {'state': 'draft'}) self.write(cr, uid, ids, {'state':'draft'}) - wf_service = netsvc.LocalService("workflow") - for id in ids: - wf_service.trg_create(uid, 'mrp.repair', id, cr) + self.create_workflow(cr, uid, ids) return True def action_confirm(self, cr, uid, ids, *args): @@ -505,7 +502,6 @@ class mrp_repair(osv.osv): """ res = {} move_obj = self.pool.get('stock.move') - wf_service = netsvc.LocalService("workflow") repair_line_obj = self.pool.get('mrp.repair.line') seq_obj = self.pool.get('ir.sequence') pick_obj = self.pool.get('stock.picking') @@ -548,7 +544,7 @@ class mrp_repair(osv.osv): 'tracking_id': False, 'state': 'assigned', }) - wf_service.trg_validate(uid, 'stock.picking', picking, 'button_confirm', cr) + self.registry.signal_button_confirm(cr, uid, [picking]) self.write(cr, uid, [repair.id], {'state': 'done', 'picking_id': picking}) res[repair.id] = picking else: From f63497e12ff9c933706dec07ba13d6432bd7199a Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Thu, 31 Jan 2013 18:36:50 +0530 Subject: [PATCH 33/56] [IMP] hr_expense: cleanup the code for workflow declaration. bzr revid: tta@openerp.com-20130131130650-szwdnjyqiohdimio --- addons/hr_expense/hr_expense.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index f32479c2ae2..0b6ec48974b 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -21,7 +21,6 @@ import time -from openerp import netsvc from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -152,7 +151,6 @@ class hr_expense_expense(osv.osv): account_journal = self.pool.get('account.journal') voucher_obj = self.pool.get('account.voucher') currency_obj = self.pool.get('res.currency') - wkf_service = netsvc.LocalService("workflow") if context is None: context = {} for exp in self.browse(cr, uid, ids, context=context): From d80d06514474fc33a262b4e9a736b67e72cae029 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Thu, 31 Jan 2013 18:41:07 +0530 Subject: [PATCH 34/56] [IMP] hr_payroll_account: use the new signal_xxx method instead of trg_validate. bzr revid: tta@openerp.com-20130131131107-4h42x3g19blw6jzw --- addons/hr_payroll_account/test/hr_payroll_account.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/hr_payroll_account/test/hr_payroll_account.yml b/addons/hr_payroll_account/test/hr_payroll_account.yml index 5abf7d5dffa..ad0197c7905 100644 --- a/addons/hr_payroll_account/test/hr_payroll_account.yml +++ b/addons/hr_payroll_account/test/hr_payroll_account.yml @@ -104,10 +104,8 @@ I want to check cancel button. So I first cancel the sheet then make it set to draft. - !python {model: hr.payslip}: | - import netsvc - wf_service = netsvc.LocalService("workflow") self.cancel_sheet(cr, uid, [ref("hr_payslip_0")], None) - wf_service.trg_validate(uid, 'hr.payslip', ref("hr_payslip_0"), 'draft', cr) + self.signal_draft(cr, uid, [ref("hr_payslip_0")]) - Then I click on the "Confirm" button. - From 0b7fe8278e8050faa6fbd568db2c704fc619254e Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 10:23:11 +0530 Subject: [PATCH 35/56] [IMP] mrp: use the new signal_xxx methods instead of trg_validate. bzr revid: tta@openerp.com-20130201045311-1njirm57d9cd5mff --- addons/mrp/stock.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index ae7edf54750..1ff121c78bd 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -21,7 +21,6 @@ from openerp.osv import fields from openerp.osv import osv -from openerp import netsvc class StockMove(osv.osv): @@ -45,7 +44,6 @@ class StockMove(osv.osv): move_obj = self.pool.get('stock.move') procurement_obj = self.pool.get('procurement.order') product_obj = self.pool.get('product.product') - wf_service = netsvc.LocalService("workflow") processed_ids = [move.id] if move.product_id.supply_method == 'produce' and move.product_id.procure_method == 'make_to_order': bis = bom_obj.search(cr, uid, [ @@ -90,16 +88,17 @@ class StockMove(osv.osv): 'procure_method': prodobj.procure_method, 'move_id': mid, }) - wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) + procurement_obj.signal_button_confirm(cr, uid, [proc_id]) + move_obj.write(cr, uid, [move.id], { 'location_dest_id': move.location_id.id, # dummy move for the kit 'auto_validate': True, 'picking_id': False, 'state': 'confirmed' }) - for m in procurement_obj.search(cr, uid, [('move_id','=',move.id)], context): - wf_service.trg_validate(uid, 'procurement.order', m, 'button_confirm', cr) - wf_service.trg_validate(uid, 'procurement.order', m, 'button_wait_done', cr) + procurement_ids = procurement_obj.search(cr, uid, [('move_id','=',move.id)], context) + procurement_obj.signal_button_confirm(cr, uid, procurement_ids) + procurement_obj.signal_button_wait_done(cr, uid, procurement_ids) return processed_ids def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None): @@ -110,7 +109,6 @@ class StockMove(osv.osv): """ res = [] production_obj = self.pool.get('mrp.production') - wf_service = netsvc.LocalService("workflow") for move in self.browse(cr, uid, ids): move.action_confirm(context) new_moves = super(StockMove, self).action_consume(cr, uid, [move.id], product_qty, location_id, context=context) @@ -118,7 +116,7 @@ class StockMove(osv.osv): for prod in production_obj.browse(cr, uid, production_ids, context=context): if prod.state == 'confirmed': production_obj.force_production(cr, uid, [prod.id]) - wf_service.trg_validate(uid, 'mrp.production', prod.id, 'button_produce', cr) + production_obj.signal_button_produce(cr, uid, production_ids) for new_move in new_moves: if new_move == move.id: #This move is already there in move lines of production order @@ -135,14 +133,13 @@ class StockMove(osv.osv): """ res = [] production_obj = self.pool.get('mrp.production') - wf_service = netsvc.LocalService("workflow") for move in self.browse(cr, uid, ids, context=context): new_moves = super(StockMove, self).action_scrap(cr, uid, [move.id], product_qty, location_id, context=context) #If we are not scrapping our whole move, tracking and lot references must not be removed #self.write(cr, uid, [move.id], {'prodlot_id': False, 'tracking_id': False}) production_ids = production_obj.search(cr, uid, [('move_lines', 'in', [move.id])]) for prod_id in production_ids: - wf_service.trg_validate(uid, 'mrp.production', prod_id, 'button_produce', cr) + production_obj.signal_button_produce(cr, uid, [prod_id]) for new_move in new_moves: production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]}) res.append(new_move) From 263e0cf4824324d9842cca0688350bee7c726643 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 10:35:51 +0530 Subject: [PATCH 36/56] [IMP] hr_timesheet_invoice: code cleanup unused import. bzr revid: tta@openerp.com-20130201050551-1v45eut2toek9g7x --- addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml | 2 -- .../test/test_hr_timesheet_invoice_no_prod_tax.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml index de19ea8fb3a..0896cf7d517 100644 --- a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml +++ b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml @@ -115,6 +115,4 @@ I click on "Create Invoice" button to create Invoice and validate the invoice. - !python {model: hr.timesheet.invoice.create.final}: | - import netsvc - wkf_service = netsvc.LocalService("workflow") res = self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_final_0")], {"active_ids": [ref("account.analytic_agrolait")]}) diff --git a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml index 68e827e79f1..d00963073f0 100644 --- a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml +++ b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml @@ -114,6 +114,4 @@ I click on "Create Invoice" button to create Invoice and validate the invoice. - !python {model: hr.timesheet.invoice.create.final}: | - import netsvc - wkf_service = netsvc.LocalService("workflow") res = self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_final_0")], {"active_ids": [ref("account.analytic_agrolait")]}) From ddf3057db54a72991bd06b4d577da3c5ab4a2ab8 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 10:42:33 +0530 Subject: [PATCH 37/56] [IMP] mrp: use the new signal_xxx methods instead of trg_validate. bzr revid: tta@openerp.com-20130201051233-tcegov6upxq1jsqo --- addons/mrp/procurement.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 8162c3178dc..1f94f0034ad 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -24,7 +24,6 @@ from dateutil.relativedelta import relativedelta from openerp.osv import fields from openerp.osv import osv from openerp.tools.translate import _ -from openerp import netsvc class procurement_order(osv.osv): _inherit = 'procurement.order' @@ -87,7 +86,6 @@ class procurement_order(osv.osv): company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id production_obj = self.pool.get('mrp.production') move_obj = self.pool.get('stock.move') - wf_service = netsvc.LocalService("workflow") procurement_obj = self.pool.get('procurement.order') for procurement in procurement_obj.browse(cr, uid, ids, context=context): res_id = procurement.move_id.id @@ -112,7 +110,7 @@ class procurement_order(osv.osv): self.write(cr, uid, [procurement.id], {'state': 'running', 'production_id': produce_id}) bom_result = production_obj.action_compute(cr, uid, [produce_id], properties=[x.id for x in procurement.property_ids]) - wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr) + production_obj.signal_button_confirm(cr, uid, [produce_id]) if res_id: move_obj.write(cr, uid, [res_id], {'location_id': procurement.location_id.id}) From 191a095164482f7fe91a897a9ba812dd9c153f46 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 10:50:27 +0530 Subject: [PATCH 38/56] [IMP] membership: use the new signal_xxx methods instead of trg_validate. bzr revid: tta@openerp.com-20130201052027-2c0quhoqligc6ag2 --- addons/membership/test/test_membership.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/membership/test/test_membership.yml b/addons/membership/test/test_membership.yml index 357fcbcfc3e..8e8e7887b44 100644 --- a/addons/membership/test/test_membership.yml +++ b/addons/membership/test/test_membership.yml @@ -42,8 +42,8 @@ membership_lines = membership_line_pool.browse(cr, uid, membership_line_ids) assert membership_lines, _('Membership is not registrated.') membership_line = membership_lines[0] - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.invoice', membership_line.account_invoice_id.id, 'invoice_open', cr) + invoice_pool.signal_invoice_open(cr, uid, [membership_line.account_invoice_id.id]) + - | I'm checking "Current membership state" of "Seagate". It is an "Invoiced Member" or not. - From 89d400f824ba89dc45bc6a982b7b74a64a5f29ed Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 11:11:20 +0530 Subject: [PATCH 39/56] [IMP] mrp_repair: use the new signal_xxx methods instead of trg_validate. bzr revid: tta@openerp.com-20130201054120-lzah0vb83w3ff53z --- addons/mrp_repair/wizard/make_invoice.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/mrp_repair/wizard/make_invoice.py b/addons/mrp_repair/wizard/make_invoice.py index a6e93aca064..9442746d68e 100644 --- a/addons/mrp_repair/wizard/make_invoice.py +++ b/addons/mrp_repair/wizard/make_invoice.py @@ -19,7 +19,6 @@ # ############################################################################## -from openerp import netsvc from openerp.osv import fields, osv class make_invoice(osv.osv_memory): @@ -50,9 +49,7 @@ class make_invoice(osv.osv_memory): # We have to trigger the workflow of the given repairs, otherwise they remain 'to be invoiced'. # Note that the signal 'action_invoice_create' will trigger another call to the method 'action_invoice_create', # but that second call will not do anything, since the repairs are already invoiced. - wf_service = netsvc.LocalService("workflow") - for repair_id in context['active_ids']: - wf_service.trg_validate(uid, 'mrp.repair', repair_id, 'action_invoice_create', cr) + order_obj.signal_action_invoice_create(cr, uid, context['active_ids']) form_res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form') form_id = form_res and form_res[1] or False From 048907a80f9f24986fdba0a0d462adb9dd1e94b1 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 11:38:37 +0530 Subject: [PATCH 40/56] [IMP] sale_mrp: use the new signal_xxx methods instead of trg_validate. bzr revid: tta@openerp.com-20130201060837-6uiv82cobhwjhimg --- addons/sale_mrp/test/sale_mrp.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/sale_mrp/test/sale_mrp.yml b/addons/sale_mrp/test/sale_mrp.yml index 6fd64301af2..c2eff008943 100644 --- a/addons/sale_mrp/test/sale_mrp.yml +++ b/addons/sale_mrp/test/sale_mrp.yml @@ -103,11 +103,8 @@ !python {model: procurement.order}: | sale_order_obj = self.pool.get('sale.order') so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - import netsvc - wf_service = netsvc.LocalService("workflow") proc_ids = self.search(cr, uid, [('origin','=',so.name)]) - for proc in proc_ids: - wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr) + self.signal_button_check(cr, uid, proc_ids) - I verify that a procurement state is "running" - From 3589c008ad440ea18d8f382c590228977af7c70e Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 11:54:21 +0530 Subject: [PATCH 41/56] [IMP] POS: use the new signal_xxx methods instead of trg_validate. bzr revid: cha@tinyerp.com-20130201062421-luknla6wp3yqxhqm --- addons/point_of_sale/point_of_sale.py | 20 ++++++++----------- addons/point_of_sale/wizard/pos_confirm.py | 4 +--- addons/point_of_sale/wizard/pos_payment.py | 4 +--- addons/point_of_sale/wizard/pos_return.py | 10 +++------- .../wizard/pos_session_opening.py | 4 +--- 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 970eb1fbed7..9b9e5b951b4 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -27,7 +27,7 @@ import pdb import time import openerp -from openerp import netsvc, tools +from openerp import tools from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -442,8 +442,7 @@ class pos_session(osv.osv): } def _confirm_orders(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") - + for session in self.browse(cr, uid, ids, context=context): order_ids = [order.id for order in session.order_ids if order.state == 'paid'] @@ -457,7 +456,7 @@ class pos_session(osv.osv): _('Error!'), _("You cannot confirm all orders of this session, because they have not the 'paid' status")) else: - wf_service.trg_validate(uid, 'pos.order', order.id, 'done', cr) + self.pool.get('pos.order').signal_done(cr, uid, [order.id]) return True @@ -519,8 +518,7 @@ class pos_order(osv.osv): 'journal': cash_journal.id, }, context=context) order_ids.append(order_id) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'pos.order', order_id, 'paid', cr) + self.signal_paid(cr, uid, [order_id]) return order_ids def unlink(self, cr, uid, ids, context=None): @@ -695,9 +693,8 @@ class pos_order(osv.osv): }, context=context) if line.qty < 0: location_id, output_id = output_id, location_id - - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) + + self.pool.get('stock.picking').signal_button_confirm(cr, uid, [picking_id]) picking_obj.force_assign(cr, uid, [picking_id], context) return True @@ -707,7 +704,7 @@ class pos_order(osv.osv): """ stock_picking_obj = self.pool.get('stock.picking') for order in self.browse(cr, uid, ids, context=context): - wf_service.trg_validate(uid, 'stock.picking', order.picking_id.id, 'button_cancel', cr) + self.pool.get('stock.picking').signal_button_cancel(cr, uid, [order.picking_id.id]) if stock_picking_obj.browse(cr, uid, order.picking_id.id, context=context).state <> 'cancel': raise osv.except_osv(_('Error!'), _('Unable to cancel the picking.')) self.write(cr, uid, ids, {'state': 'cancel'}, context=context) @@ -803,7 +800,6 @@ class pos_order(osv.osv): return self.write(cr, uid, ids, {'state':'invoiced'}, context=context) def action_invoice(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") inv_ref = self.pool.get('account.invoice') inv_line_ref = self.pool.get('account.invoice.line') product_obj = self.pool.get('product.product') @@ -857,7 +853,7 @@ class pos_order(osv.osv): and [(6, 0, inv_line['invoice_line_tax_id'])] or [] inv_line_ref.create(cr, uid, inv_line, context=context) inv_ref.button_reset_taxes(cr, uid, [inv_id], context=context) - wf_service.trg_validate(uid, 'pos.order', order.id, 'invoice', cr) + self.signal_invoice(cr, uid, [order.id]) if not inv_ids: return {} diff --git a/addons/point_of_sale/wizard/pos_confirm.py b/addons/point_of_sale/wizard/pos_confirm.py index 4dec36685f0..ebc432a846f 100644 --- a/addons/point_of_sale/wizard/pos_confirm.py +++ b/addons/point_of_sale/wizard/pos_confirm.py @@ -19,7 +19,6 @@ # ############################################################################## -from openerp import netsvc from openerp.osv import osv @@ -28,7 +27,6 @@ class pos_confirm(osv.osv_memory): _description = 'Post POS Journal Entries' def action_confirm(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") order_obj = self.pool.get('pos.order') ids = order_obj.search(cr, uid, [('state','=','paid')], context=context) for order in order_obj.browse(cr, uid, ids, context=context): @@ -38,7 +36,7 @@ class pos_confirm(osv.osv_memory): todo = False break if todo: - wf_service.trg_validate(uid, 'pos.order', order.id, 'done', cr) + self.pool.get('pos.order').signal_done(cr, uid, [order.id]) # Check if there is orders to reconcile their invoices ids = order_obj.search(cr, uid, [('state','=','invoiced'),('invoice_id.state','=','open')], context=context) diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index 0a1684ca9ca..5f90f267f7e 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -23,7 +23,6 @@ import time import pos_box_entries -from openerp import netsvc from openerp.osv import osv, fields from openerp.tools.translate import _ @@ -67,8 +66,7 @@ class pos_make_payment(osv.osv_memory): order_obj.add_payment(cr, uid, active_id, data, context=context) if order_obj.test_paid(cr, uid, [active_id]): - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'pos.order', active_id, 'paid', cr) + self.pool.get('pos.order').signal_paid(cr, uid, [active_id]) return {'type' : 'ir.actions.act_window_close' } ##self.print_report(cr, uid, ids, context=context) diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py index d6dfdd1e183..f711a2e56ee 100644 --- a/addons/point_of_sale/wizard/pos_return.py +++ b/addons/point_of_sale/wizard/pos_return.py @@ -19,7 +19,6 @@ # ############################################################################## -from openerp import netsvc from openerp.osv import osv,fields from openerp.tools.translate import _ import time @@ -104,7 +103,6 @@ class pos_return(osv.osv_memory): property_obj= self.pool.get("ir.property") uom_obj =self. pool.get('product.uom') statementl_obj = self.pool.get('account.bank.statement.line') - wf_service = netsvc.LocalService("workflow") #Todo :Need to clean the code if active_id: data = self.browse(cr, uid, ids, context=context)[0] @@ -157,7 +155,7 @@ class pos_return(osv.osv_memory): 'amount': -amount, }) order_obj.write(cr,uid, [active_id,new_order], {'state': 'done'}) - wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) + self.pool.get('stock.picking').signal_button_confirm(cr, uid, [new_picking]) picking_obj.force_assign(cr, uid, [new_picking], context) act = { 'domain': "[('id', 'in', ["+str(new_order)+"])]", @@ -200,7 +198,6 @@ class add_product(osv.osv_memory): date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') - wf_service = netsvc.LocalService("workflow") order_obj.add_product(cr, uid, active_id, data['product_id'], data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [active_id], context=context): @@ -232,7 +229,7 @@ class add_product(osv.osv_memory): 'date':date_cur }) - wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) + self.pool.get('stock.picking').signal_button_confirm(cr, uid, [new_picking]) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,active_id,{'picking_id':new_picking}) @@ -265,7 +262,6 @@ class add_product(osv.osv_memory): if return_id: data = return_boj.read(cr,uid,return_id,[])[0] - wf_service = netsvc.LocalService("workflow") self_data = self.browse(cr, uid, ids, context=context)[0] order_obj.add_product(cr, uid, active_ids[0], self_data.product_id.id, self_data.quantity, context=context) @@ -306,7 +302,7 @@ class add_product(osv.osv_memory): 'name':'%s (return)' % order_id.name, 'date':date_cur, }) - wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) + self.poolget('stock.picking').signal_button_confirm(cr, uid, [new_picking]) picking_obj.force_assign(cr, uid, [new_picking], context) obj=order_obj.browse(cr,uid, active_ids[0]) context.update({'return':'return'}) diff --git a/addons/point_of_sale/wizard/pos_session_opening.py b/addons/point_of_sale/wizard/pos_session_opening.py index 1aa4cb702c4..e0135de0cdb 100644 --- a/addons/point_of_sale/wizard/pos_session_opening.py +++ b/addons/point_of_sale/wizard/pos_session_opening.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from openerp import netsvc from openerp.osv import osv, fields from openerp.tools.translate import _ @@ -37,9 +36,8 @@ class pos_session_opening(osv.osv_memory): } def open_existing_session_cb_close(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService("workflow") wizard = self.browse(cr, uid, ids[0], context=context) - wf_service.trg_validate(uid, 'pos.session', wizard.pos_session_id.id, 'cashbox_control', cr) + self.pool.get('pos.session').signal_cashbox_control(cr, uid, [wizard.pos_session_id.id]) return self.open_session_cb(cr, uid, ids, context) def open_session_cb(self, cr, uid, ids, context=None): From b5a9ccbe11af41f0b11e4b07ea6e10eecce72d69 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 12:17:40 +0530 Subject: [PATCH 42/56] [IMP] account: use the new signal_xxx methods instead of trg_validate and also update code with create_workflow and delete_workflow feature. bzr revid: tta@openerp.com-20130201064740-wxigbf179uf6dnnt --- addons/account/account_invoice.py | 10 +++------- addons/account/wizard/account_state_open.py | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 250a0446534..d7b2052305b 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -23,7 +23,6 @@ import time from lxml import etree import openerp.addons.decimal_precision as dp -from openerp import netsvc from openerp import pooler from openerp.osv import fields, osv, orm from openerp.tools.translate import _ @@ -80,11 +79,10 @@ class account_invoice(osv.osv): def _reconciled(self, cr, uid, ids, name, args, context=None): res = {} - wf_service = netsvc.LocalService("workflow") for inv in self.browse(cr, uid, ids, context=context): res[inv.id] = self.test_paid(cr, uid, [inv.id]) if not res[inv.id] and inv.state == 'paid': - wf_service.trg_validate(uid, 'account.invoice', inv.id, 'open_test', cr) + self.signal_open_test(cr, uid, [inv.id]) return res def _get_reference_type(self, cr, uid, context=None): @@ -638,10 +636,8 @@ class account_invoice(osv.osv): # go from canceled state to draft state def action_cancel_draft(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state':'draft'}) - wf_service = netsvc.LocalService("workflow") - for inv_id in ids: - wf_service.trg_delete(uid, 'account.invoice', inv_id, cr) - wf_service.trg_create(uid, 'account.invoice', inv_id, cr) + self.delete_workflow(cr, uid, ids) + self.create_workflow(cr, uid, ids) return True # Workflow stuff diff --git a/addons/account/wizard/account_state_open.py b/addons/account/wizard/account_state_open.py index b2cbdc4961b..5d0ae6b66bd 100644 --- a/addons/account/wizard/account_state_open.py +++ b/addons/account/wizard/account_state_open.py @@ -35,8 +35,7 @@ class account_state_open(osv.osv_memory): data_inv = obj_invoice.browse(cr, uid, context['active_ids'][0], context=context) if data_inv.reconciled: raise osv.except_osv(_('Warning!'), _('Invoice is already reconciled.')) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'account.invoice', context['active_ids'][0], 'open_test', cr) + obj_invoice.signal_open_test(cr, uid, context['active_ids'][0]) return {'type': 'ir.actions.act_window_close'} account_state_open() From 27bd0dbfef0802bc621e5b80a82fcbbeea4a7ebe Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 12:29:48 +0530 Subject: [PATCH 43/56] [FIX] sale: did some changes bzr revid: cha@tinyerp.com-20130201065948-oae060lc7f25z1b3 --- addons/sale/sale.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 93556a3e7d5..c8ccfed1cba 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -418,7 +418,7 @@ class sale_order(osv.osv): This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow ''' assert len(ids) == 1, 'This option should only be used for a single id at a time' - self.signal_quotation_sent(cr, uid, [ids[0]]) + self.signal_quotation_sent(cr, uid, ids) datas = { 'model': 'sale.order', 'ids': ids, @@ -986,7 +986,7 @@ class mail_compose_message(osv.Model): context = context or {} if context.get('default_model') == 'sale.order' and context.get('default_res_id') and context.get('mark_so_as_sent'): context = dict(context, mail_post_autofollow=True) - self.pool.get('sale.order').signal_quotation_sent(cr, uid, context['default_res_id']) + self.pool.get('sale.order').signal_quotation_sent(cr, uid, [context['default_res_id']]) return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 0b2a72f0a8e2ef74f53683fddeb7eddfaf60b9d4 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 12:36:28 +0530 Subject: [PATCH 44/56] [FIX] sale: did some changes bzr revid: cha@tinyerp.com-20130201070628-utvt502wrg5ynv44 --- addons/sale/wizard/sale_line_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/wizard/sale_line_invoice.py b/addons/sale/wizard/sale_line_invoice.py index 4b18c9a4b39..fe8432fc7db 100644 --- a/addons/sale/wizard/sale_line_invoice.py +++ b/addons/sale/wizard/sale_line_invoice.py @@ -102,7 +102,7 @@ class sale_order_line_make_invoice(osv.osv_memory): flag = False break if flag: - sales_order_obj.signal_manual_invoice(cr, uid, line.order_id.id) + sales_order_obj.signal_manual_invoice(cr, uid, [line.order_id.id]) sales_order_obj.write(cr, uid, [line.order_id.id], {'state': 'progress'}) if not invoices: From 75ffe3c712a8aabb6f8c1d00ed6642ba45439c4b Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 12:48:33 +0530 Subject: [PATCH 45/56] [IMP] account: use the new signal_xxx methods instead of trg_validate and also update code with create_workflow and delete_workflow feature. bzr revid: tta@openerp.com-20130201071833-x48y4zloat1diqa5 --- addons/account/wizard/account_invoice_refund.py | 5 +---- addons/account/wizard/account_invoice_state.py | 16 +++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 54d6c38a353..68937004dbc 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -23,7 +23,6 @@ import time from openerp.osv import fields, osv from openerp.tools.translate import _ -from openerp import netsvc class account_invoice_refund(osv.osv_memory): @@ -90,7 +89,6 @@ class account_invoice_refund(osv.osv_memory): account_m_line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') - wf_service = netsvc.LocalService('workflow') inv_tax_obj = self.pool.get('account.invoice.tax') inv_line_obj = self.pool.get('account.invoice.line') res_users_obj = self.pool.get('res.users') @@ -161,8 +159,7 @@ class account_invoice_refund(osv.osv_memory): to_reconcile_ids[line.account_id.id] = [line.id] if type(line.reconcile_id) != osv.orm.browse_null: reconcile_obj.unlink(cr, uid, line.reconcile_id.id) - wf_service.trg_validate(uid, 'account.invoice', \ - refund.id, 'invoice_open', cr) + inv_obj.signal_invoice_open(cr, uid, [refund.id]) refund = inv_obj.browse(cr, uid, refund_id[0], context=context) for tmpline in refund.move_id.line_id: if tmpline.account_id.id == inv.account_id.id: diff --git a/addons/account/wizard/account_invoice_state.py b/addons/account/wizard/account_invoice_state.py index f79b4c046e3..9fab19ff42c 100644 --- a/addons/account/wizard/account_invoice_state.py +++ b/addons/account/wizard/account_invoice_state.py @@ -21,7 +21,6 @@ from openerp.osv import osv from openerp.tools.translate import _ -from openerp import netsvc from openerp import pooler class account_invoice_confirm(osv.osv_memory): @@ -33,16 +32,16 @@ class account_invoice_confirm(osv.osv_memory): _description = "Confirm the selected invoices" def invoice_confirm(self, cr, uid, ids, context=None): - wf_service = netsvc.LocalService('workflow') if context is None: context = {} pool_obj = pooler.get_pool(cr.dbname) - data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) - + account_invoice_obj = pool_obj.get('account.invoice') + data_inv = account_invoice_obj.read(cr, uid, context['active_ids'], ['state'], context=context) for record in data_inv: if record['state'] not in ('draft','proforma','proforma2'): raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state.")) - wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_open', cr) + account_invoice_obj.signal_invoice_open(cr, uid, [ record['id'] ]) + return {'type': 'ir.actions.act_window_close'} account_invoice_confirm() @@ -59,14 +58,13 @@ class account_invoice_cancel(osv.osv_memory): def invoice_cancel(self, cr, uid, ids, context=None): if context is None: context = {} - wf_service = netsvc.LocalService('workflow') pool_obj = pooler.get_pool(cr.dbname) - data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) - + account_invoice_obj = pool_obj.get('account.invoice') + data_inv = account_invoice_obj.read(cr, uid, context['active_ids'], ['state'], context=context) for record in data_inv: if record['state'] in ('cancel','paid'): raise osv.except_osv(_('Warning!'), _("Selected invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state.")) - wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_cancel', cr) + account_invoice_obj.signal_invoice_cancel(cr , uid, [record['id']]) return {'type': 'ir.actions.act_window_close'} account_invoice_cancel() From f3c4e973cd74c3be9f47cd254cef69dbbb652c80 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 14:14:04 +0530 Subject: [PATCH 46/56] [FIX] hr_holidays: did some changes. bzr revid: cha@tinyerp.com-20130201084404-uanxza6nx80l8pn9 --- addons/hr_holidays/hr_holidays.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index ce30951f7a9..c81c4062a73 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -27,7 +27,6 @@ from itertools import groupby from operator import attrgetter, itemgetter import math -from openerp import netsvc from openerp import tools from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -304,9 +303,8 @@ class hr_holidays(osv.osv): 'manager_id': False, 'manager_id2': False, }) - for id in ids: - self.delete_workflow(cr, uid, [id]) - self.create_workflow(cr, uid, [id]) + self.delete_workflow(cr, uid, ids) + self.create_workflow(cr, uid, ids) to_unlink = [] for record in self.browse(cr, uid, ids, context=context): for record2 in record.linked_request_ids: From 19685c35a592408b223b8a6b1a7503c6ecb2cd26 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 14:36:21 +0530 Subject: [PATCH 47/56] [FIX] code corrected. bzr revid: tta@openerp.com-20130201090621-sym8rxhgofk6wg9p --- addons/mrp/mrp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index b8081f461d6..9f2d651d3d0 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -991,7 +991,7 @@ class mrp_production(osv.osv): destination_location_id=source_location_id, context=context) self._make_production_line_procurement(cr, uid, line, shipment_move_id, context=context) - self.registry('stock.picking').signal_button_confirm(cr, uid, [shipment_id]) + self.pool.get('stock.picking').signal_button_confirm(cr, uid, [shipment_id]) production.write({'state':'confirmed'}, context=context) return shipment_id From 95a8d5759e6b033978af444813d1436828e640ea Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 14:53:07 +0530 Subject: [PATCH 48/56] [FIX] hr_timesheet_sheet: did some changes. bzr revid: cha@tinyerp.com-20130201092307-yajxn97wnhz3xofj --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 5948c02bc5e..d4e71cedbf5 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -190,8 +190,7 @@ class hr_timesheet_sheet(osv.osv): def action_set_to_draft(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'draft'}) - for id in ids: - self.create_workflow(cr, uid, [id]) + self.create_workflow(cr, uid, ids) return True def name_get(self, cr, uid, ids, context=None): From aded1b1840f3f98e68fcea07cdbc9cf99b4c57e1 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Fri, 1 Feb 2013 15:20:35 +0530 Subject: [PATCH 49/56] [FIX] code corrected for mrp.repair. bzr revid: tta@openerp.com-20130201095035-2hbkwbc9npxf74kr --- addons/mrp_repair/mrp_repair.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 7bb12b0402a..6c3f0ce21e1 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -544,7 +544,7 @@ class mrp_repair(osv.osv): 'tracking_id': False, 'state': 'assigned', }) - self.registry.signal_button_confirm(cr, uid, [picking]) + pick_obj.signal_button_confirm(cr, uid, [picking]) self.write(cr, uid, [repair.id], {'state': 'done', 'picking_id': picking}) res[repair.id] = picking else: From c2ffb389a3d6125461e63f0c85193931a9bdb76f Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 17:36:10 +0530 Subject: [PATCH 50/56] [FIX] sale: Made some changes bzr revid: cha@tinyerp.com-20130201120610-eotziutfkhsgd77o --- addons/sale/test/manual_order_policy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale/test/manual_order_policy.yml b/addons/sale/test/manual_order_policy.yml index 905f04b01f5..d138e917a4d 100644 --- a/addons/sale/test/manual_order_policy.yml +++ b/addons/sale/test/manual_order_policy.yml @@ -42,7 +42,9 @@ - !python {model: sale.order}: | so = self.browse(cr, uid, ref("sale_order_2")) - self.pool.get('account.invoice').signal_invoice_open(cr, uid, so.invoice_ids) + account_invoice_obj = self.pool.get('account.invoice') + for invoice in so.invoice_ids: + account_invoice_obj.signal_invoice_open(cr, uid, [invoice.id]) - I pay the invoice. - From a500b5d24942ee1bc4b1746793fef54f3d800dab Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 18:49:55 +0530 Subject: [PATCH 51/56] [FIX] sale: Made some changes bzr revid: cha@tinyerp.com-20130201131955-nmcaji8bkblipxo3 --- addons/sale/test/cancel_order.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale/test/cancel_order.yml b/addons/sale/test/cancel_order.yml index d9d76f19935..982452bc50e 100644 --- a/addons/sale/test/cancel_order.yml +++ b/addons/sale/test/cancel_order.yml @@ -52,7 +52,9 @@ - !python {model: sale.order}: | invoice_ids = self.browse(cr, uid, ref("sale_order_8")).invoice_ids - self.pool.get('account.invoice').signal_invoice_cancel(cr, uid, invoice_ids) + account_invoice_obj = self.pool.get('account.invoice') + for invoice in invoice_ids: + account_invoice_obj.signal_invoice_cancel(cr, uid, [invoice.id]) - I check order status in "Invoice Exception" and related invoice is in cancel state. - From df29fec0906661bf4cd58f8e2d631b088c8c6193 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 1 Feb 2013 19:04:40 +0530 Subject: [PATCH 52/56] [FIX] sale_stock: Made some changes bzr revid: cha@tinyerp.com-20130201133440-fgo2lj4q22i4dpfb --- addons/sale_stock/sale_stock.py | 3 ++- addons/sale_stock/test/picking_order_policy.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index f63282b7a16..b121bf425b6 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -208,8 +208,9 @@ class sale_order(osv.osv): proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)]) if proc_ids: self.pool.get('procurement.order').signal_button_check(cr, uid, proc_ids) + stock_obj = self.pool.get('stock.picking') for r in self.read(cr, uid, ids, ['picking_ids']): - self.pool.get('stock.picking').signal_button_cancel(cr, uid, r['picking_ids']) + stock_obj.signal_button_cancel(cr, uid, r['picking_ids']) return super(sale_order, self).action_cancel(cr, uid, ids, context=context) def action_wait(self, cr, uid, ids, context=None): diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml index a28326598ac..406aaf0bf8a 100644 --- a/addons/sale_stock/test/picking_order_policy.yml +++ b/addons/sale_stock/test/picking_order_policy.yml @@ -133,8 +133,9 @@ - !python {model: sale.order}: | so = self.browse(cr, uid, ref("sale.sale_order_6")) + account_invoice_obj = self.pool.get('account.invoice') for invoice in so.invoice_ids: - self.pool.get('account.invoice').signal_invoice_open(cr, uid, [invoice.id]) + account_invoice_obj.signal_invoice_open(cr, uid, [invoice.id]) - I pay the invoice - From 85f6cb82390714e86b7b82e81afc0fee798eb7b6 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Mon, 4 Feb 2013 12:11:42 +0530 Subject: [PATCH 53/56] [IMP] POS: made some changes in code bzr revid: cha@tinyerp.com-20130204064142-xivaomscssibwsb8 --- addons/point_of_sale/point_of_sale.py | 4 ++-- addons/point_of_sale/wizard/pos_confirm.py | 2 +- addons/point_of_sale/wizard/pos_payment.py | 2 +- addons/point_of_sale/wizard/pos_return.py | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 9b9e5b951b4..7687ee3aa4e 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -694,7 +694,7 @@ class pos_order(osv.osv): if line.qty < 0: location_id, output_id = output_id, location_id - self.pool.get('stock.picking').signal_button_confirm(cr, uid, [picking_id]) + picking_obj.signal_button_confirm(cr, uid, [picking_id]) picking_obj.force_assign(cr, uid, [picking_id], context) return True @@ -704,7 +704,7 @@ class pos_order(osv.osv): """ stock_picking_obj = self.pool.get('stock.picking') for order in self.browse(cr, uid, ids, context=context): - self.pool.get('stock.picking').signal_button_cancel(cr, uid, [order.picking_id.id]) + stock_picking_obj.signal_button_cancel(cr, uid, [order.picking_id.id]) if stock_picking_obj.browse(cr, uid, order.picking_id.id, context=context).state <> 'cancel': raise osv.except_osv(_('Error!'), _('Unable to cancel the picking.')) self.write(cr, uid, ids, {'state': 'cancel'}, context=context) diff --git a/addons/point_of_sale/wizard/pos_confirm.py b/addons/point_of_sale/wizard/pos_confirm.py index ebc432a846f..f37bdd9f8b8 100644 --- a/addons/point_of_sale/wizard/pos_confirm.py +++ b/addons/point_of_sale/wizard/pos_confirm.py @@ -36,7 +36,7 @@ class pos_confirm(osv.osv_memory): todo = False break if todo: - self.pool.get('pos.order').signal_done(cr, uid, [order.id]) + order_obj.signal_done(cr, uid, [order.id]) # Check if there is orders to reconcile their invoices ids = order_obj.search(cr, uid, [('state','=','invoiced'),('invoice_id.state','=','open')], context=context) diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index 5f90f267f7e..47814761b20 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -66,7 +66,7 @@ class pos_make_payment(osv.osv_memory): order_obj.add_payment(cr, uid, active_id, data, context=context) if order_obj.test_paid(cr, uid, [active_id]): - self.pool.get('pos.order').signal_paid(cr, uid, [active_id]) + order_obj.signal_paid(cr, uid, [active_id]) return {'type' : 'ir.actions.act_window_close' } ##self.print_report(cr, uid, ids, context=context) diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py index f711a2e56ee..b4e0e7b2041 100644 --- a/addons/point_of_sale/wizard/pos_return.py +++ b/addons/point_of_sale/wizard/pos_return.py @@ -155,7 +155,7 @@ class pos_return(osv.osv_memory): 'amount': -amount, }) order_obj.write(cr,uid, [active_id,new_order], {'state': 'done'}) - self.pool.get('stock.picking').signal_button_confirm(cr, uid, [new_picking]) + picking_obj.signal_button_confirm(cr, uid, [new_picking]) picking_obj.force_assign(cr, uid, [new_picking], context) act = { 'domain': "[('id', 'in', ["+str(new_order)+"])]", @@ -229,7 +229,7 @@ class add_product(osv.osv_memory): 'date':date_cur }) - self.pool.get('stock.picking').signal_button_confirm(cr, uid, [new_picking]) + picking_obj.signal_button_confirm(cr, uid, [new_picking]) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,active_id,{'picking_id':new_picking}) @@ -302,7 +302,7 @@ class add_product(osv.osv_memory): 'name':'%s (return)' % order_id.name, 'date':date_cur, }) - self.poolget('stock.picking').signal_button_confirm(cr, uid, [new_picking]) + picking_obj.signal_button_confirm(cr, uid, [new_picking]) picking_obj.force_assign(cr, uid, [new_picking], context) obj=order_obj.browse(cr,uid, active_ids[0]) context.update({'return':'return'}) From f33d11f0a46a15ed2b8c3e82f523b1dd2d641366 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Mon, 4 Feb 2013 12:45:26 +0530 Subject: [PATCH 54/56] [IMP] sale_stock: made some changes in code bzr revid: cha@tinyerp.com-20130204071526-6ey9lfunu4mbnjhn --- addons/sale_stock/sale_stock.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index b121bf425b6..95404ec0a93 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -207,7 +207,7 @@ class sale_order(osv.osv): for mov in pick.move_lines: proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)]) if proc_ids: - self.pool.get('procurement.order').signal_button_check(cr, uid, proc_ids) + proc_obj.signal_button_check(cr, uid, proc_ids) stock_obj = self.pool.get('stock.picking') for r in self.read(cr, uid, ids, ['picking_ids']): stock_obj.signal_button_cancel(cr, uid, r['picking_ids']) @@ -394,8 +394,8 @@ class sale_order(osv.osv): self.ship_recreate(cr, uid, order, line, move_id, proc_id) if picking_id: - self.pool.get('stock.picking').signal_button_confirm(cr, uid, [picking_id]) - self.pool.get('procurement.order').signal_button_confirm(cr, uid, proc_ids) + picking_obj.signal_button_confirm(cr, uid, [picking_id]) + procurement_obj.signal_button_confirm(cr, uid, proc_ids) val = {} if order.state == 'shipping_except': From 55625f52db111c75563a72a04dd3d5e992fadaf9 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 13 Feb 2013 11:18:03 +0100 Subject: [PATCH 55/56] [FIX] fix import statements in yml files bzr revid: rco@openerp.com-20130213101803-4y1ponocx6oai2mz --- addons/account_voucher/test/case1_usd_usd.yml | 2 -- addons/account_voucher/test/case2_suppl_usd_eur.yml | 2 -- .../account_voucher/test/case2_usd_eur_debtor_in_usd.yml | 2 -- addons/account_voucher/test/case3_eur_eur.yml | 2 -- addons/hr_holidays/test/test_hr_holiday.yml | 1 - addons/hr_payroll_account/test/hr_payroll_account.yml | 4 ++-- addons/membership/test/test_membership.yml | 1 - addons/purchase_requisition/test/purchase_requisition.yml | 3 ++- addons/sale_mrp/test/sale_mrp.yml | 2 +- addons/sale_stock/test/picking_order_policy.yml | 7 ++++--- 10 files changed, 9 insertions(+), 17 deletions(-) diff --git a/addons/account_voucher/test/case1_usd_usd.yml b/addons/account_voucher/test/case1_usd_usd.yml index fd1945691ba..44269104370 100644 --- a/addons/account_voucher/test/case1_usd_usd.yml +++ b/addons/account_voucher/test/case1_usd_usd.yml @@ -159,7 +159,6 @@ I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$> - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_1_case1')) data = [] @@ -254,7 +253,6 @@ I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$ - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_2_case1')) data = [] diff --git a/addons/account_voucher/test/case2_suppl_usd_eur.yml b/addons/account_voucher/test/case2_suppl_usd_eur.yml index 91fb99f6360..c13bfcbd5d4 100644 --- a/addons/account_voucher/test/case2_suppl_usd_eur.yml +++ b/addons/account_voucher/test/case2_suppl_usd_eur.yml @@ -131,7 +131,6 @@ I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$ - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2_suppl')) data = [] @@ -234,7 +233,6 @@ I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$> - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2_suppl')) data = [] diff --git a/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml b/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml index b049fc7692e..52c416e06cc 100644 --- a/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml +++ b/addons/account_voucher/test/case2_usd_eur_debtor_in_usd.yml @@ -163,7 +163,6 @@ I fill amounts 130 for the invoice of 200$ and 70 for the invoice of 100$> - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2b')) data = [] @@ -244,7 +243,6 @@ and I fully reconcil the 2 previous invoices - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2b')) data = [] diff --git a/addons/account_voucher/test/case3_eur_eur.yml b/addons/account_voucher/test/case3_eur_eur.yml index d0b18a5231b..99153ceeca4 100644 --- a/addons/account_voucher/test/case3_eur_eur.yml +++ b/addons/account_voucher/test/case3_eur_eur.yml @@ -118,7 +118,6 @@ I fill amounts 100 for the invoice of 150€ and 20 for the invoice of 80€ - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_1_case3')) data = [] @@ -206,7 +205,6 @@ I fill amounts 50 for the invoice of 150€ and 70 for the invoice of 80€ - !python {model: account.voucher}: | - import netsvc, time vals = {} voucher_id = self.browse(cr, uid, ref('account_voucher_2_case3')) data = [] diff --git a/addons/hr_holidays/test/test_hr_holiday.yml b/addons/hr_holidays/test/test_hr_holiday.yml index e78c2fd08bc..2bb60300cff 100644 --- a/addons/hr_holidays/test/test_hr_holiday.yml +++ b/addons/hr_holidays/test/test_hr_holiday.yml @@ -18,7 +18,6 @@ I again set to draft and then confirm. - !python {model: hr.holidays}: | - import netsvc self.set_to_draft(cr, uid, [ref('hr_holidays_employee1_cl')]) self.signal_confirm(cr, uid, [ref('hr_holidays_employee1_cl')]) - diff --git a/addons/hr_payroll_account/test/hr_payroll_account.yml b/addons/hr_payroll_account/test/hr_payroll_account.yml index ad0197c7905..c8b6bf42fdd 100644 --- a/addons/hr_payroll_account/test/hr_payroll_account.yml +++ b/addons/hr_payroll_account/test/hr_payroll_account.yml @@ -89,7 +89,7 @@ I verify the payslip is in draft state. - !python {model: hr.payslip}: | - from tools.translate import _ + from openerp.tools.translate import _ payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) assert(payslip_brw.state == 'draft'), _('State not changed!') - @@ -120,7 +120,7 @@ I verify that the payslip is in done state. - !python {model: hr.payslip}: | - from tools.translate import _ + from openerp.tools.translate import _ payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) assert(payslip_brw.state == 'done'), _('State not changed!') diff --git a/addons/membership/test/test_membership.yml b/addons/membership/test/test_membership.yml index 8e8e7887b44..6fb392670e9 100644 --- a/addons/membership/test/test_membership.yml +++ b/addons/membership/test/test_membership.yml @@ -31,7 +31,6 @@ I'm Opening that Invoice which is created for "Seagate". - !python {model: res.partner}: | - import netsvc from tools.translate import _ invoice_pool = self.pool.get('account.invoice') partner_pool = self.pool.get('res.partner') diff --git a/addons/purchase_requisition/test/purchase_requisition.yml b/addons/purchase_requisition/test/purchase_requisition.yml index f23737d21b8..8fd36e07d71 100644 --- a/addons/purchase_requisition/test/purchase_requisition.yml +++ b/addons/purchase_requisition/test/purchase_requisition.yml @@ -82,7 +82,8 @@ I print a Requisition report - !python {model: purchase.requisition}: | - import netsvc, tools, os + import os + from openerp import netsvc, tools (data, format) = netsvc.LocalService('report.purchase.requisition').create(cr, uid, [ref('purchase_requisition.requisition1')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'purchase_requisition-purchase_requisition_report.'+format), 'wb+').write(data) diff --git a/addons/sale_mrp/test/sale_mrp.yml b/addons/sale_mrp/test/sale_mrp.yml index c2eff008943..9b70e052854 100644 --- a/addons/sale_mrp/test/sale_mrp.yml +++ b/addons/sale_mrp/test/sale_mrp.yml @@ -92,7 +92,7 @@ I verify that a procurement has been generated for sale order - !python {model: procurement.order}: | - from tools.translate import _ + from openerp.tools.translate import _ sale_order_obj = self.pool.get('sale.order') so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) proc_ids = self.search(cr, uid, [('origin','=',so.name)]) diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml index 406aaf0bf8a..f761dfb65db 100644 --- a/addons/sale_stock/test/picking_order_policy.yml +++ b/addons/sale_stock/test/picking_order_policy.yml @@ -22,7 +22,7 @@ !python {model: sale.order}: | from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta - from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT + from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT order = self.browse(cr, uid, ref("sale.sale_order_6")) for order_line in order.order_line: procurement = order_line.procurement_id @@ -44,7 +44,7 @@ !python {model: sale.order}: | from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta - from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT + from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT sale_order = self.browse(cr, uid, ref("sale.sale_order_6")) assert sale_order.picking_ids, "Delivery order is not created." for picking in sale_order.picking_ids: @@ -161,7 +161,8 @@ I print a sale order report. - !python {model: sale.order}: | - import netsvc, tools, os + import os + from openerp import netsvc, tools (data, format) = netsvc.LocalService('report.sale.order').create(cr, uid, [ref('sale.sale_order_6')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'sale-sale_order.'+format), 'wb+').write(data) From 9e05f4d291845c642da3ba018c0b16e42ac744e8 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Wed, 13 Feb 2013 11:32:39 +0100 Subject: [PATCH 56/56] [FIX] membership: fix import statements in yml file bzr revid: rco@openerp.com-20130213103239-5tq1ib4xcbykgjzk --- addons/membership/test/test_membership.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/membership/test/test_membership.yml b/addons/membership/test/test_membership.yml index 6fb392670e9..40d1785c29a 100644 --- a/addons/membership/test/test_membership.yml +++ b/addons/membership/test/test_membership.yml @@ -31,7 +31,7 @@ I'm Opening that Invoice which is created for "Seagate". - !python {model: res.partner}: | - from tools.translate import _ + from openerp.tools.translate import _ invoice_pool = self.pool.get('account.invoice') partner_pool = self.pool.get('res.partner') membership_line_pool = self.pool.get('membership.membership_line') @@ -105,7 +105,7 @@ I'm doing to make credit note of invoice which is paid by "Seagate" to cancel membership. - !python {model: account.invoice}: | - from tools.translate import _ + from openerp.tools.translate import _ invoice_pool = self.pool.get('account.invoice') partner_pool = self.pool.get('res.partner') membership_line_pool = self.pool.get('membership.membership_line')