From c762b165371e99880bf46e624b4f928772cfe724 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 20 May 2011 11:42:28 +0530 Subject: [PATCH 001/362] [FIX]purchase:Purchase Order report does not print destination address ,fixed =>if destination address not there then address will be getting from default wharhouse address lp bug: https://launchpad.net/bugs/784265 fixed bzr revid: ron@tinyerp.com-20110520061228-poi0uddsdbk0klcp --- addons/purchase/report/order.rml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/addons/purchase/report/order.rml b/addons/purchase/report/order.rml index 4b143d0f961..18e53aade77 100644 --- a/addons/purchase/report/order.rml +++ b/addons/purchase/report/order.rml @@ -165,21 +165,13 @@ - - - - - - - - [[ repeatIn(o.dest_address_id and [o.dest_address_id] or [],'addr') ]] Shipping address : - [[ (addr.partner_id and addr.partner_id.title and addr.partner_id.title.name) or '' ]] [[ (addr.partner_id and addr.partner_id.name) or '' ]] - [[ addr.street ]] - [[ addr.street2 or removeParentNode('para') ]] - [[ addr.zip or '' ]] [[ addr.city or '' ]] - [[ addr.state_id and addr.state_id.name or removeParentNode('para') ]] - [[ addr.country_id and addr.country_id.name or '' ]] + [[ (o.dest_address_id and o.dest_address_id.partner_id.name) or (o.warehouse_id and o.warehouse_id.name) or '']] + [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.street) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.street) or '']] + [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.street2) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.street2) or removeParentNode('para') ]] + [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.zip) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.zip) or '' ]] [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.city) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.city) or '' ]] + [[ (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.state_id and o.warehouse_id.partner_address_id.state_id.name) or o.partner_address_id and o.partner_address_id.state_id and o.partner_address_id.state_id.name or removeParentNode('para') ]] + [[ (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.country_id and o.warehouse_id.partner_address_id.country_id.name) or o.partner_address_id.country_id.name ]] From 0bb1e1cba0343d995ea1b98692200534f7a620e9 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Tue, 24 May 2011 17:49:58 +0530 Subject: [PATCH 002/362] [FIX]mrp:extensibility broken in action_scrap lp bug: https://launchpad.net/bugs/780589 fixed bzr revid: ron@tinyerp.com-20110524121958-t1vu2wpnk2yimgo2 --- addons/mrp/stock.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 0c1454edf98..29994398f06 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -137,14 +137,13 @@ class StockMove(osv.osv): 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) - 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) for new_move in new_moves: production_obj.write(cr, uid, production_ids, {'move_lines': [(4, new_move)]}) res.append(new_move) - return {} + return res StockMove() From c6c0ca1207ba38e8fa5ea6b3fa61a5c9932eb156 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 3 Jun 2011 11:18:49 +0530 Subject: [PATCH 003/362] [IMP]purchase:Fixed=>Give proper state and country value in Purchase Order report bzr revid: ron@tinyerp.com-20110603054849-60kvwno0a27eai3l --- addons/purchase/report/order.rml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/purchase/report/order.rml b/addons/purchase/report/order.rml index 18e53aade77..5e0aa082fa2 100644 --- a/addons/purchase/report/order.rml +++ b/addons/purchase/report/order.rml @@ -170,8 +170,8 @@ [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.street) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.street) or '']] [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.street2) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.street2) or removeParentNode('para') ]] [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.zip) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.zip) or '' ]] [[ (o.dest_address_id and o.dest_address_id and o.dest_address_id.city) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.city) or '' ]] - [[ (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.state_id and o.warehouse_id.partner_address_id.state_id.name) or o.partner_address_id and o.partner_address_id.state_id and o.partner_address_id.state_id.name or removeParentNode('para') ]] - [[ (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.country_id and o.warehouse_id.partner_address_id.country_id.name) or o.partner_address_id.country_id.name ]] + [[ (o.dest_address_id and o.dest_address_id.state_id and o.dest_address_id.state_id.name) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.state_id and o.warehouse_id.partner_address_id.state_id.name) or removeParentNode('para') ]] + [[ (o.dest_address_id and o.dest_address_id.country_id and o.dest_address_id.country_id.name) or (o.warehouse_id and o.warehouse_id.partner_address_id and o.warehouse_id.partner_address_id.country_id and o.warehouse_id.partner_address_id.country_id.name) ]] From 87aa4380d4008db1d0058cdd08c9d2989edabaa4 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 3 Jun 2011 12:29:38 +0530 Subject: [PATCH 004/362] [IMP]mrp: instead of removing the line give the proper comment of that line bzr revid: ron@tinyerp.com-20110603065938-chm15leo6r9aazil --- addons/mrp/stock.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 29994398f06..2756e383adb 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -137,6 +137,8 @@ class StockMove(osv.osv): 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) From c83acd9ce4e04cadac352fa25db4e42c2a235f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= <> Date: Wed, 15 Jun 2011 15:34:11 +0530 Subject: [PATCH 005/362] [ADD] hr : Added default value for departmet and applied onchange method for department according to employee_id lp bug: https://launchpad.net/bugs/708730 fixed bzr revid: bde@tiny2-desktop-20110615100411-gs5vkug3kb0i8sg8 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 15 ++++++++++++++- .../hr_timesheet_sheet_view.xml | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index ea2b5017790..94b390b30a2 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -321,9 +321,15 @@ class hr_timesheet_sheet(osv.osv): return time.strftime('%Y-12-31') return time.strftime('%Y-%m-%d') - def _default_employee(self,cr, uid, context=None): + def _default_employee(self, cr, uid, context=None): emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)], context=context) return emp_ids and emp_ids[0] or False + + def _default_department(self, cr, uid, context=None): + emp_id = self._default_employee(cr, uid, context) + if emp_id: + return self.pool.get('hr.employee').read(cr, uid, [emp_id], context)[0]['department_id'] + return False _defaults = { 'date_from' : _default_date_from, @@ -331,6 +337,7 @@ class hr_timesheet_sheet(osv.osv): 'date_to' : _default_date_to, 'state': 'new', 'employee_id': _default_employee, + 'department_id': _default_department, 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'hr_timesheet_sheet.sheet', context=c) } @@ -382,6 +389,12 @@ class hr_timesheet_sheet(osv.osv): raise osv.except_osv(_('Invalid action !'), _('Cannot delete Sheet(s) which have attendance entries encoded !')) return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context) + def onchange_department_id(self, cr, uid, ids, employee_id, context=None): + department_id = False + if employee_id: + department_id = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).department_id.id or False + return {'value': {'department_id': department_id}} + hr_timesheet_sheet() diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 321e4c2addd..dc43ca10920 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -66,7 +66,7 @@ - + From 6e948ccb54036e70c49f51df48dee8dd4a3de674 Mon Sep 17 00:00:00 2001 From: "aag (OpenERP)" Date: Wed, 15 Jun 2011 16:29:40 +0530 Subject: [PATCH 006/362] [FIX] product:Now user can create unique UOM lp bug: https://launchpad.net/bugs/731035 fixed bzr revid: aag@tinyerp.co.in-20110615105940-ke84jj7rrgtpv02v --- addons/product/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index fa6796b3953..1db24e1bd32 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -122,7 +122,7 @@ class product_uom(osv.osv): _sql_constraints = [ ('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!'), - ('factor_category_id_uniq', 'unique (category_id, factor)', 'You can not have more than one UOM with same factor for same UOM category'), + ('uom_name_unique', 'unique (name)', 'You cannot have multiple Units of Measure with the same name'), ] def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False): From 3cc05ec6f96af8a9f3d464d0ddf3c2bf8177bf21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= <> Date: Wed, 15 Jun 2011 18:43:26 +0530 Subject: [PATCH 007/362] [FIX] hr_expense: Fixed problem of company id when creating invoice from expenses. lp bug: https://launchpad.net/bugs/796363 fixed bzr revid: uco@tinyerp.com-20110615131326-64npowgjwy4jk4xy --- addons/hr_expense/hr_expense.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 2e7020306b5..07e3ef94063 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -24,6 +24,7 @@ import time from osv import fields, osv from tools.translate import _ import decimal_precision as dp +import netsvc def _employee_get(obj, cr, uid, context=None): if context is None: @@ -54,6 +55,12 @@ class hr_expense_expense(osv.osv): else: return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)], context=context)[0] + def _company_get(obj, cr, uid, context=None): + employee_id = _employee_get(obj, cr, uid, context) + if employee_id: + return obj.pool.get('hr.employee').read(cr, uid, [employee_id], ['company_id'], context)[0]['company_id'] + return False + _name = "hr.expense.expense" _description = "Expense" _columns = { @@ -91,14 +98,18 @@ class hr_expense_expense(osv.osv): 'employee_id': _employee_get, 'user_id': lambda cr, uid, id, c={}: id, 'currency_id': _get_currency, - 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'company_id': _company_get, } def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): + emp_obj = self.pool.get('hr.employee') department_id = False + company_id = False if employee_id: - department_id = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).department_id.id or False - return {'value':{'department_id':department_id}} + employee = emp_obj.browse(cr, uid, employee_id, context=context) + department_id = employee.department_id.id or False + company_id = employee.company_id.id or False + return {'value':{'department_id':department_id, 'company_id':company_id}} def expense_confirm(self, cr, uid, ids, *args): self.write(cr, uid, ids, { @@ -153,6 +164,7 @@ class hr_expense_expense(osv.osv): analytic_journal_obj = self.pool.get('account.analytic.journal') account_journal = self.pool.get('account.journal') for exp in self.browse(cr, uid, ids): + company_id = exp.company_id.id lines = [] for l in exp.line_ids: tax_id = [] @@ -162,10 +174,9 @@ class hr_expense_expense(osv.osv): acc = l.product_id.categ_id.property_account_expense_categ tax_id = [x.id for x in l.product_id.supplier_taxes_id] else: - acc = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category') + acc = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category', context={'force_company': company_id}) if not acc: raise osv.except_osv(_('Error !'), _('Please configure Default Expense account for Product purchase, `property_account_expense_categ`')) - lines.append((0, False, { 'name': l.name, 'account_id': acc.id, @@ -190,6 +201,7 @@ class hr_expense_expense(osv.osv): 'partner_id': exp.employee_id.address_home_id.partner_id.id, 'address_invoice_id': exp.employee_id.address_home_id.id, 'address_contact_id': exp.employee_id.address_home_id.id, + 'company_id': company_id, 'origin': exp.name, 'invoice_line': lines, 'currency_id': exp.currency_id.id, @@ -205,7 +217,7 @@ class hr_expense_expense(osv.osv): inv['journal_id']=exp.journal_id.id journal = exp.journal_id else: - journal_id = invoice_obj._get_journal(cr, uid, context={'type': 'in_invoice'}) + journal_id = invoice_obj._get_journal(cr, uid, context={'type': 'in_invoice', 'company_id': company_id}) if journal_id: inv['journal_id'] = journal_id journal = account_journal.browse(cr, uid, journal_id) @@ -248,7 +260,7 @@ class hr_expense_line(osv.osv): 'unit_amount': fields.float('Unit Price', digits_compute=dp.get_precision('Account')), 'unit_quantity': fields.float('Quantities' ), 'product_id': fields.many2one('product.product', 'Product', domain=[('hr_expense_ok','=',True)]), - 'uom_id': fields.many2one('product.uom', 'UoM' ), + 'uom_id': fields.many2one('product.uom', 'UoM'), 'description': fields.text('Description'), 'analytic_account': fields.many2one('account.analytic.account','Analytic account'), 'ref': fields.char('Reference', size=32), From 8f34b9bc5f0f9c8b2f876548573b775aeaccee49 Mon Sep 17 00:00:00 2001 From: bde Date: Thu, 16 Jun 2011 18:33:31 +0530 Subject: [PATCH 008/362] [REM] hr : Removed default method, improved the code in onchange method and renamed the onchange method bzr revid: bde@tiny2-desktop-20110616130331-akwurvfky183f442 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 16 ++++++---------- .../hr_timesheet_sheet_view.xml | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 94b390b30a2..02ba6d6dd68 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -325,19 +325,12 @@ class hr_timesheet_sheet(osv.osv): emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)], context=context) return emp_ids and emp_ids[0] or False - def _default_department(self, cr, uid, context=None): - emp_id = self._default_employee(cr, uid, context) - if emp_id: - return self.pool.get('hr.employee').read(cr, uid, [emp_id], context)[0]['department_id'] - return False - _defaults = { 'date_from' : _default_date_from, 'date_current' : lambda *a: time.strftime('%Y-%m-%d'), 'date_to' : _default_date_to, 'state': 'new', 'employee_id': _default_employee, - 'department_id': _default_department, 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'hr_timesheet_sheet.sheet', context=c) } @@ -389,11 +382,14 @@ class hr_timesheet_sheet(osv.osv): raise osv.except_osv(_('Invalid action !'), _('Cannot delete Sheet(s) which have attendance entries encoded !')) return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context) - def onchange_department_id(self, cr, uid, ids, employee_id, context=None): - department_id = False + def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): + res = {'value':{}} if employee_id: department_id = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).department_id.id or False - return {'value': {'department_id': department_id}} + res['value'] = { + 'department_id': department_id, + } + return res hr_timesheet_sheet() diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index dc43ca10920..bbcebaec9d3 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -66,7 +66,7 @@ - + From dee848cb217e73e330227c2612e6f35b41867c0c Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 17 Jun 2011 10:45:01 +0530 Subject: [PATCH 009/362] [FIX] hr_expense: Used browse instead of read method for _company_get. bzr revid: uco@tinyerp.com-20110617051501-o9cx1faew9v7qv6y --- addons/hr_expense/hr_expense.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 07e3ef94063..8dcfcd6c2db 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -58,7 +58,7 @@ class hr_expense_expense(osv.osv): def _company_get(obj, cr, uid, context=None): employee_id = _employee_get(obj, cr, uid, context) if employee_id: - return obj.pool.get('hr.employee').read(cr, uid, [employee_id], ['company_id'], context)[0]['company_id'] + return obj.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).company_id.id return False _name = "hr.expense.expense" From e5712ece72e688c30f8fce018ae7753b08474ace Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 17 Jun 2011 15:25:08 +0530 Subject: [PATCH 010/362] [FIX] hr_expense: Removed default value for company id. bzr revid: uco@tinyerp.com-20110617095508-qqv2bdr2h1rfs2g6 --- addons/hr_expense/hr_expense.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 8dcfcd6c2db..60e05b9e9dd 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -55,12 +55,6 @@ class hr_expense_expense(osv.osv): else: return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)], context=context)[0] - def _company_get(obj, cr, uid, context=None): - employee_id = _employee_get(obj, cr, uid, context) - if employee_id: - return obj.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).company_id.id - return False - _name = "hr.expense.expense" _description = "Expense" _columns = { @@ -98,7 +92,6 @@ class hr_expense_expense(osv.osv): 'employee_id': _employee_get, 'user_id': lambda cr, uid, id, c={}: id, 'currency_id': _get_currency, - 'company_id': _company_get, } def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): From b113f671595c426b14b2f6ea3e9e25187a31d6ab Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 17 Jun 2011 15:30:09 +0530 Subject: [PATCH 011/362] [REF] hr_expense: Small Refactoring. bzr revid: uco@tinyerp.com-20110617100009-m9mkt7nh6fsu0zdn --- addons/hr_expense/hr_expense.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 60e05b9e9dd..f9768b557e1 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -100,9 +100,9 @@ class hr_expense_expense(osv.osv): company_id = False if employee_id: employee = emp_obj.browse(cr, uid, employee_id, context=context) - department_id = employee.department_id.id or False - company_id = employee.company_id.id or False - return {'value':{'department_id':department_id, 'company_id':company_id}} + department_id = employee.department_id.id + company_id = employee.company_id.id + return {'value': {'department_id': department_id, 'company_id': company_id}} def expense_confirm(self, cr, uid, ids, *args): self.write(cr, uid, ids, { From 461c89b180f55d25a0c5e18ae3926207f45a0331 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 17 Jun 2011 18:29:52 +0530 Subject: [PATCH 012/362] [IMP] hr_timesheet_sheet: Improved onchange_employee_id method. bzr revid: uco@tinyerp.com-20110617125952-m1xbspu0j2d81g5e --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 02ba6d6dd68..a8cda50bd0f 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -383,13 +383,10 @@ class hr_timesheet_sheet(osv.osv): return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context) def onchange_employee_id(self, cr, uid, ids, employee_id, context=None): - res = {'value':{}} + department_id = False if employee_id: - department_id = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).department_id.id or False - res['value'] = { - 'department_id': department_id, - } - return res + department_id = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).department_id.id + return {'value': {'department_id': department_id}} hr_timesheet_sheet() From 0890da73530daf8fe3a8e65197f551fb0554a62b Mon Sep 17 00:00:00 2001 From: "mayur maheshwari (Open ERP)" Date: Fri, 17 Jun 2011 18:48:08 +0530 Subject: [PATCH 013/362] [FIX]multi_company,purchase:created a sequence for purchase order and demo data for company shop1 and shop2 lp bug: https://launchpad.net/bugs/787052 fixed bzr revid: mma@tinyerp.com-20110617131808-dx8387t60fzebzv2 --- addons/multi_company/__openerp__.py | 3 +- addons/multi_company/multi_company_demo.xml | 26 ++++++++++++++++ .../multi_company_purchase_sequence.xml | 31 +++++++++++++++++++ addons/purchase/purchase.py | 2 +- 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 addons/multi_company/multi_company_purchase_sequence.xml diff --git a/addons/multi_company/__openerp__.py b/addons/multi_company/__openerp__.py index baf3a88c32e..beeffc75358 100644 --- a/addons/multi_company/__openerp__.py +++ b/addons/multi_company/__openerp__.py @@ -39,7 +39,8 @@ This module is the base module for other multi-company modules. ], 'init_xml': [], 'update_xml': [ - 'res_company_view.xml' + 'res_company_view.xml', + 'multi_company_purchase_sequence.xml', ], 'demo_xml': [ 'multi_company_demo.xml' diff --git a/addons/multi_company/multi_company_demo.xml b/addons/multi_company/multi_company_demo.xml index d3b46e6d112..583f83d252d 100644 --- a/addons/multi_company/multi_company_demo.xml +++ b/addons/multi_company/multi_company_demo.xml @@ -267,6 +267,32 @@ + + + Expenses Journal - (Shop 1) + EXJ-Shop 1 + purchase + + + + + + + + + + + Expenses Journal - (Shop 2) + EXJ-Shop 2 + purchase + + + + + + + + Expenses Credit Notes Journal - (OpenERP IN) diff --git a/addons/multi_company/multi_company_purchase_sequence.xml b/addons/multi_company/multi_company_purchase_sequence.xml new file mode 100644 index 00000000000..8205866e573 --- /dev/null +++ b/addons/multi_company/multi_company_purchase_sequence.xml @@ -0,0 +1,31 @@ + + + + + + + + Purchase Order + purchase.order + + + + + + Purchase Order + purchase.order + PO + 5 + + + + + Purchase Order + purchase.order + PO + 5 + + + + + diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6f6ab0c1b44..436ec0b021b 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -228,7 +228,7 @@ class purchase_order(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c), } _sql_constraints = [ - ('name_uniq', 'unique(name)', 'Order Reference must be unique !'), + ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique !'), ] _name = "purchase.order" _description = "Purchase Order" From 4b6c69f4219c2eeba85a4dc97369a0f34448396b Mon Sep 17 00:00:00 2001 From: "aag (OpenERP)" Date: Tue, 21 Jun 2011 18:03:55 +0530 Subject: [PATCH 014/362] [FIX] product :Remove _sql_constraints lp bug: https://launchpad.net/bugs/731035 fixed bzr revid: aag@tinyerp.co.in-20110621123355-rxwrb82jlckl622w --- addons/product/product.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index 1db24e1bd32..a6513522db2 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -122,7 +122,6 @@ class product_uom(osv.osv): _sql_constraints = [ ('factor_gt_zero', 'CHECK (factor!=0)', 'The conversion ratio for a unit of measure cannot be 0!'), - ('uom_name_unique', 'unique (name)', 'You cannot have multiple Units of Measure with the same name'), ] def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False): From 645d0a870d32bec67b1fc3d40d6ece0d52df0d52 Mon Sep 17 00:00:00 2001 From: "aag (OpenERP)" Date: Fri, 1 Jul 2011 17:26:28 +0530 Subject: [PATCH 015/362] [FIX] purchase,sale : one category can have several UoM references than it will not give error msg when open related Report lp bug: https://launchpad.net/bugs/731035 fixed bzr revid: aag@tinyerp.co.in-20110701115628-500ttalfgqlhifnx --- addons/purchase/report/purchase_report.py | 2 +- addons/sale/report/sale_report.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index 6b68cecf1a5..c91920a0d86 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -93,7 +93,7 @@ class purchase_report(osv.osv): l.product_id, t.categ_id as category_id, (case when u.uom_type not in ('reference') then - (select id from product_uom where uom_type='reference' and category_id = 1) + (select id from product_uom where uom_type='reference' and category_id = 1 LIMIT 1) else u.id end) as product_uom, diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py index aaaec228d7b..ed457835fb6 100644 --- a/addons/sale/report/sale_report.py +++ b/addons/sale/report/sale_report.py @@ -91,7 +91,7 @@ class sale_report(osv.osv): select l.id as id, l.product_id as product_id, (case when u.uom_type not in ('reference') then - (select name from product_uom where uom_type='reference' and category_id=u.category_id) + (select name from product_uom where uom_type='reference' and category_id=u.category_id LIMIT 1) else u.name end) as uom_name, From 3c8de333a4e648fc3d827e69379990217ee5c792 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 6 Jul 2011 17:36:44 +0530 Subject: [PATCH 016/362] [IMP] add boolean field on account_followup wizard and fix partner_id many2many fields gives error bzr revid: ara@tinyerp.com-20110706120644-etqtptxkmjer6qsa --- addons/account_followup/wizard/account_followup_print.py | 7 ++++--- .../wizard/account_followup_print_view.xml | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index a8608c2fdd0..c1b5247dec2 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -115,12 +115,13 @@ class account_followup_print_all(osv.osv_memory): _name = 'account.followup.print.all' _description = 'Print Followup & Send Mail to Customers' _columns = { - 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True, domain="[('account_id.type', '=', 'receivable'), ('account_id.reconcile', '=', True), ('reconcile_id','=', False), ('state', '!=', 'draft'), ('account_id.active', '=', True), ('debit', '>', 0)]"), + 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True), 'email_conf': fields.boolean('Send email confirmation'), 'email_subject': fields.char('Email Subject', size=64), 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), 'email_body': fields.text('Email body'), - 'summary': fields.text('Summary', required=True, readonly=True) + 'summary': fields.text('Summary', required=True, readonly=True), + 'test': fields.boolean('Test File') } def _get_summary(self, cr, uid, context=None): if context is None: @@ -316,7 +317,7 @@ class account_followup_print_all(osv.osv_memory): data['followup_id'] = 'followup_id' in context and context['followup_id'] or False date = 'date' in context and context['date'] or data['date'] for id in to_update.keys(): - if to_update[id]['partner_id'] in data['partner_ids']: + if to_update[id]['partner_id'] in data['partner_ids'] and not data['test']: cr.execute( "UPDATE account_move_line "\ "SET followup_line_id=%s, followup_date=%s "\ diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml index af105b17c55..1ece8ea2959 100644 --- a/addons/account_followup/wizard/account_followup_print_view.xml +++ b/addons/account_followup/wizard/account_followup_print_view.xml @@ -86,6 +86,7 @@ + From db4c8d395d520e1388ef3731994e092f29942bc8 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 6 Jul 2011 17:57:33 +0530 Subject: [PATCH 017/362] [IMP] add help on test field bzr revid: ara@tinyerp.com-20110706122733-qszw297j0w7si3q7 --- addons/account_followup/wizard/account_followup_print.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index c1b5247dec2..d7730c1cfff 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -121,7 +121,7 @@ class account_followup_print_all(osv.osv_memory): 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), 'email_body': fields.text('Email body'), 'summary': fields.text('Summary', required=True, readonly=True), - 'test': fields.boolean('Test File') + 'test': fields.boolean('Test File', help='Check if you want to print follow ups without increase follow ups level.') } def _get_summary(self, cr, uid, context=None): if context is None: From 469ca9b5f4bbf1e67d22f63c1fac6905aeac2796 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 6 Jul 2011 17:58:07 +0530 Subject: [PATCH 018/362] [IMP] add help on test field bzr revid: ara@tinyerp.com-20110706122807-t13hbmxzximo561h --- addons/account_followup/wizard/account_followup_print.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index d7730c1cfff..03f376d9af2 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -121,7 +121,7 @@ class account_followup_print_all(osv.osv_memory): 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), 'email_body': fields.text('Email body'), 'summary': fields.text('Summary', required=True, readonly=True), - 'test': fields.boolean('Test File', help='Check if you want to print follow ups without increase follow ups level.') + 'test': fields.boolean('Test File', help='Check if you want to print follow ups without changing follow ups level.') } def _get_summary(self, cr, uid, context=None): if context is None: From 71a33c47bd404488e7beaab04584f9cf67b95478 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 11 Jul 2011 15:39:03 +0530 Subject: [PATCH 019/362] [IMP] account_followups: improve varible name bzr revid: ara@tinyerp.com-20110711100903-dts3dzar0tv95wh3 --- .../wizard/account_followup_print.py | 19 ++++++++++--------- .../wizard/account_followup_print_view.xml | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 03f376d9af2..59cdb915a8f 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -121,7 +121,7 @@ class account_followup_print_all(osv.osv_memory): 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), 'email_body': fields.text('Email body'), 'summary': fields.text('Summary', required=True, readonly=True), - 'test': fields.boolean('Test File', help='Check if you want to print follow ups without changing follow ups level.') + 'test_print': fields.boolean('Test Print', help='Check if you want to print followups without changing follow ups level.') } def _get_summary(self, cr, uid, context=None): if context is None: @@ -316,14 +316,15 @@ class account_followup_print_all(osv.osv_memory): to_update = res data['followup_id'] = 'followup_id' in context and context['followup_id'] or False date = 'date' in context and context['date'] or data['date'] - for id in to_update.keys(): - if to_update[id]['partner_id'] in data['partner_ids'] and not data['test']: - cr.execute( - "UPDATE account_move_line "\ - "SET followup_line_id=%s, followup_date=%s "\ - "WHERE id=%s", - (to_update[id]['level'], - date, int(id),)) + if not data['test_print']: + for id in to_update.keys(): + if to_update[id]['partner_id'] in data['partner_ids']: + cr.execute( + "UPDATE account_move_line "\ + "SET followup_line_id=%s, followup_date=%s "\ + "WHERE id=%s", + (to_update[id]['level'], + date, int(id),)) data.update({'date': context['date']}) datas = { 'ids': [], diff --git a/addons/account_followup/wizard/account_followup_print_view.xml b/addons/account_followup/wizard/account_followup_print_view.xml index 1ece8ea2959..9d74060b19a 100644 --- a/addons/account_followup/wizard/account_followup_print_view.xml +++ b/addons/account_followup/wizard/account_followup_print_view.xml @@ -86,7 +86,7 @@ - + From 758ca5c4f47a26152e7edf7afdfc8a4e838591f9 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 11 Jul 2011 15:56:13 +0530 Subject: [PATCH 020/362] [IMP] account_followups: improve varible name bzr revid: ara@tinyerp.com-20110711102613-msoe0my3j7qwil2j --- addons/account_followup/wizard/account_followup_print.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 59cdb915a8f..794bf13a1d4 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -121,7 +121,7 @@ class account_followup_print_all(osv.osv_memory): 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), 'email_body': fields.text('Email body'), 'summary': fields.text('Summary', required=True, readonly=True), - 'test_print': fields.boolean('Test Print', help='Check if you want to print followups without changing follow ups level.') + 'test_print': fields.boolean('Test Print', help='Check if you want to print followups without changing followups level.') } def _get_summary(self, cr, uid, context=None): if context is None: From 236e429cefa9c6c749f4cb4a9f4a20d00a454ecd Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Thu, 14 Jul 2011 18:53:19 +0530 Subject: [PATCH 021/362] [IMP]multi_company,purchase:Removing a file of sequence bzr revid: mma@tinyerp.com-20110714132319-3tggg0636kkqsm3v --- addons/multi_company/__openerp__.py | 1 - .../multi_company_purchase_sequence.xml | 31 ------------------- addons/purchase/purchase_sequence.xml | 1 + 3 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 addons/multi_company/multi_company_purchase_sequence.xml diff --git a/addons/multi_company/__openerp__.py b/addons/multi_company/__openerp__.py index beeffc75358..2ae556fe1e7 100644 --- a/addons/multi_company/__openerp__.py +++ b/addons/multi_company/__openerp__.py @@ -40,7 +40,6 @@ This module is the base module for other multi-company modules. 'init_xml': [], 'update_xml': [ 'res_company_view.xml', - 'multi_company_purchase_sequence.xml', ], 'demo_xml': [ 'multi_company_demo.xml' diff --git a/addons/multi_company/multi_company_purchase_sequence.xml b/addons/multi_company/multi_company_purchase_sequence.xml deleted file mode 100644 index 8205866e573..00000000000 --- a/addons/multi_company/multi_company_purchase_sequence.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - Purchase Order - purchase.order - - - - - - Purchase Order - purchase.order - PO - 5 - - - - - Purchase Order - purchase.order - PO - 5 - - - - - diff --git a/addons/purchase/purchase_sequence.xml b/addons/purchase/purchase_sequence.xml index 7f426b53be6..e8a7f43c503 100644 --- a/addons/purchase/purchase_sequence.xml +++ b/addons/purchase/purchase_sequence.xml @@ -11,6 +11,7 @@ purchase.order PO 5 + From 659f408f504a3bb1a44a7d4b49605c0ffc2623d1 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Fri, 15 Jul 2011 17:30:59 +0530 Subject: [PATCH 022/362] [FIX]stock:product_uos ,product_uos_qty and address_id field readonly mode when state is done lp bug: https://launchpad.net/bugs/781642 fixed bzr revid: mma@tinyerp.com-20110715120059-m7mhvhfmh6lzoml7 --- addons/stock/stock.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 310b1067ff8..fffe580aee1 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1527,13 +1527,13 @@ class stock_move(osv.osv): 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), required=True,states={'done': [('readonly', True)]}), 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True,states={'done': [('readonly', True)]}), - 'product_uos_qty': fields.float('Quantity (UOS)', digits_compute=dp.get_precision('Product UoM')), - 'product_uos': fields.many2one('product.uom', 'Product UOS'), + 'product_uos_qty': fields.float('Quantity (UOS)', digits_compute=dp.get_precision('Product UoM'), states={'done': [('readonly', True)]}), + 'product_uos': fields.many2one('product.uom', 'Product UOS', states={'done': [('readonly', True)]}), 'product_packaging': fields.many2one('product.packaging', 'Packaging', help="It specifies attributes of packaging like type, quantity of packaging,etc."), 'location_id': fields.many2one('stock.location', 'Source Location', required=True, select=True,states={'done': [('readonly', True)]}, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."), 'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True,states={'done': [('readonly', True)]}, select=True, help="Location where the system will stock the finished products."), - 'address_id': fields.many2one('res.partner.address', 'Destination Address', help="Optional address where goods are to be delivered, specifically used for allotment"), + 'address_id': fields.many2one('res.partner.address', 'Destination Address ', states={'done': [('readonly', True)]}, help="Optional address where goods are to be delivered, specifically used for allotment"), 'prodlot_id': fields.many2one('stock.production.lot', 'Production Lot', states={'done': [('readonly', True)]}, help="Production lot is used to put a serial number on the production", select=True), 'tracking_id': fields.many2one('stock.tracking', 'Pack', select=True, states={'done': [('readonly', True)]}, help="Logistical shipping unit: pallet, box, pack ..."), From 2380552cb493040b22e61f8e4209cc6df8edc912 Mon Sep 17 00:00:00 2001 From: guillem <> Date: Tue, 19 Jul 2011 11:19:15 +0530 Subject: [PATCH 023/362] [FIX] crm helpdesk : don't list categories without section lp bug: https://launchpad.net/bugs/810404 fixed bzr revid: dbr@tinyerp.com-20110719054915-3qlup3512yktkpko --- addons/crm_helpdesk/crm_helpdesk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py index 5d02ec12369..f8f1bca6fa0 100644 --- a/addons/crm_helpdesk/crm_helpdesk.py +++ b/addons/crm_helpdesk/crm_helpdesk.py @@ -71,7 +71,7 @@ class crm_helpdesk(crm.crm_case, osv.osv): 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'), 'probability': fields.float('Probability (%)'), 'categ_id': fields.many2one('crm.case.categ', 'Category', \ - domain="[('section_id','=',section_id),\ + domain="['|',('section_id','=',False),('section_id','=',section_id),\ ('object_id.model', '=', 'crm.helpdesk')]"), 'duration': fields.float('Duration', states={'done': [('readonly', True)]}), 'state': fields.selection(crm.AVAILABLE_STATES, 'State', size=16, readonly=True, From cab72a2d5451e5c48f91b91e0c7dfc652351d6b2 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Wed, 20 Jul 2011 14:25:05 +0530 Subject: [PATCH 024/362] [FIX]:when merging PO put minimum order date of all merged PO lp bug: https://launchpad.net/bugs/812871 fixed bzr revid: ksa@tinyerp.co.in-20110720085505-q17ufdhft9znoefi --- addons/purchase/purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6ec558acc97..ccd9817f2c8 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -532,6 +532,7 @@ class purchase_order(osv.osv): new_orders = {} for porder in [order for order in self.browse(cr, uid, ids, context=context) if order.state == 'draft']: + date_orders = sorted([obj.date_order for obj in self.browse(cr, uid, ids, context=context)]) order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id')) new_order = new_orders.setdefault(order_key, ({}, [])) new_order[1].append(porder.id) @@ -539,7 +540,7 @@ class purchase_order(osv.osv): if not order_infos: order_infos.update({ 'origin': porder.origin, - 'date_order': time.strftime('%Y-%m-%d'), + 'date_order': date_orders[0], 'partner_id': porder.partner_id.id, 'partner_address_id': porder.partner_address_id.id, 'dest_address_id': porder.dest_address_id.id, From 431b93bd59fe18a77a1ee3971e497e64da2eed81 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Wed, 20 Jul 2011 15:16:39 +0530 Subject: [PATCH 025/362] [FIX]:wrong scheduled date and order date for PO generated from procurement lp bug: https://launchpad.net/bugs/812794 fixed bzr revid: ksa@tinyerp.co.in-20110720094639-u0hujqlwotv2cgo7 --- addons/purchase/purchase.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6ec558acc97..3818060c9b5 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -792,8 +792,9 @@ class procurement_order(osv.osv): price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner_id, {'uom': uom_id})[pricelist_id] - newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - newdate = (newdate - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay) + order_date = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') + order_date = (order_date - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay) + schedule_date = (order_date - relativedelta(days=company.po_lead)) #Passing partner_id to context for purchase order line integrity of Line name context.update({'lang': partner.lang, 'partner_id': partner_id}) @@ -806,7 +807,7 @@ class procurement_order(osv.osv): 'product_id': procurement.product_id.id, 'product_uom': uom_id, 'price_unit': price, - 'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'), + 'date_planned': schedule_date.strftime('%Y-%m-%d %H:%M:%S'), 'move_dest_id': res_id, 'notes': product.description_purchase, } @@ -822,6 +823,7 @@ class procurement_order(osv.osv): 'partner_address_id': address_id, 'location_id': procurement.location_id.id, 'pricelist_id': pricelist_id, + 'date_order': order_date.strftime('%Y-%m-%d %H:%M:%S'), 'order_line': [(0,0,line)], 'company_id': procurement.company_id.id, 'fiscal_position': partner.property_account_position and partner.property_account_position.id or False From 4c81cfbebd33e2755ae68aed2396cf750a289c13 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 20 Jul 2011 17:22:35 +0530 Subject: [PATCH 026/362] [IMP]multi_company,purchase:Remove a demo data and sql constraint bzr revid: mma@tinyerp.com-20110720115235-k3grrx9ast556sj1 --- addons/multi_company/__openerp__.py | 2 +- addons/multi_company/multi_company_demo.xml | 26 --------------------- addons/purchase/purchase.py | 2 +- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/addons/multi_company/__openerp__.py b/addons/multi_company/__openerp__.py index 2ae556fe1e7..baf3a88c32e 100644 --- a/addons/multi_company/__openerp__.py +++ b/addons/multi_company/__openerp__.py @@ -39,7 +39,7 @@ This module is the base module for other multi-company modules. ], 'init_xml': [], 'update_xml': [ - 'res_company_view.xml', + 'res_company_view.xml' ], 'demo_xml': [ 'multi_company_demo.xml' diff --git a/addons/multi_company/multi_company_demo.xml b/addons/multi_company/multi_company_demo.xml index 583f83d252d..5248a26f4f9 100644 --- a/addons/multi_company/multi_company_demo.xml +++ b/addons/multi_company/multi_company_demo.xml @@ -268,32 +268,6 @@ - - Expenses Journal - (Shop 1) - EXJ-Shop 1 - purchase - - - - - - - - - - - Expenses Journal - (Shop 2) - EXJ-Shop 2 - purchase - - - - - - - - - Expenses Credit Notes Journal - (OpenERP IN) ECNJ-OpenERP IN diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 436ec0b021b..6f6ab0c1b44 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -228,7 +228,7 @@ class purchase_order(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c), } _sql_constraints = [ - ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique !'), + ('name_uniq', 'unique(name)', 'Order Reference must be unique !'), ] _name = "purchase.order" _description = "Purchase Order" From bf8d91d99cd67ab118b4d1a3512299de7c857d75 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Thu, 21 Jul 2011 10:10:50 +0530 Subject: [PATCH 027/362] [IMP]:use min instead of sort bzr revid: ksa@tinyerp.co.in-20110721044050-9lmfuxyvw0nv7z5c --- addons/purchase/purchase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index ccd9817f2c8..e029aac1c0d 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -532,7 +532,7 @@ class purchase_order(osv.osv): new_orders = {} for porder in [order for order in self.browse(cr, uid, ids, context=context) if order.state == 'draft']: - date_orders = sorted([obj.date_order for obj in self.browse(cr, uid, ids, context=context)]) + date_orders = min([obj.date_order for obj in self.browse(cr, uid, ids, context=context)]) order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id')) new_order = new_orders.setdefault(order_key, ({}, [])) new_order[1].append(porder.id) @@ -540,7 +540,7 @@ class purchase_order(osv.osv): if not order_infos: order_infos.update({ 'origin': porder.origin, - 'date_order': date_orders[0], + 'date_order': date_orders, 'partner_id': porder.partner_id.id, 'partner_address_id': porder.partner_address_id.id, 'dest_address_id': porder.dest_address_id.id, From 8691e4b906fb4c114fa687665953a978b7efe2c8 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Thu, 21 Jul 2011 11:29:40 +0530 Subject: [PATCH 028/362] [IMP]:improve bzr revid: ksa@tinyerp.co.in-20110721055940-poqs2hb1ppvxdss9 --- addons/purchase/purchase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 3818060c9b5..67223903219 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -793,7 +793,7 @@ class procurement_order(osv.osv): price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner_id, {'uom': uom_id})[pricelist_id] order_date = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - order_date = (order_date - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay) + order_dates = (order_date - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay) schedule_date = (order_date - relativedelta(days=company.po_lead)) #Passing partner_id to context for purchase order line integrity of Line name @@ -823,7 +823,7 @@ class procurement_order(osv.osv): 'partner_address_id': address_id, 'location_id': procurement.location_id.id, 'pricelist_id': pricelist_id, - 'date_order': order_date.strftime('%Y-%m-%d %H:%M:%S'), + 'date_order': order_dates.strftime('%Y-%m-%d %H:%M:%S'), 'order_line': [(0,0,line)], 'company_id': procurement.company_id.id, 'fiscal_position': partner.property_account_position and partner.property_account_position.id or False From bfcfaf85c401d4692175a6bbf3a48dcfd16a22e3 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Thu, 21 Jul 2011 11:58:03 +0530 Subject: [PATCH 029/362] [FIX] stock: Accounting entries from goods receipt now broken lp bug: https://launchpad.net/bugs/797477 fixed bzr revid: psi@tinyerp.co.in-20110721062803-t1hqbapndzsq6qsa --- addons/stock/wizard/stock_invoice_onshipping.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py index 42add8019c4..06951a717d9 100644 --- a/addons/stock/wizard/stock_invoice_onshipping.py +++ b/addons/stock/wizard/stock_invoice_onshipping.py @@ -38,7 +38,7 @@ class stock_invoice_onshipping(osv.osv_memory): res_ids = context and context.get('active_ids', []) vals = [] browse_picking = model_pool.browse(cr, uid, res_ids, context=context) - + for pick in browse_picking: src_usage = pick.move_lines[0].location_id.usage dest_usage = pick.move_lines[0].location_dest_id.usage @@ -53,7 +53,7 @@ class stock_invoice_onshipping(osv.osv_memory): journal_type = 'sale_refund' else: journal_type = 'sale' - + value = journal_obj.search(cr, uid, [('type', '=',journal_type )]) for jr_type in journal_obj.browse(cr, uid, value, context=context): t1 = jr_type.id,jr_type.name @@ -129,7 +129,7 @@ class stock_invoice_onshipping(osv.osv_memory): res = picking_pool.action_invoice_create(cr, uid, active_ids, journal_id = onshipdata_obj[0]['journal_id'], group = onshipdata_obj[0]['group'], - type = None, + type = inv_type, context=context) return res From 97b38de7c5b20c72c8300e5e415243167a5b956f Mon Sep 17 00:00:00 2001 From: "Graeme Gellatly (gdgellatly)" <> Date: Thu, 21 Jul 2011 12:01:39 +0530 Subject: [PATCH 030/362] [FIX] stock: Accounting entries from goods receipt now broken lp bug: https://launchpad.net/bugs/797477 fixed bzr revid: psi@tinyerp.co.in-20110721063139-383nbh9v2elp407x --- addons/stock/wizard/stock_invoice_onshipping.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py index 42add8019c4..06951a717d9 100644 --- a/addons/stock/wizard/stock_invoice_onshipping.py +++ b/addons/stock/wizard/stock_invoice_onshipping.py @@ -38,7 +38,7 @@ class stock_invoice_onshipping(osv.osv_memory): res_ids = context and context.get('active_ids', []) vals = [] browse_picking = model_pool.browse(cr, uid, res_ids, context=context) - + for pick in browse_picking: src_usage = pick.move_lines[0].location_id.usage dest_usage = pick.move_lines[0].location_dest_id.usage @@ -53,7 +53,7 @@ class stock_invoice_onshipping(osv.osv_memory): journal_type = 'sale_refund' else: journal_type = 'sale' - + value = journal_obj.search(cr, uid, [('type', '=',journal_type )]) for jr_type in journal_obj.browse(cr, uid, value, context=context): t1 = jr_type.id,jr_type.name @@ -129,7 +129,7 @@ class stock_invoice_onshipping(osv.osv_memory): res = picking_pool.action_invoice_create(cr, uid, active_ids, journal_id = onshipdata_obj[0]['journal_id'], group = onshipdata_obj[0]['group'], - type = None, + type = inv_type, context=context) return res From 8e7247624f590a209099707b6b920f66d03f21c7 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Thu, 21 Jul 2011 14:44:32 +0530 Subject: [PATCH 031/362] [FIX] res_partner bank - IBAN must check for SWIFT/BIC in res_bank lp bug: https://launchpad.net/bugs/805996 fixed bzr revid: ara@tinyerp.com-20110721091432-xavmr81nh4s4q237 --- addons/base_iban/base_iban.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/base_iban/base_iban.py b/addons/base_iban/base_iban.py index f473bd090c0..feb36dd8a47 100644 --- a/addons/base_iban/base_iban.py +++ b/addons/base_iban/base_iban.py @@ -120,6 +120,15 @@ class res_partner_bank(osv.osv): return _('The IBAN does not seem to be correct. You should have entered something like this %s'), (iban_example) return _('The IBAN is invalid, It should begin with the country code'), () + def _check_bank(self, cr, uid, ids, context=None): + if context is None: + context = {} + banks = self.browse(cr, uid, ids, context=context) + for bank in banks: + if bank.state == 'iban' and not bank.bank.bic: + return False + return True + def name_get(self, cr, uid, ids, context=None): res = [] to_check_ids = [] @@ -172,8 +181,7 @@ class res_partner_bank(osv.osv): _columns = { 'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"), } - - _constraints = [(check_iban, _construct_constraint_msg, ["iban"])] + _constraints = [(check_iban, _construct_constraint_msg, ["iban"]), (_check_bank, '\nPlease define BIC/Swift code on bank for bank type IBAN Account to make valid payments', ['BIC/Swift code'])] res_partner_bank() From 5783538775c9af6483bb6fa305d9fb91ec05ab5b Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Thu, 21 Jul 2011 15:29:35 +0530 Subject: [PATCH 032/362] [FIX] account : Added the company_id in product_id_change method in account_anglo_saxon module lp bug: https://launchpad.net/bugs/813329 fixed bzr revid: bde@tinyerp.com-20110721095935-fm8t1pq9rg2rgdts --- addons/account_anglo_saxon/invoice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index c37a93b4be4..e8a650e6a50 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -136,11 +136,11 @@ class account_invoice_line(osv.osv): res += diff_res return res - def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): + def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None, company_id=None): if not product: - return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context) + return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) else: - res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context) + res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) if type in ('in_invoice','in_refund'): product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context) From fcbab41369587f7069f8e275fe00b1ff1c3b51a0 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Thu, 21 Jul 2011 16:51:40 +0530 Subject: [PATCH 033/362] [IMP]:get order date accoring to partner bzr revid: ksa@tinyerp.co.in-20110721112140-rzfouzx1x5zsrk71 --- addons/purchase/purchase.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index e029aac1c0d..012c9a8bbfb 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -532,7 +532,8 @@ class purchase_order(osv.osv): new_orders = {} for porder in [order for order in self.browse(cr, uid, ids, context=context) if order.state == 'draft']: - date_orders = min([obj.date_order for obj in self.browse(cr, uid, ids, context=context)]) + partner_ids = self.search(cr,uid,[('partner_id','=',porder.partner_id.id)]) + date_orders = min([obj.date_order for obj in self.browse(cr, uid, partner_ids, context=context)]) order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id')) new_order = new_orders.setdefault(order_key, ({}, [])) new_order[1].append(porder.id) From 8c7faca654db02b7b208ab65723d5f4491d74b34 Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Fri, 22 Jul 2011 11:58:39 +0530 Subject: [PATCH 034/362] [FIX] changed the internal_type and user_type of account when Generic chart of account is configured lp bug: https://launchpad.net/bugs/814053 fixed bzr revid: bde@tinyerp.com-20110722062839-lwmg8oigwm9jt11h --- addons/account/configurable_account_chart.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml index fbae77349af..81d01ee4c10 100644 --- a/addons/account/configurable_account_chart.xml +++ b/addons/account/configurable_account_chart.xml @@ -187,8 +187,8 @@ 1104 Bank Current Account - liquidity - + view + @@ -447,7 +447,7 @@ - + @@ -612,7 +612,7 @@ - + Generate Chart of Accounts from a Chart Template From 6fa4a0491c5573be62d642bc7d394d2c4b323f35 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Fri, 22 Jul 2011 11:59:13 +0530 Subject: [PATCH 035/362] [IMP]:improved bzr revid: ksa@tinyerp.co.in-20110722062913-9roigkh4i6etvpj6 --- 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 012c9a8bbfb..723f5e426c8 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -532,8 +532,6 @@ class purchase_order(osv.osv): new_orders = {} for porder in [order for order in self.browse(cr, uid, ids, context=context) if order.state == 'draft']: - partner_ids = self.search(cr,uid,[('partner_id','=',porder.partner_id.id)]) - date_orders = min([obj.date_order for obj in self.browse(cr, uid, partner_ids, context=context)]) order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id')) new_order = new_orders.setdefault(order_key, ({}, [])) new_order[1].append(porder.id) @@ -541,7 +539,7 @@ class purchase_order(osv.osv): if not order_infos: order_infos.update({ 'origin': porder.origin, - 'date_order': date_orders, + 'date_order': porder.date_order, 'partner_id': porder.partner_id.id, 'partner_address_id': porder.partner_address_id.id, 'dest_address_id': porder.dest_address_id.id, @@ -554,6 +552,8 @@ class purchase_order(osv.osv): 'fiscal_position': porder.fiscal_position and porder.fiscal_position.id or False, }) else: + if porder.date_order < order_infos['date_order']: + order_infos['date_order'] = porder.date_order if porder.notes: order_infos['notes'] = (order_infos['notes'] or '') + ('\n%s' % (porder.notes,)) if porder.origin: From f1b56240b0ea6265a384a4946cc478c414073d67 Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Fri, 22 Jul 2011 18:53:24 +0530 Subject: [PATCH 036/362] [IMP]: improve code bzr revid: ksa@tinyerp.co.in-20110722132324-ojbbzlcp0xrl3jvt --- addons/purchase/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 67223903219..0d6e75437ff 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -793,8 +793,8 @@ class procurement_order(osv.osv): price = pricelist_obj.price_get(cr, uid, [pricelist_id], procurement.product_id.id, qty, partner_id, {'uom': uom_id})[pricelist_id] order_date = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - order_dates = (order_date - relativedelta(days=company.po_lead)) - relativedelta(days=seller_delay) schedule_date = (order_date - relativedelta(days=company.po_lead)) + order_dates = schedule_date - relativedelta(days=seller_delay) #Passing partner_id to context for purchase order line integrity of Line name context.update({'lang': partner.lang, 'partner_id': partner_id}) From 4df2c92250819fb18360b177144967498e740ab1 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 25 Jul 2011 14:51:57 +0530 Subject: [PATCH 037/362] [FIX] res_partner bank - IBAN must check for SWIFT/BIC in res_bank bzr revid: ara@tinyerp.com-20110725092157-pxtdtjf930usk3dl --- addons/base_iban/base_iban.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/addons/base_iban/base_iban.py b/addons/base_iban/base_iban.py index feb36dd8a47..446db474f65 100644 --- a/addons/base_iban/base_iban.py +++ b/addons/base_iban/base_iban.py @@ -121,11 +121,8 @@ class res_partner_bank(osv.osv): return _('The IBAN is invalid, It should begin with the country code'), () def _check_bank(self, cr, uid, ids, context=None): - if context is None: - context = {} - banks = self.browse(cr, uid, ids, context=context) - for bank in banks: - if bank.state == 'iban' and not bank.bank.bic: + for partner_bank in self.browse(cr, uid, ids, context=context): + if partner_bank.state == 'iban' and not partner_bank.bank.bic: return False return True From e678571316569ddda52825d2cd8cd72b5e20ab22 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 25 Jul 2011 15:44:24 +0530 Subject: [PATCH 038/362] [IMP] account_anglo_saxon: Improve code bzr revid: mra@mra-laptop-20110725101424-q3zlft8s7tsz8dys --- addons/account_anglo_saxon/invoice.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index e8a650e6a50..2bdac8b01fe 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -134,14 +134,13 @@ class account_invoice_line(osv.osv): 'taxes':line.get('taxes',[]), }) res += diff_res - return res - - def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None, company_id=None): - if not product: - return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) - else: - res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) + return res + def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None, company_id=None): + fiscal_pool = self.pool.get('account.fiscal.position') + res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) + if not product: + return res if type in ('in_invoice','in_refund'): product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context) if type == 'in_invoice': @@ -153,11 +152,11 @@ class account_invoice_line(osv.osv): if not oa: oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id if oa: - fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False - a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa) - res['value'].update({'account_id':a}) + fpos = fposition_id and fiscal_pool.browse(cr, uid, fposition_id, context=context) or False + a = fiscal_pool.map_account(cr, uid, fpos, oa) + res['value'].update({'account_id':a}) return res - + account_invoice_line() class account_invoice(osv.osv): @@ -180,6 +179,6 @@ class account_invoice(osv.osv): line.update({'account_id': (account_data['id'],account_data['name'])}) res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines) return res - + account_invoice() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 9466968e63f5d948a18a46739fb7ef1eeed140c5 Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Mon, 25 Jul 2011 16:36:34 +0530 Subject: [PATCH 039/362] [IMP] changed the account type to Asset View bzr revid: bde@tinyerp.com-20110725110634-orjxdm836m5zzrif --- addons/account/configurable_account_chart.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml index 81d01ee4c10..2c999cf1094 100644 --- a/addons/account/configurable_account_chart.xml +++ b/addons/account/configurable_account_chart.xml @@ -188,7 +188,7 @@ Bank Current Account view - + From d196118cdee85f246d2ddd19e39b29137bb288dc Mon Sep 17 00:00:00 2001 From: "Kunal Chavda (OpenERP)" Date: Wed, 27 Jul 2011 12:13:25 +0530 Subject: [PATCH 040/362] [IMP]Implement Import data Functionality. bzr revid: kch@tinyerp.com-20110727064325-zh8j9w7bvcdckv7v --- addons/base/__openerp__.py | 1 + addons/base/controllers/main.py | 86 ++++++++++++++++++++++----- addons/base/static/src/js/base.js | 3 + addons/base/static/src/js/import.js | 35 +++++++++++ addons/base/static/src/js/views.js | 17 +++++- addons/base/static/src/xml/base.xml | 91 +++++++++++++++++++++++++++-- 6 files changed, 214 insertions(+), 19 deletions(-) create mode 100644 addons/base/static/src/js/import.js diff --git a/addons/base/__openerp__.py b/addons/base/__openerp__.py index a983a4227ce..b4ff7052242 100644 --- a/addons/base/__openerp__.py +++ b/addons/base/__openerp__.py @@ -28,6 +28,7 @@ "static/src/js/list-editable.js", "static/src/js/search.js", "static/src/js/view_tree.js", + "static/src/js/import.js", ], 'css' : [ "static/lib/jquery.superfish/css/superfish.css", diff --git a/addons/base/controllers/main.py b/addons/base/controllers/main.py index 628a086e3d6..16b4613df5e 100644 --- a/addons/base/controllers/main.py +++ b/addons/base/controllers/main.py @@ -10,7 +10,7 @@ import openerpweb.ast import openerpweb.nonliterals import cherrypy - +import csv # Should move to openerpweb.Xml2Json class Xml2Json: # xml2json-direct @@ -119,8 +119,8 @@ class WebClient(openerpweb.Controller): %s @@ -222,7 +222,7 @@ class Session(openerpweb.Controller): context, domain = eval_context_and_domain(req.session, openerpweb.nonliterals.CompoundContext(*(contexts or [])), openerpweb.nonliterals.CompoundDomain(*(domains or []))) - + group_by_sequence = [] for candidate in (group_by_seq or []): ctx = req.session.eval_context(candidate, context) @@ -233,7 +233,7 @@ class Session(openerpweb.Controller): group_by_sequence.append(group_by) else: group_by_sequence.extend(group_by) - + return { 'context': context, 'domain': domain, @@ -246,7 +246,7 @@ class Session(openerpweb.Controller): This method store an action object in the session object and returns an integer identifying that action. The method get_session_action() can be used to get back the action. - + :param the_action: The action to save in the session. :type the_action: anything :return: A key identifying the saved action. @@ -269,7 +269,7 @@ class Session(openerpweb.Controller): """ Gets back a previously saved action. This method can return None if the action was saved since too much time (this case should be handled in a smart way). - + :param key: The key given by save_session_action() :type key: integer :return: The saved action or None. @@ -404,7 +404,7 @@ class Menu(openerpweb.Controller): menu_items = Menus.read(menu_ids, ['name', 'sequence', 'parent_id'], context) menu_root = {'id': False, 'name': 'root', 'parent_id': [-1, '']} menu_items.append(menu_root) - + # make a tree using parent_id menu_items_map = dict((menu_item["id"], menu_item) for menu_item in menu_items) for menu_item in menu_items: @@ -511,7 +511,7 @@ class DataSet(openerpweb.Controller): record_map = dict((record['id'], record) for record in records) return [record_map[id] for id in ids if record_map.get(id)] - + @openerpweb.jsonrequest def load(self, req, model, id, fields): m = req.session.model(model) @@ -674,7 +674,7 @@ class View(openerpweb.Controller): except ValueError: # not a literal return openerpweb.nonliterals.Domain(session, domain) - + def parse_context(self, context, session): """ Parses an arbitrary string containing a context, transforms it to either a literal context or a :class:`openerpweb.nonliterals.Context` @@ -764,7 +764,7 @@ class SearchView(View): if field.get('context'): field["context"] = self.parse_domain(field["context"], req.session) return {'fields': fields} - + @openerpweb.jsonrequest def get_filters(self, req, model): Model = req.session.model("ir.filters") @@ -773,7 +773,7 @@ class SearchView(View): filter["context"] = req.session.eval_context(self.parse_context(filter["context"], req.session)) filter["domain"] = req.session.eval_domain(self.parse_domain(filter["domain"], req.session)) return filters - + @openerpweb.jsonrequest def save_filter(self, req, model, name, context_to_save, domain): Model = req.session.model("ir.filters") @@ -903,4 +903,64 @@ class Action(openerpweb.Controller): return clean_action(req.session.model('ir.actions.server').run( [action_id], req.session.eval_context(req.context)), req.session) -# +class Import(View): + _cp_path = "/base/import" + + @openerpweb.httprequest + def import_data(self, req, session_id, callback, model, id, csvfile, csvsep, csvdel, csvcode, csvskip, fields=[]): + import StringIO + context = req.session.eval_context(req.context) + modle_obj = req.session.model(model) + + res = None + content = csvfile.file.read() + print "\n content++++++++++++++++++++++++++++",content + input=StringIO.StringIO(content) + limit = 0 + data = [] + + if not (csvdel and len(csvdel) == 1): + return "The CSV delimiter must be a single character" + + try: + for j, line in enumerate(csv.reader(input, quotechar=str(csvdel), delimiter=str(csvsep))): + # If the line contains no data, we should skip it. + if not line: + continue + if j == limit: + fields = line + else: + data.append(line) + except: + return "CSV Error" + + datas = [] + ctx = context + + if not isinstance(fields, list): + fields = [fields] + + for line in data: + try: + datas.append(map(lambda x:x.decode(csvcode).encode('utf-8'), line)) + except: + datas.append(map(lambda x:x.decode('latin').encode('utf-8'), line)) + + # If the file contains nothing, + if not datas: + return "The file is empty." + + #Inverting the header into column names + try: + res = modle_obj.import_data(fields, datas, 'init', '', False, ctx) + except: + return "Error in Importing Data." + + if res[0]>=0: + return "Successfully Imported %d objects." % (res[0],) + + d = '' + for key,val in res[1].items(): + d+= ('%s: %s' % (key,val)) + + return "Error trying to import this record :%s. ErrorMessage:%s %s" % (d,res[2],res[3]) diff --git a/addons/base/static/src/js/base.js b/addons/base/static/src/js/base.js index 28022f8b764..d5f23209723 100644 --- a/addons/base/static/src/js/base.js +++ b/addons/base/static/src/js/base.js @@ -87,6 +87,9 @@ openerp.base = function(instance) { if (openerp.base.view_tree) { openerp.base.view_tree(instance); } + if (openerp.base.import){ + openerp.base.import(instance); + } }; // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/base/static/src/js/import.js b/addons/base/static/src/js/import.js new file mode 100644 index 00000000000..5b6affe27c7 --- /dev/null +++ b/addons/base/static/src/js/import.js @@ -0,0 +1,35 @@ +openerp.base.import = function(openerp) { +openerp.base.Import = openerp.base.Dialog.extend({ + init: function(parent, dataset, views){ + this._super(parent); + this.dataset = dataset; + this.views = views; + this.views_id = {}; + for (var key in this.views) { + this.views_id[key] = this.views[key].view_id + } + }, + start: function() { + var self = this + self._super(false); + self.template = 'ImportDataView'; + self.dialog_title = "Import Data" + self.open({ + modal: true, + width: '70%', + height: 'auto', + position: 'top', + buttons : { + "Close" : function() { + self.stop(); + }, + "Import File" : function() { + $("#import_data").submit(); + //self.do_import(); + } + }, + close: function(event, ui){ self.close();} + }); + }, +}); +} \ No newline at end of file diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js index b98b0bc637f..1d44fb3a0c0 100644 --- a/addons/base/static/src/js/views.js +++ b/addons/base/static/src/js/views.js @@ -212,11 +212,24 @@ openerp.base.ViewManager = openerp.base.Controller.extend({ } } } + if(this.flags && this.flags.sidebar) { + if(this.$element.find('#importview')){ + this.$element.find('#importview').remove() + } + if(this.active_view == 'list' || this.active_view == 'form') { + this.views[this.active_view].controller.$element.after(QWeb.render('ImportView')) + this.$element.find('#importview').click(function(ev) { + var import_view = new openerp.base.Import(self, self.dataset, self.views); + import_view.start(false); + ev.preventDefault(); + }); + } + } return view_promise; }, /** * Event launched when a controller has been inited. - * + * * @param {String} view_type type of view * @param {String} view the inited controller */ @@ -522,7 +535,7 @@ openerp.base.View = openerp.base.Controller.extend({ * Directly set a view to use instead of calling fields_view_get. This method must * be called before start(). When an embedded view is set, underlying implementations * of openerp.base.View must use the provided view instead of any other one. - * + * * @param embedded_view A view. */ set_embedded_view: function(embedded_view) { diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 10d1539cde1..f7c2cf53054 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -103,7 +103,7 @@ @@ -333,7 +333,7 @@ t-att-data-index="row_index"> - + @@ -821,7 +821,7 @@ -
@@ -944,4 +944,87 @@ .unwrap();
+ + Import + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + +
+

1. Import a .CSV file

+
+ Select a .CSV file to import. If you need a sample of file to import, + you should use the export tool with the "Import Compatible" option. +
+
+ + + + + +
+ +
+
+
+
+ + + + +
+

2. Check your file format

+
+ +
+
+ CSV Options + + + + + + + + + + + + + +
+ +
+
+
+
+
+
From 0a25bfc2ede24275c694fc5305fdcd47ebd436d0 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Wed, 27 Jul 2011 17:23:09 +0530 Subject: [PATCH 041/362] [FIX/BUG] Increased the Ldap Filter Size bzr revid: jam@tinyerp.com-20110727115309-awso1wew48qtisdt --- addons/users_ldap/users_ldap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/users_ldap/users_ldap.py b/addons/users_ldap/users_ldap.py index bddaaeed6ae..7c3bd0d9c17 100644 --- a/addons/users_ldap/users_ldap.py +++ b/addons/users_ldap/users_ldap.py @@ -43,7 +43,7 @@ class CompanyLDAP(osv.osv): 'ldap_password': fields.char('LDAP password', size=64, help=("The password of the user account on the LDAP server that is " "used to query the directory.")), - 'ldap_filter': fields.char('LDAP filter', size=64, required=True), + 'ldap_filter': fields.char('LDAP filter', size=256, required=True), 'ldap_base': fields.char('LDAP base', size=64, required=True), 'user': fields.many2one('res.users', 'Model User', help="Model used for user creation"), From 161b3bd233e3146ed7211019fc069ad40468cbb6 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Thu, 28 Jul 2011 14:48:10 +0530 Subject: [PATCH 042/362] [FIX] res_partner bank - IBAN must check for SWIFT/BIC in res_bank bzr revid: ara@tinyerp.com-20110728091810-akm54utmf4wrbs98 --- addons/base_iban/base_iban.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_iban/base_iban.py b/addons/base_iban/base_iban.py index 446db474f65..ef752203c3f 100644 --- a/addons/base_iban/base_iban.py +++ b/addons/base_iban/base_iban.py @@ -178,7 +178,7 @@ class res_partner_bank(osv.osv): _columns = { 'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"), } - _constraints = [(check_iban, _construct_constraint_msg, ["iban"]), (_check_bank, '\nPlease define BIC/Swift code on bank for bank type IBAN Account to make valid payments', ['BIC/Swift code'])] + _constraints = [(check_iban, _construct_constraint_msg, ["iban"]), (_check_bank, '\nPlease define BIC/Swift code on bank for bank type IBAN Account to make valid payments', ['bic'])] res_partner_bank() From 5c24a193f74a6a12c393877041fc083b1f315911 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 28 Jul 2011 14:02:04 +0200 Subject: [PATCH 043/362] [REF] web_services: removed unused class. bzr revid: vmt@openerp.com-20110728120204-ezzhvkbvlw134n2b --- openerp/service/web_services.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index 40e7ccf1d69..f89329d41b8 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -357,23 +357,9 @@ class db(netsvc.ExportService): raise return True -class _ObjectService(netsvc.ExportService): - "A common base class for those who have fn(db, uid, password,...) " - - def common_dispatch(self, method, auth, params): - (db, uid, passwd ) = params[0:3] - params = params[3:] - security.check(db,uid,passwd) - cr = pooler.get_db(db).cursor() - fn = getattr(self, 'exp_'+method) - res = fn(cr, uid, *params) - cr.commit() - cr.close() - return res - -class common(_ObjectService): +class common(netsvc.ExportService): def __init__(self,name="common"): - _ObjectService.__init__(self,name) + netsvc.ExportService.__init__(self,name) self.joinGroup("web-services") def dispatch(self, method, auth, params): From d8db9e6b1d61daf0a326158d911d6da31761910c Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 28 Jul 2011 14:07:54 +0200 Subject: [PATCH 044/362] [REF] web_services: removed unused new_dispatch method. bzr revid: vmt@openerp.com-20110728120754-deq2a4jiyhne1ynv --- openerp/netsvc.py | 3 --- openerp/service/web_services.py | 17 ----------------- 2 files changed, 20 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 3a2add26421..1037960c851 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -144,9 +144,6 @@ class ExportService(object): def dispatch(self, method, auth, params): raise Exception("stub dispatch at %s" % self.__name) - def new_dispatch(self,method,auth,params): - raise Exception("stub dispatch at %s" % self.__name) - def abortResponse(self, error, description, origin, details): if not tools.config['debug_mode']: raise Exception("%s -- %s\n\n%s"%(origin, description, details)) diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index f89329d41b8..0264150c678 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -73,8 +73,6 @@ class db(netsvc.ExportService): fn = getattr(self, 'exp_'+method) return fn(*params) - def new_dispatch(self,method,auth,params): - pass def _create_empty_database(self, name): db = sql_db.db_connect('template1') cr = db.cursor() @@ -390,10 +388,6 @@ class common(netsvc.ExportService): fn = getattr(self, 'exp_'+method) return fn(*params) - - def new_dispatch(self,method,auth,params): - pass - def exp_about(self, extended=False): """Return information about the OpenERP Server. @@ -575,10 +569,6 @@ class objects_proxy(netsvc.ExportService): return res - def new_dispatch(self,method,auth,params): - pass - - # # Wizard ID: 1 # - None = end of wizard @@ -609,9 +599,6 @@ class wizard(netsvc.ExportService): res = fn(db, uid, *params) return res - def new_dispatch(self,method,auth,params): - pass - def _execute(self, db, uid, wiz_id, datas, action, context): self.wiz_datas[wiz_id].update(datas) wiz = netsvc.LocalService('wizard.'+self.wiz_name[wiz_id]) @@ -670,10 +657,6 @@ class report_spool(netsvc.ExportService): res = fn(db, uid, *params) return res - - def new_dispatch(self,method,auth,params): - pass - def exp_report(self, db, uid, object, ids, datas=None, context=None): if not datas: datas={} From df555e35c15f1c7f93940f7ed45a79c841a738c7 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 28 Jul 2011 14:28:56 +0200 Subject: [PATCH 045/362] [REF] netsvc: LocalService() can be a function. bzr revid: vmt@openerp.com-20110728122856-ne9299uqh21xpabs --- openerp/netsvc.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 1037960c851..81a97f124d1 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -94,25 +94,8 @@ class Service(object): else: raise -class LocalService(object): - """ Proxy for local services. - - Any instance of this class will behave like the single instance - of Service(name) - """ - __logger = logging.getLogger('service') - def __init__(self, name): - self.__name = name - try: - self._service = Service._services[name] - for method_name, method_definition in self._service._methods.items(): - setattr(self, method_name, method_definition) - except KeyError, keyError: - self.__logger.error('This service does not exist: %s' % (str(keyError),) ) - raise - - def __call__(self, method, *params): - return getattr(self, method)(*params) +def LocalService(name): + return Service._services[name] class ExportService(object): """ Proxy for exported services. From e1939127175e0003c6f9bff6157f7eb67807f6f6 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 28 Jul 2011 14:39:16 +0200 Subject: [PATCH 046/362] [REF] netsvc: removed exportMethod that was only used with the previously removed class LocalService. bzr revid: vmt@openerp.com-20110728123916-cobk8vk2oktkidke --- openerp/netsvc.py | 5 ----- openerp/osv/osv.py | 2 -- openerp/report/interface.py | 1 - openerp/wizard/__init__.py | 1 - openerp/workflow/wkf_service.py | 7 ------- 5 files changed, 16 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 81a97f124d1..7fdf927fe64 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -69,7 +69,6 @@ class Service(object): def __init__(self, name, audience=''): Service._services[name] = self self.__name = name - self._methods = {} def joinGroup(self, name): raise Exception("No group for local services") @@ -84,10 +83,6 @@ class Service(object): if cls.exists(name): cls._services.pop(name) - def exportMethod(self, method): - if callable(method): - self._methods[method.__name__] = method - def abortResponse(self, error, description, origin, details): if not tools.config['debug_mode']: raise Exception("%s -- %s\n\n%s"%(origin, description, details)) diff --git a/openerp/osv/osv.py b/openerp/osv/osv.py index 1327efe5731..852e6b7c7ef 100644 --- a/openerp/osv/osv.py +++ b/openerp/osv/osv.py @@ -44,8 +44,6 @@ class object_proxy(netsvc.Service): def __init__(self): self.logger = logging.getLogger('web-services') netsvc.Service.__init__(self, 'object_proxy', audience='') - self.exportMethod(self.exec_workflow) - self.exportMethod(self.execute) def check(f): @wraps(f) diff --git a/openerp/report/interface.py b/openerp/report/interface.py index 178c015ba34..de2a3bba967 100644 --- a/openerp/report/interface.py +++ b/openerp/report/interface.py @@ -52,7 +52,6 @@ class report_int(netsvc.Service): # TODO the reports have methods with a 'title' kwarg that is redundant with this attribute self.title = None #self.joinGroup('report') - self.exportMethod(self.create) def create(self, cr, uid, ids, datas, context=None): return False diff --git a/openerp/wizard/__init__.py b/openerp/wizard/__init__.py index df0b942d0df..536d9303028 100644 --- a/openerp/wizard/__init__.py +++ b/openerp/wizard/__init__.py @@ -44,7 +44,6 @@ class interface(netsvc.Service): def __init__(self, name): assert not self.exists('wizard.'+name), 'The wizard "%s" already exists!' % (name,) super(interface, self).__init__('wizard.'+name) - self.exportMethod(self.execute) self.wiz_name = name def translate_view(self, cr, node, state, lang): diff --git a/openerp/workflow/wkf_service.py b/openerp/workflow/wkf_service.py index 6f5059e6817..3684ac05694 100644 --- a/openerp/workflow/wkf_service.py +++ b/openerp/workflow/wkf_service.py @@ -29,13 +29,6 @@ import openerp.pooler as pooler class workflow_service(netsvc.Service): def __init__(self, name='workflow', audience='*'): netsvc.Service.__init__(self, name, audience) - self.exportMethod(self.trg_write) - self.exportMethod(self.trg_delete) - self.exportMethod(self.trg_create) - self.exportMethod(self.trg_validate) - self.exportMethod(self.trg_redirect) - self.exportMethod(self.trg_trigger) - self.exportMethod(self.clear_cache) self.wkf_on_create_cache={} def clear_cache(self, cr, uid): From 5f3f9e820eca3cd5092e8f8716aaa4428e5466c1 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 28 Jul 2011 15:10:34 +0200 Subject: [PATCH 047/362] [REF] netsvc: Service._groups and joinGroup are unused. bzr revid: vmt@openerp.com-20110728131034-q5wpiwqh7f860l5s --- openerp/netsvc.py | 8 -------- openerp/report/interface.py | 1 - openerp/service/web_services.py | 5 ----- 3 files changed, 14 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 7fdf927fe64..21dfb7d6877 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -70,10 +70,6 @@ class Service(object): Service._services[name] = self self.__name = name - def joinGroup(self, name): - raise Exception("No group for local services") - #GROUPS.setdefault(name, {})[self.__name] = self - @classmethod def exists(cls, name): return name in cls._services @@ -104,7 +100,6 @@ class ExportService(object): """ _services = {} - _groups = {} _logger = logging.getLogger('web-services') def __init__(self, name, audience=''): @@ -112,9 +107,6 @@ class ExportService(object): self.__name = name self._logger.debug("Registered an exported service: %s" % name) - def joinGroup(self, name): - ExportService._groups.setdefault(name, {})[self.__name] = self - @classmethod def getService(cls,name): return cls._services[name] diff --git a/openerp/report/interface.py b/openerp/report/interface.py index de2a3bba967..d940505a342 100644 --- a/openerp/report/interface.py +++ b/openerp/report/interface.py @@ -51,7 +51,6 @@ class report_int(netsvc.Service): self.name2 = '.'.join(name.split('.')[1:]) # TODO the reports have methods with a 'title' kwarg that is redundant with this attribute self.title = None - #self.joinGroup('report') def create(self, cr, uid, ids, datas, context=None): return False diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index 0264150c678..f40cf2009ec 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -50,7 +50,6 @@ from cStringIO import StringIO class db(netsvc.ExportService): def __init__(self, name="db"): netsvc.ExportService.__init__(self, name) - self.joinGroup("web-services") self.actions = {} self.id = 0 self.id_protect = threading.Semaphore() @@ -358,7 +357,6 @@ class db(netsvc.ExportService): class common(netsvc.ExportService): def __init__(self,name="common"): netsvc.ExportService.__init__(self,name) - self.joinGroup("web-services") def dispatch(self, method, auth, params): logger = netsvc.Logger() @@ -553,7 +551,6 @@ GNU Public Licence. class objects_proxy(netsvc.ExportService): def __init__(self, name="object"): netsvc.ExportService.__init__(self,name) - self.joinGroup('web-services') def dispatch(self, method, auth, params): (db, uid, passwd ) = params[0:3] @@ -583,7 +580,6 @@ class objects_proxy(netsvc.ExportService): class wizard(netsvc.ExportService): def __init__(self, name='wizard'): netsvc.ExportService.__init__(self,name) - self.joinGroup('web-services') self.id = 0 self.wiz_datas = {} self.wiz_name = {} @@ -642,7 +638,6 @@ class ExceptionWithTraceback(Exception): class report_spool(netsvc.ExportService): def __init__(self, name='report'): netsvc.ExportService.__init__(self, name) - self.joinGroup('web-services') self._reports = {} self.id = 0 self.id_protect = threading.Semaphore() From 64490ad5ac1497f9dfba85131bfcbbbb242338a3 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 28 Jul 2011 16:19:10 +0200 Subject: [PATCH 048/362] [REF] netsvc: removed unused kwarg. bzr revid: vmt@openerp.com-20110728141910-r0z95l3mf1zeh8us --- openerp/netsvc.py | 4 ++-- openerp/osv/osv.py | 2 +- openerp/report/interface.py | 4 ++-- openerp/workflow/wkf_service.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 21dfb7d6877..09f2048bc03 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -66,7 +66,7 @@ class Service(object): Functionality here is trusted, no authentication. """ _services = {} - def __init__(self, name, audience=''): + def __init__(self, name): Service._services[name] = self self.__name = name @@ -102,7 +102,7 @@ class ExportService(object): _services = {} _logger = logging.getLogger('web-services') - def __init__(self, name, audience=''): + def __init__(self, name): ExportService._services[name] = self self.__name = name self._logger.debug("Registered an exported service: %s" % name) diff --git a/openerp/osv/osv.py b/openerp/osv/osv.py index 852e6b7c7ef..5cffec62794 100644 --- a/openerp/osv/osv.py +++ b/openerp/osv/osv.py @@ -43,7 +43,7 @@ class except_osv(Exception): class object_proxy(netsvc.Service): def __init__(self): self.logger = logging.getLogger('web-services') - netsvc.Service.__init__(self, 'object_proxy', audience='') + netsvc.Service.__init__(self, 'object_proxy') def check(f): @wraps(f) diff --git a/openerp/report/interface.py b/openerp/report/interface.py index d940505a342..110110fb1a9 100644 --- a/openerp/report/interface.py +++ b/openerp/report/interface.py @@ -41,9 +41,9 @@ def toxml(value): return unicode_value.replace('&', '&').replace('<','<').replace('>','>') class report_int(netsvc.Service): - def __init__(self, name, audience='*'): + def __init__(self, name): assert not self.exists(name), 'The report "%s" already exists!' % name - super(report_int, self).__init__(name, audience) + super(report_int, self).__init__(name) if name[0:7]<>'report.': raise Exception, 'ConceptionError, bad report name, should start with "report."' self.name = name diff --git a/openerp/workflow/wkf_service.py b/openerp/workflow/wkf_service.py index 3684ac05694..c74a0ad25c1 100644 --- a/openerp/workflow/wkf_service.py +++ b/openerp/workflow/wkf_service.py @@ -27,8 +27,8 @@ import openerp.netsvc as netsvc import openerp.pooler as pooler class workflow_service(netsvc.Service): - def __init__(self, name='workflow', audience='*'): - netsvc.Service.__init__(self, name, audience) + def __init__(self, name='workflow'): + netsvc.Service.__init__(self, name) self.wkf_on_create_cache={} def clear_cache(self, cr, uid): From c4d7dde6456832d4e4278f7bc357670a33eb458b Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 29 Jul 2011 10:38:24 +0200 Subject: [PATCH 049/362] [REF] netsvc: object_proxy is no longer in netsvc. bzr revid: vmt@openerp.com-20110729083824-onx5kklbgzb9pok2 --- openerp/netsvc.py | 11 +++++++++++ openerp/osv/osv.py | 16 +++++++++------- openerp/report/custom.py | 21 +++++++++------------ openerp/report/print_xml.py | 5 ++--- openerp/service/web_services.py | 14 +++++++------- 5 files changed, 38 insertions(+), 29 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 09f2048bc03..db828babd5e 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -60,6 +60,12 @@ def close_socket(sock): #.apidoc title: Common Services: netsvc #.apidoc module-mods: member-order: bysource +def abort_response(error, description, origin, details): + if not tools.config['debug_mode']: + raise Exception("%s -- %s\n\n%s"%(origin, description, details)) + else: + raise + class Service(object): """ Base class for *Local* services @@ -86,6 +92,11 @@ class Service(object): raise def LocalService(name): + # Special case for addons support, will be removed in a few days when addons + # are updated to directly use openerp.osv.osv.service. + if name == 'object_proxy': + return openerp.osv.osv.service + return Service._services[name] class ExportService(object): diff --git a/openerp/osv/osv.py b/openerp/osv/osv.py index 5cffec62794..02c6fbe3c5d 100644 --- a/openerp/osv/osv.py +++ b/openerp/osv/osv.py @@ -39,11 +39,13 @@ class except_osv(Exception): self.value = value self.args = (exc_type, name) +service = None -class object_proxy(netsvc.Service): +class object_proxy(): def __init__(self): self.logger = logging.getLogger('web-services') - netsvc.Service.__init__(self, 'object_proxy') + global service + service = self def check(f): @wraps(f) @@ -117,14 +119,14 @@ class object_proxy(netsvc.Service): except orm.except_orm, inst: if inst.name == 'AccessError': self.logger.debug("AccessError", exc_info=True) - self.abortResponse(1, inst.name, 'warning', inst.value) + netsvc.abort_response(1, inst.name, 'warning', inst.value) except except_osv, inst: - self.abortResponse(1, inst.name, inst.exc_type, inst.value) + netsvc.abort_response(1, inst.name, inst.exc_type, inst.value) except IntegrityError, inst: osv_pool = pooler.get_pool(dbname) for key in osv_pool._sql_error.keys(): if key in inst[0]: - self.abortResponse(1, _('Constraint Error'), 'warning', + netsvc.abort_response(1, _('Constraint Error'), 'warning', tr(osv_pool._sql_error[key], 'sql_constraint') or inst[0]) if inst.pgcode in (errorcodes.NOT_NULL_VIOLATION, errorcodes.FOREIGN_KEY_VIOLATION, errorcodes.RESTRICT_VIOLATION): msg = _('The operation cannot be completed, probably due to the following:\n- deletion: you may be trying to delete a record while other records still reference it\n- creation/update: a mandatory field is not correctly set') @@ -145,9 +147,9 @@ class object_proxy(netsvc.Service): msg += _('\n\n[object with reference: %s - %s]') % (model_name, model) except Exception: pass - self.abortResponse(1, _('Integrity Error'), 'warning', msg) + netsvc.abort_response(1, _('Integrity Error'), 'warning', msg) else: - self.abortResponse(1, _('Integrity Error'), 'warning', inst[0]) + netsvc.abort_response(1, _('Integrity Error'), 'warning', inst[0]) except Exception: self.logger.exception("Uncaught exception") raise diff --git a/openerp/report/custom.py b/openerp/report/custom.py index f3d6cfbc074..051d1f29862 100644 --- a/openerp/report/custom.py +++ b/openerp/report/custom.py @@ -136,16 +136,15 @@ class report_custom(report_int): ids = self.pool.get(report.model_id.model).search(cr, uid, []) datas['ids'] = ids - service = netsvc.LocalService("object_proxy") report_id = datas['report_id'] - report = service.execute(cr.dbname, uid, 'ir.report.custom', 'read', [report_id], context=context)[0] - fields = service.execute(cr.dbname, uid, 'ir.report.custom.fields', 'read', report['fields_child0'], context=context) + report = self.pool.get('ir.report.custom').read(cr, uid, [report_id], context=context)[0] + fields = self.pool.get('ir.report.custom.fields').read(cr, uid, report['fields_child0'], context=context) fields.sort(lambda x,y : x['sequence'] - y['sequence']) if report['field_parent']: - parent_field = service.execute(cr.dbname, uid, 'ir.model.fields', 'read', [report['field_parent'][0]],['model']) - model_name = service.execute(cr.dbname, uid, 'ir.model', 'read', [report['model_id'][0]], ['model'],context=context)[0]['model'] + parent_field = self.pool.get('ir.model.fields').read(cr, uid, [report['field_parent'][0]], ['model']) + model_name = self.pool.get('ir.model').read(cr, uid, [report['model_id'][0]], ['model'], context=context)[0]['model'] fct = {} fct['id'] = lambda x : x @@ -160,9 +159,7 @@ class report_custom(report_int): field_child = f['field_child'+str(i)] if field_child: row.append( - service.execute(cr.dbname, uid, - 'ir.model.fields', 'read', [field_child[0]], - ['name'], context=context)[0]['name'] + self.pool.get('ir.model.fields').read(cr, uid, [field_child[0]], ['name'], context=context)[0]['name'] ) if f['fc'+str(i)+'_operande']: fct_name = 'id' @@ -346,7 +343,7 @@ class report_custom(report_int): def _create_lines(self, cr, uid, ids, report, fields, results, context): - service = netsvc.LocalService("object_proxy") + pool = pooler.get_pool(cr.dbname) pdf_string = cStringIO.StringIO() can = canvas.init(fname=pdf_string, format='pdf') @@ -376,7 +373,7 @@ class report_custom(report_int): for f in fields: field_id = (f['field_child3'] and f['field_child3'][0]) or (f['field_child2'] and f['field_child2'][0]) or (f['field_child1'] and f['field_child1'][0]) or (f['field_child0'] and f['field_child0'][0]) if field_id: - type = service.execute(cr.dbname, uid, 'ir.model.fields', 'read', [field_id],['ttype']) + type = pool.get('ir.model.fields').read(cr, uid, [field_id],['ttype']) if type[0]['ttype'] == 'date': date_idx = idx fct[idx] = process_date[report['frequency']] @@ -449,7 +446,7 @@ class report_custom(report_int): def _create_bars(self, cr, uid, ids, report, fields, results, context): - service = netsvc.LocalService("object_proxy") + pool = pooler.get_pool(cr.dbname) pdf_string = cStringIO.StringIO() can = canvas.init(fname=pdf_string, format='pdf') @@ -475,7 +472,7 @@ class report_custom(report_int): for f in fields: field_id = (f['field_child3'] and f['field_child3'][0]) or (f['field_child2'] and f['field_child2'][0]) or (f['field_child1'] and f['field_child1'][0]) or (f['field_child0'] and f['field_child0'][0]) if field_id: - type = service.execute(cr.dbname, uid, 'ir.model.fields', 'read', [field_id],['ttype']) + type = pool.get('ir.model.fields').read(cr, uid, [field_id],['ttype']) if type[0]['ttype'] == 'date': date_idx = idx fct[idx] = process_date[report['frequency']] diff --git a/openerp/report/print_xml.py b/openerp/report/print_xml.py index ad2b0528d99..b7074a2d0c3 100644 --- a/openerp/report/print_xml.py +++ b/openerp/report/print_xml.py @@ -137,9 +137,8 @@ class document(object): value = self.get_value(browser, attrs['name']) - service = netsvc.LocalService("object_proxy") - ids = service.execute(self.cr.dbname, self.uid, 'ir.attachment', 'search', [('res_model','=',model),('res_id','=',int(value))]) - datas = service.execute(self.cr.dbname, self.uid, 'ir.attachment', 'read', ids) + ids = self.pool.get('ir.attachment').search(self.cr, self.uid, [('res_model','=',model),('res_id','=',int(value))]) + datas = self.pool.get('ir.attachment').read(self.cr, self.uid, ids) if len(datas): # if there are several, pick first diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index f40cf2009ec..fb347c38970 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -344,9 +344,9 @@ class db(netsvc.ExportService): tools.config['update']['base'] = True pooler.restart_pool(db, force_demo=False, update_module=True) except except_orm, inst: - self.abortResponse(1, inst.name, 'warning', inst.value) + netsvc.abort_response(1, inst.name, 'warning', inst.value) except except_osv, inst: - self.abortResponse(1, inst.name, inst.exc_type, inst.value) + netsvc.abort_response(1, inst.name, inst.exc_type, inst.value) except Exception: import traceback tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback)) @@ -419,7 +419,7 @@ GNU Public Licence. return rc.get_available_updates(rc.id, openerp.modules.get_modules_with_version()) except tm.RemoteContractException, e: - self.abortResponse(1, 'Migration Error', 'warning', str(e)) + netsvc.abort_response(1, 'Migration Error', 'warning', str(e)) def exp_get_migration_scripts(self, contract_id, contract_password): @@ -487,7 +487,7 @@ GNU Public Licence. return True except tm.RemoteContractException, e: - self.abortResponse(1, 'Migration Error', 'warning', str(e)) + netsvc.abort_response(1, 'Migration Error', 'warning', str(e)) except Exception, e: import traceback tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback)) @@ -560,8 +560,8 @@ class objects_proxy(netsvc.ExportService): if method not in ['execute','exec_workflow']: raise NameError("Method not available %s" % method) security.check(db,uid,passwd) - ls = netsvc.LocalService('object_proxy') - fn = getattr(ls, method) + assert openerp.osv.osv.service, "The object_proxy class must be started with start_object_proxy." + fn = getattr(openerp.osv.osv.service, method) res = fn(db, uid, *params) return res @@ -701,7 +701,7 @@ class report_spool(netsvc.ExportService): result = self._reports[report_id] exc = result['exception'] if exc: - self.abortResponse(exc, exc.message, 'warning', exc.traceback) + netsvc.abort_response(exc, exc.message, 'warning', exc.traceback) res = {'state': result['state']} if res['state']: if tools.config['reportgz']: From 9ea28d59700a2cc44cfb89744a3fea88f6007a81 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 29 Jul 2011 11:08:20 +0200 Subject: [PATCH 050/362] [REF] netsvc: netsvc wont provide any longer LocalService("object_service"), better use the model directly. bzr revid: vmt@openerp.com-20110729090820-6kvt9a2swqeepmhn --- addons/auction/report/artists_lots.py | 5 +++-- addons/auction/report/seller_address.py | 8 ++++---- addons/auction/report/total.py | 8 +++----- addons/auction/wizard/auction_aie_send.py | 6 ++---- addons/auction/wizard/auction_aie_send_result.py | 3 +-- addons/auction/wizard/auction_lots_invoice.py | 10 ++++------ 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/addons/auction/report/artists_lots.py b/addons/auction/report/artists_lots.py index 981440dac53..6c9344c88db 100644 --- a/addons/auction/report/artists_lots.py +++ b/addons/auction/report/artists_lots.py @@ -21,14 +21,15 @@ from report.interface import report_int import netsvc +import openerp.pooler class report_artistlot(report_int): def __init__(self, name): report_int.__init__(self, name) def create(self, cr, uid, ids, datas, context): - service = netsvc.LocalService("object_proxy") - lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['artist_id']) + pool = pooler.get_pool(cr.dbname) + lots = pool.get('auction.lots').read(cr, uid, ids, ['artist_id']) artists = [] for lot in lots: if lot['artist_id'] and lot['artist_id'] not in artists: diff --git a/addons/auction/report/seller_address.py b/addons/auction/report/seller_address.py index 315533e99f4..7a7c10cb4aa 100644 --- a/addons/auction/report/seller_address.py +++ b/addons/auction/report/seller_address.py @@ -20,15 +20,15 @@ ############################################################################## from report.interface import report_int -import netsvc +import openerp.pooler class auction_seller(report_int): def __init__(self, name): report_int.__init__(self, name) def create(self, cr, uid, ids, datas, context): - service = netsvc.LocalService("object_proxy") - lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['bord_vnd_id']) + pool = openerp.pooler.get_pool(cr.dbname) + lots = pool.get('auction.lots').read(cr, uid, ids, ['bord_vnd_id']) bords = {} for l in lots: @@ -37,7 +37,7 @@ class auction_seller(report_int): new_ids = bords.keys() parts = {} - partners = service.execute(cr.dbname, uid, 'auction.deposit', 'read', new_ids, ['partner_id']) + partners = pool.get('auction.deposit').read(cr, uid, new_ids, ['partner_id']) for l in partners: if l['partner_id']: parts[l['partner_id'][0]]=True diff --git a/addons/auction/report/total.py b/addons/auction/report/total.py index e878001c2e4..609a1ad3a48 100644 --- a/addons/auction/report/total.py +++ b/addons/auction/report/total.py @@ -32,10 +32,8 @@ class report_custom(report_rml): report_rml.__init__(self, name, table, tmpl, xsl) def create_xml(self, cr, uid, ids, datas, context=None): - service = netsvc.LocalService("object_proxy") - - lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id']) - auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0] + lots = self.pool.get('auction.lots').read(cr, uid , ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id']) + auction = self.pool.get('auction.dates').read(cr, uid, [lots[0]['auction_id'][0]])[0] unsold = comm = emp = paid = unpaid = 0 est1 = est2 = adj = 0 @@ -75,7 +73,7 @@ class report_custom(report_rml): debit = adj - costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_seller_costs', ids) + costs = self.pool.get('auction.lots').compute_seller_costs(cr, uid, ids) for cost in costs: debit += cost['amount'] diff --git a/addons/auction/wizard/auction_aie_send.py b/addons/auction/wizard/auction_aie_send.py index 1caec13b852..563230c0d1f 100644 --- a/addons/auction/wizard/auction_aie_send.py +++ b/addons/auction/wizard/auction_aie_send.py @@ -141,9 +141,8 @@ class auction_lots_send_aie(osv.osv_memory): def _photos_send(cr, uid, uname, passwd, did, ids): - service = netsvc.LocalService("object_proxy") for (ref,id) in ids: - datas = service.execute(cr.db_name, uid, 'auction.lots', 'read', [id], ['name','image']) + datas = self.pool.get('auction.lots').read(cr, uid, [id], ['name','image']) if len(datas): bin = base64.decodestring(datas[0]['image']) fname = datas[0]['name'] @@ -186,8 +185,7 @@ class auction_lots_send_aie(osv.osv_memory): if context is None: context = {} - service = netsvc.LocalService("object_proxy") - lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids',[]), ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ']) + lots = self.pool.get('auction.lots').read(cr, uid, context.get('active_ids',[]), ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ']) lots_ids = [] datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates']) for l in lots: diff --git a/addons/auction/wizard/auction_aie_send_result.py b/addons/auction/wizard/auction_aie_send_result.py index d6102dd0522..24489fda441 100644 --- a/addons/auction/wizard/auction_aie_send_result.py +++ b/addons/auction/wizard/auction_aie_send_result.py @@ -132,9 +132,8 @@ class auction_lots_pay(osv.osv_memory): if context is None: context = {} import pickle - service = netsvc.LocalService("object_proxy") datas = self.read(cr, uid, ids[0],['uname','password','dates']) - lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context['active_ids'], ['obj_num','obj_price']) + lots = self.pool.get('auction.lots').read(cr, uid, context['active_ids'], ['obj_num','obj_price']) args = pickle.dumps(lots) self._catalog_send(datas['uname'], datas['password'], datas['dates'], args) return {'type': 'ir.actions.act_window_close'} diff --git a/addons/auction/wizard/auction_lots_invoice.py b/addons/auction/wizard/auction_lots_invoice.py index 66bb5e42f2b..3994aa6ff91 100644 --- a/addons/auction/wizard/auction_lots_invoice.py +++ b/addons/auction/wizard/auction_lots_invoice.py @@ -49,9 +49,8 @@ class auction_lots_invoice(osv.osv_memory): if context is None: context = {} res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context) - service = netsvc.LocalService("object_proxy") - lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', [])) - auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0] + lots = self.pool.get('auction.lots').read(cr, uid, context.get('active_ids', [])) + auction = self.pool.get('auction.dates').read(cr, uid, [lots[0]['auction_id'][0]])[0] price = 0.0 price_topay = 0.0 @@ -59,7 +58,7 @@ class auction_lots_invoice(osv.osv_memory): for lot in lots: price_lot = lot['obj_price'] or 0.0 - costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_buyer_costs', [lot['id']]) + costs = self.pool.get('auction.lots').compute_buyer_costs(cr, uid, [lot['id']]) price_lot += costs['amount'] price += price_lot @@ -68,7 +67,7 @@ class auction_lots_invoice(osv.osv_memory): raise osv.except_osv(_('UserError'), _('Two different buyers for the same invoice !\nPlease correct this problem before invoicing')) uid = lot['ach_uid'][0] elif lot['ach_login']: - refs = service.execute(uid, 'res.partner', 'search', [('ref','=',lot['ach_login'])]) + refs = self.pool.get('res.partner').search(cr, uid, [('ref','=',lot['ach_login'])]) if len(refs): uid = refs[-1] if 'ach_pay_id' in lot and lot['ach_pay_id']: @@ -105,7 +104,6 @@ class auction_lots_invoice(osv.osv_memory): """ if context is None: context = {} - service = netsvc.LocalService("object_proxy") datas = {'ids' : context.get('active_ids',[])} res = self.read(cr, uid, ids, ['number','ach_uid']) res = res and res[0] or {} From 40bde558c5df3061b631899aee84585a02b092f2 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 29 Jul 2011 11:41:22 +0200 Subject: [PATCH 051/362] [REF] netsvc: removed abortResponse method. bzr revid: vmt@openerp.com-20110729094122-8c2q2c1nx0x7jdmf --- openerp/netsvc.py | 6 ------ openerp/wizard/__init__.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index db828babd5e..f3c13535d6f 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -85,12 +85,6 @@ class Service(object): if cls.exists(name): cls._services.pop(name) - def abortResponse(self, error, description, origin, details): - if not tools.config['debug_mode']: - raise Exception("%s -- %s\n\n%s"%(origin, description, details)) - else: - raise - def LocalService(name): # Special case for addons support, will be removed in a few days when addons # are updated to directly use openerp.osv.osv.service. diff --git a/openerp/wizard/__init__.py b/openerp/wizard/__init__.py index 536d9303028..2ed01921afa 100644 --- a/openerp/wizard/__init__.py +++ b/openerp/wizard/__init__.py @@ -155,7 +155,7 @@ class interface(netsvc.Service): if isinstance(e, except_wizard) \ or isinstance(e, except_osv) \ or isinstance(e, except_orm): - self.abortResponse(2, e.name, 'warning', e.value) + netsvc.abort_response(2, e.name, 'warning', e.value) else: import traceback tb_s = reduce(lambda x, y: x+y, traceback.format_exception( From 4f149e642b7e4e9cf5dc298d895c80fef5ffc298 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Fri, 29 Jul 2011 16:49:53 +0530 Subject: [PATCH 052/362] [IMP]stock:Improvement in yml bzr revid: mma@tinyerp.com-20110729111953-0mbb9za6nhn0hhl9 --- addons/stock/__openerp__.py | 1 + addons/stock/report/UPS.xml | 28 ------ addons/stock/report/__init__.py | 1 - addons/stock/report/ups.py | 39 -------- addons/stock/test/stock_test.yml | 116 +++++++++++++++++++++-- addons/stock/test/stock_test_wizard.yml | 120 ++++++++++++++++++++++++ addons/stock/wizard/__init__.py | 1 - addons/stock/wizard/stock_ups.py | 95 ------------------- addons/stock/wizard/stock_ups_view.xml | 56 ----------- 9 files changed, 231 insertions(+), 226 deletions(-) delete mode 100644 addons/stock/report/UPS.xml delete mode 100644 addons/stock/report/ups.py create mode 100644 addons/stock/test/stock_test_wizard.yml delete mode 100644 addons/stock/wizard/stock_ups.py delete mode 100644 addons/stock/wizard/stock_ups_view.xml diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 1a33fd3012c..3447f0c8358 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -79,6 +79,7 @@ Thanks to the double entry management, the inventory controlling is powerful and ], 'test': ['test/stock_test.yml', 'test/stock_report.yml', + 'test/stock_test_wizard.yml', ], 'installable': True, 'active': False, diff --git a/addons/stock/report/UPS.xml b/addons/stock/report/UPS.xml deleted file mode 100644 index 0349fda556d..00000000000 --- a/addons/stock/report/UPS.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - ES - - 1 - - - PP - - - - - diff --git a/addons/stock/report/__init__.py b/addons/stock/report/__init__.py index 18bfe2609c2..412e77f3f17 100644 --- a/addons/stock/report/__init__.py +++ b/addons/stock/report/__init__.py @@ -20,7 +20,6 @@ ############################################################################## import product_stock -import ups import picking import lot_overview_all import report_stock diff --git a/addons/stock/report/ups.py b/addons/stock/report/ups.py deleted file mode 100644 index fb8483341ec..00000000000 --- a/addons/stock/report/ups.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from report.interface import report_rml - -class report_custom(report_rml): - def create(self, uid, ids, datas, context): - datas.setdefault('form', {}) - datas['form'].setdefault('weight', 3.0) - - datas['model'] = 'stock.move.lot' - datas['ids'] = ids - del datas['id'] - - return (super(report_custom, self).create(uid, ids, datas, context), 'pdf') - -report_custom('report.stock.move.lot.ups_xml', 'stock.move.lot', 'addons/stock/report/UPS.xml', None) - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/test/stock_test.yml b/addons/stock/test/stock_test.yml index 762908e6b0c..2a6b7b37aeb 100644 --- a/addons/stock/test/stock_test.yml +++ b/addons/stock/test/stock_test.yml @@ -205,8 +205,9 @@ - !record {model: product.product, id: product_product_hpcdwriters0}: categ_id: stock.product_category_computer0 - cost_method: standard - list_price: 1000.0 + cost_method: average + list_price: 1500.0 + standard_price: 1500.0 mes_type: fixed name: HP CD writers procure_method: make_to_stock @@ -220,7 +221,47 @@ uom_po_id: product.product_uom_unit property_account_expense: account_account_productpurchase0 property_account_income: account_account_productsale0 +- + I create change product quantity for product HP CD writers. +- + !record {model: stock.change.product.qty, id: stock_change_product_qty0}: + product_id: stock.product_product_hpcdwriters0 + new_quantity: 10 + location_id: stock.stock_location_stock +- + I apply the new quantity on product HP CD writers. +- + !python {model: stock.change.product.qty }: | + self.change_product_qty(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model": + "stock.change.product.qty", "active_ids": ref("stock.product_product_hpcdwriters0"), "tz": False, "active_id":ref('stock.product_product_hpcdwriters0')}) +- + I Read quantity on product HP CD writers. +- + !python {model: stock.location }: | + self.read(cr, uid, [ref("stock.stock_location_stock")],['stock_real_value','stock_virtual'], {'lang': 'en_GB', 'tz': False, 'active_model': 'product.product', 'bin_size': True, 'active_ids': [ref("stock.product_product_hpcdwriters0")], 'product_id':ref("stock.product_product_hpcdwriters0"), 'active_id': ref("stock.product_product_hpcdwriters0")}) +- + I create change location. +- + !python {model: stock.location }: | + to=self.browse(cr,uid,ref('stock.stock_location_stock')) + form=self.browse(cr,uid,ref('stock.stock_location_locations')) + self.picking_type_get(cr, uid, to, form) +- + I create change product standard price for product HP CD writers. +- + !record {model: stock.change.standard.price, id: stock_change_standard_price0}: + new_price: 15 + stock_account_input: account_account_receivable0 + stock_account_output: account_account_payable0 + stock_journal: account_journal_purchasejournal0 + enable_stock_in_out_acc: True +- + I apply the new product standard price on product HP CD writers. +- + !python {model: stock.change.standard.price }: | + self.change_price(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model": + "product.product", "active_ids": [ref("stock.product_product_hpcdwriters0")], "tz": False, "active_id":ref('stock.product_product_hpcdwriters0')}) - I create Physical Inventory for the products. - @@ -241,14 +282,62 @@ product_uom: product.product_uom_unit name: Physical inventory state: draft - - +- + I create merge Inventory for the products. +- + !record {model: stock.inventory, id: stock_inventory_mergeinventoy0}: + company_id: base.main_company + date: !eval time.strftime('%Y-%m-%d %H:%M:%S') + date_done: !eval time.strftime('%Y-%m-%d %H:%M:%S') + inventory_line_id: + - company_id: base.main_company + location_id: stock.stock_location_stock + product_id: stock.product_product_hpcdwriters0 + product_qty: 20.0 + product_uom: product.product_uom_unit + - company_id: base.main_company + location_id: stock.stock_location_stock + product_id: stock.product_product_hppaviliondesktoppcs0 + product_qty: 20.0 + product_uom: product.product_uom_unit + name: Physical inventory + state: draft +- + I merge inventory . +- + !python {model: stock.inventory.merge}: | + self.do_merge(cr, uid, [ref("stock_inventory_mergeinventoy0")], {"lang": 'en_US', + "full": "1", "tz": False, "active_model": "stock.inventory", "active_ids": + [ref("stock_inventory_physicalinventoy0"), ref("stock_inventory_mergeinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0"), }) - I confirm the Inventory for HP CD writers. - !python {model: stock.inventory}: | self.action_confirm(cr,uid,[ref('stock_inventory_physicalinventoy0')]) self.action_done(cr,uid,[ref('stock_inventory_physicalinventoy0')]) +- + I create stock.inventory.line.split record. +- + !record {model: stock.inventory.line.split, id: stock_inventory_line_0}: + line_ids: + - name: '00002-stock-test' + quantity: 5 + use_exist: False + product_id: stock.product_product_hpcdwriters0 + product_uom: product.product_uom_unit + use_exist: False + qty: 10 +- + I Split stock.inventory.line into production line. +- + !python {model: stock.inventory.line.split}: | + move_obj=self.pool.get('stock.inventory.line') + product_obj=self.pool.get('product.product') + product_id=product_obj.search(cr,uid,[('name','=','HP CD writers')]) + move_ids=move_obj.search(cr,uid,[('product_id','in',product_id)]) + self.split_lot(cr, uid, [ref("stock_inventory_line_0")], {"lang": 'en_US', "active_model": + "stock.inventory.line", "active_ids": move_ids, "tz": False, "active_id":move_ids[0] + }) - I create stock.fill.inventory . - @@ -284,7 +373,6 @@ "stock.move", "active_ids": move_ids, "tz": False, "active_id":move_ids[0] }) - - In Order to test the picking I create picking with move lines. - !record {model: stock.picking, id: stock_picking_0}: @@ -307,7 +395,22 @@ move_type: direct type: internal - +- + I create stock split.into quantity record. +- + !record {model: stock.split.into, id: stock_split_into0}: + quantity: 1 +- + I apply the split quantity. +- + !python {model: stock.split.into}: | + move_obj=self.pool.get('stock.move') + product_obj=self.pool.get('product.product') + product_id=product_obj.search(cr,uid,[('name','=','HP CD writers')]) + move_ids=move_obj.search(cr,uid,[('product_id','in',product_id)]) + self.split(cr, uid, [ref("stock_split_into0")], {"lang": 'en_US', "active_model": + "stock.move", "active_ids": move_ids, "tz": False, "active_id":move_ids[0] + }) - I click on draft_force_assign on picking. - @@ -345,3 +448,4 @@ 'product_uom': move.product_uom.id, } self.do_partial(cr, uid, [ref('stock_picking_0')],partial_datas) + diff --git a/addons/stock/test/stock_test_wizard.yml b/addons/stock/test/stock_test_wizard.yml new file mode 100644 index 00000000000..c7e870a8d7d --- /dev/null +++ b/addons/stock/test/stock_test_wizard.yml @@ -0,0 +1,120 @@ + +- + In order to test picking i created picking record with move lines +- + !record {model: stock.picking, id: stock_picking_in0}: + address_id: base.main_address + company_id: base.main_company + invoice_state: 2binvoiced + move_lines: + - location_dest_id: stock.stock_location_shop0 + product_id: product.product_product_pc1 + product_qty: 30.0 + product_uom: product.product_uom_unit + date_expected : '2011-01-05 12:58:07' + location_id : stock.stock_location_suppliers + name : '[PC1] Basic PC' + product_uos_qty : 30.0 + name: IN/00010 + type: in + +- + I performed an osv_memory action draft_validate on module stock.picking +- + !python {model: stock.picking}: | + self.draft_validate(cr, uid, [ref("stock_picking_in0")], {"lang": "en_US", "search_default_available": + 1, "tz": False, "active_model": "ir.ui.menu", "section_id": False, "contact_display": + "partner_address", "active_ids": [ref("stock.menu_action_picking_tree4")], + "active_id": ref("stock.menu_action_picking_tree4"), }) + +- + I confirm the picking. +- + + !python {model: stock.picking }: | + import time + pick=self.browse(cr,uid,ref('stock_picking_in0')) + partial_datas={} + for move in pick.move_lines: + partial_datas['move%s'%(move.id)]= { + 'product_id': move.product_id, + 'product_qty': move.product_qty, + } + self.do_partial(cr, uid, [pick.id],partial_datas) +- + I Performing an osv_memory action create_invoice on module stock.invoice.onshipping +- + !python {model: stock.invoice.onshipping}: | + pick=self.browse(cr,uid,ref('stock_picking_in0')) + invoice_line_id = self.pool.get('stock.invoice.onshipping').create(cr, uid,{}, {"lang": 'en_US', "active_model": + "stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id}) + self.open_invoice(cr, uid, [invoice_line_id], {"lang": "en_US", + "search_default_available": 1, "inv_type": "in_invoice" , "tz": False, "active_model": "stock.picking", + "contact_display": "partner_address", "active_ids": [ref("stock_picking_in0")], + "active_id": ref("stock_picking_in0"), }) +- + I Performed an osv_memory action move_scrap and consume move on module stock.move.scrap +- + + !python {model: stock.picking }: | + import time + location_obj = self.pool.get('stock.location') + scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)]) + pick=self.browse(cr,uid,ref('stock_picking_in0')) + scrap_obj=self.pool.get('stock.move.scrap') + consume_obj=self.pool.get('stock.move.consume') + partial_datas={} + move=pick.move_lines[0] + partial_datas= { + 'product_id': move.product_id.id, + 'location_id': scrpaed_location_ids[0], + 'product_qty': move.product_qty, + 'product_uom': move.product_uom.id, + } + scrap_id = self.pool.get('stock.move.scrap').create(cr, uid, partial_datas) + scrap_obj.move_scrap(cr, uid, [scrap_id], {"lang": "en_US", "tz": + False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id], + "active_id": move.id, }) + consume_id = self.pool.get('stock.move.consume').create(cr, uid, partial_datas) + consume_obj.do_move_consume(cr, uid, [consume_id], {"lang": "en_US", "tz": + False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id], + "active_id": move.id, }) +- + I return the picking. +- + + !python {model: stock.picking }: | + import time + pick=self.browse(cr,uid,ref('stock_picking_in0')) + partial_datas={} + partial_pick_id = self.pool.get('stock.return.picking').create(cr, uid,{}, {"lang": 'en_US', "active_model": + "stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id}) + for move in pick.move_lines: + partial_datas= { + 'product_id': move.product_id.id, + 'quantity': move.product_qty, + } + self.pool.get('stock.return.picking').create_returns(cr, uid, [partial_pick_id], {"lang": 'en_US', "active_model": + "stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id}) + +- + I create stock.move record. +- + + !python {model: stock.move }: | + import time + pick_obj = self.pool.get('stock.picking') + pick=pick_obj.browse(cr,uid,ref('stock_picking_in0')) + partial_move_id = self.pool.get('stock.partial.move').create(cr, uid,{}) + search_id = self.search(cr, uid, [('picking_id', '=', pick.id)]) + partial_datas={} + for move in pick.move_lines: + partial_datas['move%s'%(move.id)]= { + 'quantity': move.product_qty, + 'product_uom': move.product_uom.id, + 'prodlot_id': move.prodlot_id and move.prodlot_id.id or False, + 'wizard_id': partial_move_id, + } + self.do_partial(cr, uid, [partial_move_id],partial_datas,{"lang": 'en_US', "active_model": + "stock.move", 'search_default_receive': 1, 'product_receive': True, "active_ids": search_id, "tz": False, "active_id":search_id[0]}) + \ No newline at end of file diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py index b903f020f82..b0b091be07a 100644 --- a/addons/stock/wizard/__init__.py +++ b/addons/stock/wizard/__init__.py @@ -25,7 +25,6 @@ import stock_splitinto import stock_partial_picking import stock_partial_move import stock_replacement -import stock_ups import stock_inventory_merge import stock_fill_inventory import stock_inventory_line_split diff --git a/addons/stock/wizard/stock_ups.py b/addons/stock/wizard/stock_ups.py deleted file mode 100644 index fb47587f254..00000000000 --- a/addons/stock/wizard/stock_ups.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import netsvc -from osv import fields, osv -from tools.translate import _ - -class stock_ups(osv.osv_memory): - _name = "stock.ups" - _description = "Stock ups" - - def ups_save(self, cr, uid, ids, context=None): - return { - 'name': False, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.ups.final', - 'type': 'ir.actions.act_window', - 'target':'new', - } - - def ups_upload(self, cr, uid, ids, context=None): - return { - 'name': False, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.ups.upload', - 'type': 'ir.actions.act_window', - 'target':'new', - } - - _columns = { - 'weight': fields.float('Lot weight', required=True), - } - - _defaults = { - 'weight': lambda *a: 3.0, - } -stock_ups() - -class stock_ups_final(osv.osv_memory): - _name = "stock.ups.final" - _description = "Stock ups final" - - def create_xmlfile(self, cr, uid, ids, context=None): - """ Creates xml report file. - @return: xml file - """ - data={} - report = netsvc._group['report']['report.stock.move.lot.ups_xml'] - data['report_type'] = 'raw' - return {'xmlfile' : report.create(uid, context['active_id'], ids, {})} - - _columns = { - 'xmlfile': fields.binary('XML File'), - } - -stock_ups_final() - -class stock_ups_upload(osv.osv_memory): - _name = "stock.ups.upload" - _description = "Stock ups upload" - - def upload_xmlfile(self, cr, uid, ids, context=None): - """ Uploads xml report file. - @return: - """ - data={} - report = netsvc._group['report']['report.stock.move.lot.ups_xml'] - data['report_type'] = 'raw' - fp = file('/tmp/test.xml', 'w').write(report.create(uid, context['active_id'], ids, {})) - return {'type': 'ir.actions.act_window_close'} - -stock_ups_upload() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/wizard/stock_ups_view.xml b/addons/stock/wizard/stock_ups_view.xml deleted file mode 100644 index cbce721e1b9..00000000000 --- a/addons/stock/wizard/stock_ups_view.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - Stock ups - stock.ups - form - -
- - - -