From e4a21fbd7b1e2a1f5343f89ccdbd186aa1bb8bb1 Mon Sep 17 00:00:00 2001 From: "Ferdinand,mtr(OpenERP)" <> Date: Thu, 16 Jun 2011 15:00:21 +0530 Subject: [PATCH 001/374] [FIX] account: calculates the correct level lp bug: https://launchpad.net/bugs/783670 fixed bzr revid: mtr@mtr-20110616093021-n7ihs56l7v08ntwq --- addons/account/account.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index f6dd36c01fc..b3b6016fc74 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -340,9 +340,11 @@ class account_account(osv.osv): accounts = self.browse(cr, uid, ids, context=context) for account in accounts: level = 0 - if account.parent_id: - obj = self.browse(cr, uid, account.parent_id.id) - level = obj.level + 1 + parent_id = account.parent_id + while parent_id: + obj = self.browse(cr, uid, parent_id.id) + level += 1 + parent_id = obj.parent_id res[account.id] = level return res @@ -390,7 +392,10 @@ class account_account(osv.osv): 'manage this. So if you import from another software system you may have to use the rate at date. ' \ 'Incoming transactions always use the rate at date.', \ required=True), - 'level': fields.function(_get_level, string='Level', method=True, store=True, type='integer'), + 'level': fields.function(_get_level, string='Level', method=True, type='integer', + store={ + 'account.account': (lambda self, cr, uid, ids, c={}: ids, ['parent_id'], 10), + }), } _defaults = { From 594e01f1064dafa63d2b77433aa0d782c1abef4c Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Wed, 22 Jun 2011 11:25:58 +0530 Subject: [PATCH 002/374] [FIX] sale: Fixed problem of unselect/make empty packaging field in the sale order line. lp bug: https://launchpad.net/bugs/795487 fixed bzr revid: uco@tinyerp.com-20110622055558-sk5lidkpklygqws5 --- addons/sale/sale.py | 9 ++++++--- addons/sale/sale_view.xml | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 0b436f0dc91..431e0a3d63a 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1013,9 +1013,11 @@ class sale_order_line(osv.osv): def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, - lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): + lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sales form !\nPlease set one customer before choosing a product.')) + if not context: + context = {} warning = {} warning_msgs = '' product_uom_obj = self.pool.get('product.uom') @@ -1023,7 +1025,7 @@ class sale_order_line(osv.osv): product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang - context = {'lang': lang, 'partner_id': partner_id} + context.update({'lang': lang, 'partner_id': partner_id}) if not product: return {'value': {'th_weight': 0, 'product_packaging': False, @@ -1034,7 +1036,8 @@ class sale_order_line(osv.osv): result = {} product_obj = product_obj.browse(cr, uid, product, context=context) - if not packaging and product_obj.packaging: + from_packaging = context.get('from_packaging', False) + if not packaging and product_obj.packaging and not from_packaging: packaging = product_obj.packaging[0].id result['product_packaging'] = packaging diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 6c444ad174d..efaca80c221 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -142,7 +142,7 @@ From e8ed589a8786193e6e8eac6ccc527505cd87ee5c Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Wed, 22 Jun 2011 15:14:13 +0530 Subject: [PATCH 003/374] [FIX] sale: Fixed problem of on change product when product does not have package. bzr revid: uco@tinyerp.com-20110622094413-ijesue23tagbju0r --- addons/sale/sale.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 431e0a3d63a..9e4675bfe05 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1040,6 +1040,9 @@ class sale_order_line(osv.osv): if not packaging and product_obj.packaging and not from_packaging: packaging = product_obj.packaging[0].id result['product_packaging'] = packaging + elif not product_obj.packaging: + packaging = False + result['product_packaging'] = False if packaging: default_uom = product_obj.uom_id and product_obj.uom_id.id From 2f5ada053acc9bf83c77b9a369f46a4eb8889e1a Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 24 Jun 2011 15:09:06 +0530 Subject: [PATCH 004/374] [FIX] sale, sale_layout: Added onchange method on product packaging field. bzr revid: uco@tinyerp.com-20110624093906-2oonk5dge6f2ond7 --- addons/sale/sale.py | 76 +++++++++++++++---------- addons/sale/sale_view.xml | 2 +- addons/sale_layout/sale_layout_view.xml | 2 +- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 9e4675bfe05..e5afac4d87e 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1010,43 +1010,26 @@ class sale_order_line(osv.osv): default = {} default.update({'state': 'draft', 'move_ids': [], 'invoiced': False, 'invoice_lines': []}) return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context) - - def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, - uom=False, qty_uos=0, uos=False, name='', partner_id=False, - lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None): - if not partner_id: - raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sales form !\nPlease set one customer before choosing a product.')) - if not context: - context = {} - warning = {} - warning_msgs = '' - product_uom_obj = self.pool.get('product.uom') - partner_obj = self.pool.get('res.partner') + + def onchange_product_packaging(self, cr, uid, ids, pricelist, product, qty, uom, packaging, flag): product_obj = self.pool.get('product.product') - if partner_id: - lang = partner_obj.browse(cr, uid, partner_id).lang - context.update({'lang': lang, 'partner_id': partner_id}) - - if not product: - return {'value': {'th_weight': 0, 'product_packaging': False, - 'product_uos_qty': qty}, 'domain': {'product_uom': [], - 'product_uos': []}} - if not date_order: - date_order = time.strftime('%Y-%m-%d') - + product_uom_obj = self.pool.get('product.uom') + warning = {} result = {} - product_obj = product_obj.browse(cr, uid, product, context=context) - from_packaging = context.get('from_packaging', False) - if not packaging and product_obj.packaging and not from_packaging: - packaging = product_obj.packaging[0].id + warning_msgs = '' + if not product: + return {'value': {'product_packaging': False}} + products = product_obj.browse(cr, uid, product) + if not packaging and products.packaging and not flag: + packaging = products.packaging[0].id result['product_packaging'] = packaging - elif not product_obj.packaging: + elif not products.packaging: packaging = False result['product_packaging'] = False if packaging: - default_uom = product_obj.uom_id and product_obj.uom_id.id - pack = self.pool.get('product.packaging').browse(cr, uid, packaging, context=context) + default_uom = products.uom_id and products.uom_id.id + pack = self.pool.get('product.packaging').browse(cr, uid, packaging) q = product_uom_obj._compute_qty(cr, uid, uom, pack.qty, default_uom) # qty = qty - qty % q + q if qty and (q and not (qty % q) == 0): @@ -1061,6 +1044,39 @@ class sale_order_line(osv.osv): warning_msgs += _("Picking Information ! : ") + warn_msg + "\n\n" result['product_uom_qty'] = qty + if warning_msgs: + warning = { + 'title': _('Configuration Error !'), + 'message' : warning_msgs + } + + return {'value': result, 'warning': warning} + + def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, + uom=False, qty_uos=0, uos=False, name='', partner_id=False, + lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): + if not partner_id: + raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sales form !\nPlease set one customer before choosing a product.')) + warning_msgs = '' + product_uom_obj = self.pool.get('product.uom') + partner_obj = self.pool.get('res.partner') + product_obj = self.pool.get('product.product') + if partner_id: + lang = partner_obj.browse(cr, uid, partner_id).lang + context = {'lang': lang, 'partner_id': partner_id} + + if not product: + return {'value': {'th_weight': 0, 'product_packaging': False, + 'product_uos_qty': qty}, 'domain': {'product_uom': [], + 'product_uos': []}} + if not date_order: + date_order = time.strftime('%Y-%m-%d') + + res = self.onchange_product_packaging(cr, uid, ids, pricelist, product, qty, uom, packaging, False) + result = res.get('value', {}) + warning = res.get('warning', {}) + product_obj = product_obj.browse(cr, uid, product, context=context) + uom2 = False if uom: uom2 = product_uom_obj.browse(cr, uid, uom) diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index efaca80c221..0b17b5ca71c 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -142,7 +142,7 @@ diff --git a/addons/sale_layout/sale_layout_view.xml b/addons/sale_layout/sale_layout_view.xml index 6dee4ddd62f..25c56a03ae6 100644 --- a/addons/sale_layout/sale_layout_view.xml +++ b/addons/sale_layout/sale_layout_view.xml @@ -38,7 +38,7 @@ name="product_packaging" attrs="{'readonly':[('layout_type','!=','article')]}" context="{'partner_id':parent.partner_id,'quantity':product_uom_qty,'pricelist':parent.pricelist_id,'shop':parent.shop_id,'uom':product_uom}" - on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging, parent.fiscal_position)" + on_change="onchange_product_packaging(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_packaging, True)" domain="[('product_id','=',product_id)]" groups="base.group_extended"/> From 4aa687cf3fad299a4cc6098f7fc12f35c36d5338 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 29 Jun 2011 10:48:00 +0530 Subject: [PATCH 005/374] [FIX]purchase,procurement:Fixed=>Generate Sale order via Non admin User Po generated with wrong warehouse and company ,For information Traceback Generated after run the ORDERPOINT it is a sequence problem and it has been fixed in lp:787052 : lp bug: https://launchpad.net/bugs/802322 fixed bzr revid: ron@tinyerp.com-20110629051800-u71iztvvtbgsyzuq --- addons/procurement/schedulers.py | 1 + addons/purchase/purchase.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 3a6e3336472..d2787185c18 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -183,6 +183,7 @@ class procurement_order(osv.osv): 'product_qty': -product.virtual_available, 'product_uom': product.uom_id.id, 'location_id': location_id, + 'company_id': warehouse.company_id.id, 'procure_method': 'make_to_order', }) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6f6ab0c1b44..8867cb7f3a7 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -775,6 +775,8 @@ class procurement_order(osv.osv): prod_obj = self.pool.get('product.product') acc_pos_obj = self.pool.get('account.fiscal.position') po_obj = self.pool.get('purchase.order') + wharehouse_obj = self.pool.get('stock.warehouse') + for procurement in self.browse(cr, uid, ids, context=context): res_id = procurement.move_id.id partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement. @@ -821,6 +823,8 @@ class procurement_order(osv.osv): 'partner_id': partner_id, 'partner_address_id': address_id, 'location_id': procurement.location_id.id, + 'warehouse_id': wharehouse_obj.search(cr, uid, [('company_id','=',procurement.company_id.id or company)])[0], + 'company_id': procurement.company_id.id or company, 'pricelist_id': pricelist_id, 'order_line': [(0,0,line)], 'company_id': procurement.company_id.id, From 6c27f121fb6621d0964a163ae6a62b1b363a9c8f Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 29 Jun 2011 18:55:39 +0530 Subject: [PATCH 006/374] [IMP]purchase:fixed=>Traceback Generated after run the ORDERPOINT bzr revid: ron@tinyerp.com-20110629132539-9y8zxts1v39olmrt --- 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 8867cb7f3a7..e06a5ef988c 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -776,7 +776,6 @@ class procurement_order(osv.osv): acc_pos_obj = self.pool.get('account.fiscal.position') po_obj = self.pool.get('purchase.order') wharehouse_obj = self.pool.get('stock.warehouse') - for procurement in self.browse(cr, uid, ids, context=context): res_id = procurement.move_id.id partner = procurement.product_id.seller_id # Taken Main Supplier of Product of Procurement. @@ -819,6 +818,7 @@ class procurement_order(osv.osv): 'taxes_id': [(6,0,taxes)] }) purchase_id = po_obj.create(cr, uid, { + 'name': self.pool.get('ir.sequence').get(cr, uid, 'purchase.order') or _('PO:%s') %procurement.name, 'origin': procurement.origin, 'partner_id': partner_id, 'partner_address_id': address_id, From f059576ba8c7bc2ca8e8f15b96b1438b502f67b7 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Tue, 5 Jul 2011 11:47:50 +0530 Subject: [PATCH 007/374] [IMP]procurment:Fixed=>changed the all select queries which bypassed the record rules in procurment.py and schedular.py,and change the output location configuaration with company_id=False because of that it will be access by child company bzr revid: ron@tinyerp.com-20110705061750-7g73nancsfijk0re --- addons/procurement/procurement.py | 4 ++-- addons/procurement/schedulers.py | 12 +++--------- addons/purchase/purchase.py | 1 - addons/stock/stock_data.xml | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 743ef85a9ea..f4988afedc0 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -371,8 +371,8 @@ class procurement_order(osv.osv): id = procurement.move_id.id if not (procurement.move_id.state in ('done','assigned','cancel')): ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id]) - cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,)) - res = cr.fetchone()[0] + order_point_id = self.pool.get('stock.warehouse.orderpoint').search(cr, uid, [('product_id', '=', procurement.product_id.id)]) + res = len(order_point_id) if not res and not ok: message = _("Not enough stock and no minimum orderpoint rule defined.") elif not res: diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index d2787185c18..33abeab34af 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -67,8 +67,7 @@ class procurement_order(osv.osv): report_except = 0 report_later = 0 while True: - cr.execute("select id from procurement_order where state='confirmed' and procure_method='make_to_order' order by priority,date_planned limit 500 offset %s", (offset,)) - ids = map(lambda x: x[0], cr.fetchall()) + ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_order')], order='priority,date_planned') for proc in procurement_obj.browse(cr, uid, ids, context=context): if maxdate >= proc.date_planned: wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) @@ -156,11 +155,7 @@ class procurement_order(osv.osv): wf_service = netsvc.LocalService("workflow") warehouse_ids = warehouse_obj.search(cr, uid, [], context=context) - - cr.execute('select p.id from product_product p \ - join product_template t on (p.product_tmpl_id=t.id) \ - where p.active=True and t.purchase_ok=True') - products_id = [x for x, in cr.fetchall()] + products_id = product_obj.search(cr, uid, [('active', '=', True), ('purchase_ok', '=', True)], order='id') for warehouse in warehouse_obj.browse(cr, uid, warehouse_ids, context=context): context['warehouse'] = warehouse @@ -242,8 +237,7 @@ class procurement_order(osv.osv): if op.procurement_draft_ids: # Check draft procurement related to this order point pro_ids = [x.id for x in op.procurement_draft_ids] - cr.execute('select id, product_qty from procurement_order where id in %s order by product_qty desc', (tuple(pro_ids), )) - procure_datas = cr.dictfetchall() + procure_datas = procurement_obj.read(cr, uid, pro_ids, ['id','product_qty'], context=context) to_generate = qty for proc_data in procure_datas: if to_generate >= proc_data['product_qty']: diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index e06a5ef988c..137e8125c06 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -824,7 +824,6 @@ class procurement_order(osv.osv): 'partner_address_id': address_id, 'location_id': procurement.location_id.id, 'warehouse_id': wharehouse_obj.search(cr, uid, [('company_id','=',procurement.company_id.id or company)])[0], - 'company_id': procurement.company_id.id or company, 'pricelist_id': pricelist_id, 'order_line': [(0,0,line)], 'company_id': procurement.company_id.id, diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index bcde818c78a..3c75615dfae 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -91,8 +91,8 @@ Output - internal + customer transparent out From ef278ffae6da5a72eabe6ea026a2cc8c3ae97561 Mon Sep 17 00:00:00 2001 From: mtr Date: Tue, 5 Jul 2011 17:56:39 +0530 Subject: [PATCH 008/374] [IMP] account: improved store dictionary of function field 'level' bzr revid: mtr@mtr-20110705122639-nq3yqkebakr4vig7 --- addons/account/account.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index b3b6016fc74..24b04ea6ae7 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -332,9 +332,9 @@ class account_account(osv.osv): for acc in record.child_consol_ids: if acc.id not in result[record.id]: result[record.id].append(acc.id) - + return result - + def _get_level(self, cr, uid, ids, field_name, arg, context=None): res = {} accounts = self.browse(cr, uid, ids, context=context) @@ -344,7 +344,7 @@ class account_account(osv.osv): while parent_id: obj = self.browse(cr, uid, parent_id.id) level += 1 - parent_id = obj.parent_id + parent_id = obj.parent_id res[account.id] = level return res @@ -394,7 +394,7 @@ class account_account(osv.osv): required=True), 'level': fields.function(_get_level, string='Level', method=True, type='integer', store={ - 'account.account': (lambda self, cr, uid, ids, c={}: ids, ['parent_id'], 10), + 'account.account': (_get_children_and_consol, [], 10), }), } From 14daa261888a6ee92db0bbd24fefee9a6a15270c Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Tue, 5 Jul 2011 18:41:02 +0530 Subject: [PATCH 009/374] [REF] sale: Refactored the code, optimization and fixed according to coding standards. bzr revid: uco@tinyerp.com-20110705131102-0r9etxoro001iem4 --- addons/sale/sale.py | 55 ++++++++++++++----------- addons/sale/sale_view.xml | 2 +- addons/sale_layout/sale_layout_view.xml | 2 +- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 398ad00b467..85e507bddd3 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1011,53 +1011,60 @@ class sale_order_line(osv.osv): default.update({'state': 'draft', 'move_ids': [], 'invoiced': False, 'invoice_lines': []}) return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context) - def onchange_product_packaging(self, cr, uid, ids, pricelist, product, qty, uom, packaging, flag): + def product_packaging_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, + partner_id=False, packaging=False, flag=False, context=None): product_obj = self.pool.get('product.product') product_uom_obj = self.pool.get('product.uom') + pack_obj = self.pool.get('product.packaging') warning = {} result = {} warning_msgs = '' if not product: return {'value': {'product_packaging': False}} - products = product_obj.browse(cr, uid, product) - if not packaging and products.packaging and not flag: + + if flag: + res = self.product_id_change(cr, uid, ids, pricelist=pricelist, + product=product, qty=qty, uom=uom, partner_id=partner_id, + packaging=packaging, flag=False) + warning_msgs = res.get('warning') and res['warning']['message'] + + products = product_obj.browse(cr, uid, product, context=context) + if not products.packaging: + packaging = result['product_packaging'] = False + elif not packaging and products.packaging and not flag: packaging = products.packaging[0].id result['product_packaging'] = packaging - elif not products.packaging: - packaging = False - result['product_packaging'] = False - + if packaging: default_uom = products.uom_id and products.uom_id.id - pack = self.pool.get('product.packaging').browse(cr, uid, packaging) + pack = pack_obj.browse(cr, uid, packaging, context=context) q = product_uom_obj._compute_qty(cr, uid, uom, pack.qty, default_uom) # qty = qty - qty % q + q if qty and (q and not (qty % q) == 0): ean = pack.ean or _('(n/a)') qty_pack = pack.qty type_ul = pack.ul - warn_msg = _("You selected a quantity of %d Units.\n" - "But it's not compatible with the selected packaging.\n" - "Here is a proposition of quantities according to the packaging:\n" - "EAN: %s Quantity: %s Type of ul: %s") % \ - (qty, ean, qty_pack, type_ul.name) - warning_msgs += _("Picking Information ! : ") + warn_msg + "\n\n" - result['product_uom_qty'] = qty - - if warning_msgs: - warning = { + if not warning_msgs: + warn_msg = _("You selected a quantity of %d Units.\n" + "But it's not compatible with the selected packaging.\n" + "Here is a proposition of quantities according to the packaging:\n" + "EAN: %s Quantity: %s Type of ul: %s") % \ + (qty, ean, qty_pack, type_ul.name) + warning_msgs += _("Picking Information ! : ") + warn_msg + "\n\n" + warning = { 'title': _('Configuration Error !'), - 'message' : warning_msgs - } + 'message': warning_msgs + } + result['product_uom_qty'] = qty return {'value': result, 'warning': warning} def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): - if not partner_id: + if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sales form !\nPlease set one customer before choosing a product.')) - warning_msgs = '' + warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') @@ -1072,9 +1079,9 @@ class sale_order_line(osv.osv): if not date_order: date_order = time.strftime('%Y-%m-%d') - res = self.onchange_product_packaging(cr, uid, ids, pricelist, product, qty, uom, packaging, False) + res = self.product_packaging_change(cr, uid, ids, pricelist, product, qty, uom, partner_id, packaging) result = res.get('value', {}) - warning = res.get('warning', {}) + warning_msgs = res.get('warning') and res['warning']['message'] or '' product_obj = product_obj.browse(cr, uid, product, context=context) uom2 = False diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 0b17b5ca71c..34e7dc292bc 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -142,7 +142,7 @@ diff --git a/addons/sale_layout/sale_layout_view.xml b/addons/sale_layout/sale_layout_view.xml index 25c56a03ae6..12d07432861 100644 --- a/addons/sale_layout/sale_layout_view.xml +++ b/addons/sale_layout/sale_layout_view.xml @@ -38,7 +38,7 @@ name="product_packaging" attrs="{'readonly':[('layout_type','!=','article')]}" context="{'partner_id':parent.partner_id,'quantity':product_uom_qty,'pricelist':parent.pricelist_id,'shop':parent.shop_id,'uom':product_uom}" - on_change="onchange_product_packaging(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_packaging, True)" + on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True)" domain="[('product_id','=',product_id)]" groups="base.group_extended"/> From 8bdaefd12e5d6e7f774662cdfeb756d822f0f27b Mon Sep 17 00:00:00 2001 From: Date: Wed, 6 Jul 2011 09:47:31 +0200 Subject: [PATCH 010/374] [IMP] hr_timesheet_sheet: sign-in and sign-out buttons on the sheet use the same attendances wizard which asks for the last sign-in/sign-out if it is missing instead of raising an error bzr revid: guewen.baconnier@camptocamp.com-20110706074731-8v14k99lcgmipm4y --- .../hr_timesheet_sheet/hr_timesheet_sheet.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index cf4351112a4..0cc0fbc11f7 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -245,23 +245,29 @@ class hr_timesheet_sheet(osv.osv): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context) return True - def sign(self, cr, uid, ids, typ, context=None): - emp_obj = self.pool.get('hr.employee') + def check_sign(self, cr, uid, ids, typ, context=None): sheet = self.browse(cr, uid, ids, context=context)[0] - if context is None: - context = {} if not sheet.date_current == time.strftime('%Y-%m-%d'): raise osv.except_osv(_('Error !'), _('You cannot sign in/sign out from an other date than today')) - emp_id = sheet.employee_id.id - context['sheet_id']=ids[0] - emp_obj.attendance_action_change(cr, uid, [emp_id], type=typ, context=context,) return True + def sign(self, cr, uid, ids, typ, context=None): + self.check_sign(cr, uid, ids, typ, context=context) + sign_obj = self.pool.get('hr.sign.in.out') + sign_id = sign_obj.create(cr, uid, {}, context=context) + methods = {'sign_in': sign_obj.si_check, + 'sign_out': sign_obj.so_check} + wizard_result = methods[typ](cr, uid, [sign_id], context=context) + if wizard_result.get('type', False) == 'ir.actions.act_window_close': + return True # ensure we do not close the main window ! + wizard_result['nodestroy'] = True # do not destroy the main window ! + return wizard_result + def sign_in(self, cr, uid, ids, context=None): - return self.sign(cr,uid,ids,'sign_in',context=None) + return self.sign(cr, uid, ids, 'sign_in', context=context) def sign_out(self, cr, uid, ids, context=None): - return self.sign(cr,uid,ids,'sign_out',context=None) + return self.sign(cr, uid, ids, 'sign_out', context=context) _columns = { 'name': fields.char('Description', size=64, select=1, From 867aa1a56f113da5748a0b44d0dff0a94cefc66b Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 6 Jul 2011 14:59:17 +0530 Subject: [PATCH 011/374] [IMP] sale: onchange package minor improvement bzr revid: mra@mra-laptop-20110706092917-44yznbfqyeklrzdn --- addons/sale/sale.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 85e507bddd3..057ed530218 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1010,31 +1010,30 @@ class sale_order_line(osv.osv): default = {} default.update({'state': 'draft', 'move_ids': [], 'invoiced': False, 'invoice_lines': []}) return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context) - - def product_packaging_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, + + def product_packaging_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, partner_id=False, packaging=False, flag=False, context=None): + if not product: + return {'value': {'product_packaging': False}} product_obj = self.pool.get('product.product') product_uom_obj = self.pool.get('product.uom') pack_obj = self.pool.get('product.packaging') warning = {} result = {} warning_msgs = '' - if not product: - return {'value': {'product_packaging': False}} - if flag: - res = self.product_id_change(cr, uid, ids, pricelist=pricelist, + res = self.product_id_change(cr, uid, ids, pricelist=pricelist, product=product, qty=qty, uom=uom, partner_id=partner_id, packaging=packaging, flag=False) warning_msgs = res.get('warning') and res['warning']['message'] - + products = product_obj.browse(cr, uid, product, context=context) if not products.packaging: packaging = result['product_packaging'] = False elif not packaging and products.packaging and not flag: packaging = products.packaging[0].id result['product_packaging'] = packaging - + if packaging: default_uom = products.uom_id and products.uom_id.id pack = pack_obj.browse(cr, uid, packaging, context=context) From b1dc5544d244fbfea6f535e49b30b0c717012665 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 6 Jul 2011 15:05:40 +0530 Subject: [PATCH 012/374] [IMP] sale: onchange package minor improvement bzr revid: mra@mra-laptop-20110706093540-ncsl94dqhd1n4c3m --- addons/sale/sale.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 057ed530218..555b83d4616 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -105,11 +105,11 @@ class sale_order(osv.osv): procurement_order mp on (mp.move_id=m.id) WHERE p.sale_id IN %s GROUP BY m.state, mp.state, p.sale_id, p.type''', (tuple(ids),)) - + for item in cr.dictfetchall(): if item['move_state'] == 'cancel': continue - + if item['picking_type'] == 'in':#this is a returned picking tmp[item['sale_order_id']]['total'] -= item['nbr'] or 0.0 # Deducting the return picking qty if item['procurement_state'] == 'done' or item['move_state'] == 'done': @@ -118,7 +118,7 @@ class sale_order(osv.osv): tmp[item['sale_order_id']]['total'] += item['nbr'] or 0.0 if item['procurement_state'] == 'done' or item['move_state'] == 'done': tmp[item['sale_order_id']]['picked'] += item['nbr'] or 0.0 - + for order in self.browse(cr, uid, ids, context=context): if order.shipped: res[order.id] = 100.0 @@ -710,7 +710,7 @@ class sale_order(osv.osv): 'note': line.notes, 'company_id': order.company_id.id, }) - + if line.product_id: proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name': line.name, @@ -1078,7 +1078,7 @@ class sale_order_line(osv.osv): if not date_order: date_order = time.strftime('%Y-%m-%d') - res = self.product_packaging_change(cr, uid, ids, pricelist, product, qty, uom, partner_id, packaging) + res = self.product_packaging_change(cr, uid, ids, pricelist, product, qty, uom, partner_id, packaging, context=context) result = res.get('value', {}) warning_msgs = res.get('warning') and res['warning']['message'] or '' product_obj = product_obj.browse(cr, uid, product, context=context) @@ -1147,7 +1147,7 @@ class sale_order_line(osv.osv): max(0,product_obj.qty_available), product_obj.uom_id.name) warning_msgs += _("Not enough stock ! : ") + warn_msg + "\n\n" # get unit price - + if not pricelist: warn_msg = _('You have to select a pricelist or a customer in the sales form !\n' 'Please set one before choosing a product.') @@ -1168,7 +1168,7 @@ class sale_order_line(osv.osv): if warning_msgs: warning = { 'title': _('Configuration Error !'), - 'message' : warning_msgs + 'message' : warning_msgs } return {'value': result, 'domain': domain, 'warning': warning} @@ -1211,7 +1211,7 @@ class sale_config_picking_policy(osv.osv_memory): ('picking', 'Invoice Based on Deliveries'), ], 'Shipping Default Policy', required=True, help="""The Shipping Policy is used to synchronise invoice and delivery operations. - - The "Invoice Based on Sales Orders" option will create the picking order directly and wait for the user to manually click on the 'Invoice' button to generate the draft invoice. + - The "Invoice Based on Sales Orders" option will create the picking order directly and wait for the user to manually click on the 'Invoice' button to generate the draft invoice. - The "Invoice Based on Deliveries" option is used to create an invoice during the picking process."""), 'step': fields.selection([ ('one', 'Delivery Order Only'), From 7044314fbc63e81d1716e2b428f6292b78052069 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Thu, 7 Jul 2011 14:16:02 +0530 Subject: [PATCH 013/374] [IMP] account: Improved reports to print translated terms correctly for filters. bzr revid: uco@tinyerp.com-20110707084602-vur1w0pnadrfgktt --- addons/account/report/account_balance.rml | 8 ++++---- addons/account/report/account_balance_sheet.rml | 8 ++++---- .../report/account_balance_sheet_horizontal.rml | 8 ++++---- addons/account/report/account_central_journal.rml | 8 ++++---- addons/account/report/account_general_journal.rml | 8 ++++---- addons/account/report/account_general_ledger.rml | 12 ++++++------ .../report/account_general_ledger_landscape.rml | 12 ++++++------ addons/account/report/account_journal.rml | 6 +++--- addons/account/report/account_partner_balance.rml | 8 ++++---- addons/account/report/account_partner_ledger.rml | 8 ++++---- .../account/report/account_partner_ledger_other.rml | 8 ++++---- addons/account/report/account_profit_horizontal.rml | 8 ++++---- addons/account/report/account_profit_loss.rml | 8 ++++---- 13 files changed, 55 insertions(+), 55 deletions(-) diff --git a/addons/account/report/account_balance.rml b/addons/account/report/account_balance.rml index 3d971862bdc..62eecf548b7 100644 --- a/addons/account/report/account_balance.rml +++ b/addons/account/report/account_balance.rml @@ -220,7 +220,7 @@ Display Account - Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Target Moves @@ -234,8 +234,8 @@ [[ get_fiscalyear(data) or '' ]] [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date @@ -253,7 +253,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period diff --git a/addons/account/report/account_balance_sheet.rml b/addons/account/report/account_balance_sheet.rml index 205bfff497b..d6acc0348f0 100644 --- a/addons/account/report/account_balance_sheet.rml +++ b/addons/account/report/account_balance_sheet.rml @@ -174,15 +174,15 @@ Chart of Account Fiscal Year - Filter By [[ get_filter(data)!='No Filter' and '' or removeParentNode('font') ]] + Filter By [[ data['form']['filter']!='filter_no' and '' or removeParentNode('font') ]] Display Account Target Moves [[ get_account(data) or removeParentNode('para') ]] [[ get_fiscalyear(data) or '' ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -192,7 +192,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period diff --git a/addons/account/report/account_balance_sheet_horizontal.rml b/addons/account/report/account_balance_sheet_horizontal.rml index 7e4f9f844a5..d34a0f053d8 100644 --- a/addons/account/report/account_balance_sheet_horizontal.rml +++ b/addons/account/report/account_balance_sheet_horizontal.rml @@ -134,15 +134,15 @@ Chart of Account Fiscal Year - Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Display Account Target Moves [[ get_account(data) or removeParentNode('para') ]] [[ get_fiscalyear(data) or '' ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -152,7 +152,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period diff --git a/addons/account/report/account_central_journal.rml b/addons/account/report/account_central_journal.rml index 33566083652..956e2e2b6a5 100644 --- a/addons/account/report/account_central_journal.rml +++ b/addons/account/report/account_central_journal.rml @@ -239,15 +239,15 @@ [[ data['model']=='ir.ui.menu' and 'Chart of Account' or removeParentNode('para') ]] Fiscal Year Journal - Filter By [[get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Target Moves [[ get_account(data) or removeParentNode('para') ]] [[ get_fiscalyear(data) or '' ]] [[o.journal_id.name ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -257,7 +257,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period diff --git a/addons/account/report/account_general_journal.rml b/addons/account/report/account_general_journal.rml index f4cc13069c8..5123d7ee19b 100644 --- a/addons/account/report/account_general_journal.rml +++ b/addons/account/report/account_general_journal.rml @@ -224,15 +224,15 @@ [[ data['model']=='ir.ui.menu' and 'Chart of Account' or removeParentNode('para') ]] Fiscal Year Journals - Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Target Moves [[ get_account(data) or removeParentNode('para') ]] [[ get_fiscalyear(data) or '' ]] [[', '.join([ lt or '' for lt in get_journal(data) ]) ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -242,7 +242,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period diff --git a/addons/account/report/account_general_ledger.rml b/addons/account/report/account_general_ledger.rml index 15614444822..14c4ce59371 100644 --- a/addons/account/report/account_general_ledger.rml +++ b/addons/account/report/account_general_ledger.rml @@ -353,7 +353,7 @@ Journal - Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filters By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Target Moves @@ -372,8 +372,8 @@ [[', '.join([ lt or '' for lt in get_journal(data) ]) ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date @@ -383,7 +383,7 @@ - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] [[ formatLang(get_start_date(data),date=True) ]] @@ -393,7 +393,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period @@ -403,7 +403,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] [[ get_start_period(data) or removeParentNode('para') ]] diff --git a/addons/account/report/account_general_ledger_landscape.rml b/addons/account/report/account_general_ledger_landscape.rml index ac100c3ecd0..fc2e482a3b1 100644 --- a/addons/account/report/account_general_ledger_landscape.rml +++ b/addons/account/report/account_general_ledger_landscape.rml @@ -373,7 +373,7 @@ Display Account - Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Entries Sorted By @@ -398,8 +398,8 @@ [[ (data['form']['display_account']=='all' and 'All') or (data['form']['display_account']=='movement' and 'With movements') or 'With balance is not equal to 0']] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date @@ -409,7 +409,7 @@ - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] [[ formatLang(get_start_date(data),date=True) ]] @@ -419,7 +419,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period @@ -429,7 +429,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] [[ get_start_period(data) or removeParentNode('para') ]] diff --git a/addons/account/report/account_journal.rml b/addons/account/report/account_journal.rml index 9b0ac55bb56..c5c22800cbd 100644 --- a/addons/account/report/account_journal.rml +++ b/addons/account/report/account_journal.rml @@ -197,8 +197,8 @@ [[ get_account(data) or '' ]] [[ get_fiscalyear(data) or '' ]] [[o.journal_id.name ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -208,7 +208,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period diff --git a/addons/account/report/account_partner_balance.rml b/addons/account/report/account_partner_balance.rml index 6425d6a4db6..f913a07df7a 100644 --- a/addons/account/report/account_partner_balance.rml +++ b/addons/account/report/account_partner_balance.rml @@ -187,7 +187,7 @@ Chart of Account Fiscal Year Journals - Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Partner's Target Moves @@ -196,8 +196,8 @@ [[ get_fiscalyear(data) or '' ]] [[', '.join([ lt or '' for lt in get_journal(data) ]) ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -207,7 +207,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period diff --git a/addons/account/report/account_partner_ledger.rml b/addons/account/report/account_partner_ledger.rml index c1ef9b22502..3af9c247d42 100644 --- a/addons/account/report/account_partner_ledger.rml +++ b/addons/account/report/account_partner_ledger.rml @@ -378,7 +378,7 @@ [[ data['form']['filter'] in ('filter_no','unreconciled') and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date @@ -388,7 +388,7 @@ - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] [[ formatLang(get_start_date(data),date=True) ]] @@ -398,7 +398,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period @@ -408,7 +408,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] [[ get_start_period(data) or removeParentNode('para') ]] diff --git a/addons/account/report/account_partner_ledger_other.rml b/addons/account/report/account_partner_ledger_other.rml index 2f58fc8ec95..1a19844c180 100644 --- a/addons/account/report/account_partner_ledger_other.rml +++ b/addons/account/report/account_partner_ledger_other.rml @@ -379,7 +379,7 @@ [[ data['form']['filter'] in ('filter_no','unreconciled') and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date @@ -389,7 +389,7 @@ - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] [[ formatLang(get_start_date(data),date=True) ]] @@ -399,7 +399,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period @@ -409,7 +409,7 @@ - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] [[ get_start_period(data) or removeParentNode('para') ]] diff --git a/addons/account/report/account_profit_horizontal.rml b/addons/account/report/account_profit_horizontal.rml index 6c70bb47310..ea03e8f3a9f 100644 --- a/addons/account/report/account_profit_horizontal.rml +++ b/addons/account/report/account_profit_horizontal.rml @@ -151,15 +151,15 @@ Chart of Account Fiscal Year - Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Display Account Target Moves [[ get_account(data) or removeParentNode('para') ]] [[ get_fiscalyear(data) or '' ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -169,7 +169,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period diff --git a/addons/account/report/account_profit_loss.rml b/addons/account/report/account_profit_loss.rml index 2b29f479478..e31da90e46e 100644 --- a/addons/account/report/account_profit_loss.rml +++ b/addons/account/report/account_profit_loss.rml @@ -174,15 +174,15 @@ Chart of Account Fiscal Year - Filter By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + Filter By [[ data['form']['filter']!='filter_no' and get_filter(data) ]] Display Account Target Moves [[ get_account(data) or removeParentNode('para') ]] [[ get_fiscalyear(data) or '' ]] - [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_no' and get_filter(data) or removeParentNode('para') ]] + [[ data['form']['filter']=='filter_date' or removeParentNode('blockTable') ]] Start Date End Date @@ -192,7 +192,7 @@ [[ formatLang(get_end_date(data),date=True) ]] - [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + [[ data['form']['filter']=='filter_period' or removeParentNode('blockTable') ]] Start Period End Period From 95a2d179308a2c9b5c86ec4bc8601434a880890e Mon Sep 17 00:00:00 2001 From: Date: Thu, 7 Jul 2011 14:27:59 +0200 Subject: [PATCH 014/374] [FIX] of last commit: allow to sign in / sign out on the sheet of an other employee bzr revid: guewen.baconnier@camptocamp.com-20110707122759-3919twq9v9sznuo4 --- .../wizard/hr_attendance_sign_in_out.py | 17 ++++++++++++++--- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py index 7a51c2b9e1e..89ca5148bbb 100644 --- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py +++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py @@ -33,14 +33,20 @@ class hr_si_so_ask(osv.osv_memory): } def _get_empname(self, cr, uid, context=None): - emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) + if context.get('emp_id', False): + emp_id = context['emp_id'] + else: + emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if emp_id: employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0].name return employee return '' def _get_empid(self, cr, uid, context=None): - emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) + if context.get('emp_id', False): + emp_id = context['emp_id'] + else: + emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if emp_id: return emp_id[0] return False @@ -72,7 +78,10 @@ class hr_sign_in_out(osv.osv_memory): } def _get_empid(self, cr, uid, context=None): - emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) + if context.get('emp_id', False): + emp_id = context['emp_id'] + else: + emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if emp_id: employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0] return {'name': employee.name, 'state': employee.state, 'emp_id': emp_id[0]} @@ -106,6 +115,7 @@ class hr_sign_in_out(osv.osv_memory): 'res_model': 'hr.sign.in.out.ask', 'views': [(resource_id,'form')], 'type': 'ir.actions.act_window', + 'context': context, 'target': 'new', } @@ -128,6 +138,7 @@ class hr_sign_in_out(osv.osv_memory): 'res_model': 'hr.sign.in.out', 'views': [(resource_id,'form')], 'type': 'ir.actions.act_window', + 'context': context, 'target': 'new', } diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 0cc0fbc11f7..7ba824814cf 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -254,6 +254,8 @@ class hr_timesheet_sheet(osv.osv): def sign(self, cr, uid, ids, typ, context=None): self.check_sign(cr, uid, ids, typ, context=context) sign_obj = self.pool.get('hr.sign.in.out') + sheet = self.browse(cr, uid, ids, context=context)[0] + context['emp_id'] = [sheet.employee_id.id] sign_id = sign_obj.create(cr, uid, {}, context=context) methods = {'sign_in': sign_obj.si_check, 'sign_out': sign_obj.so_check} From c1e2afebe8f3eea7f08dd39dfb1840f0bb867cef Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Fri, 8 Jul 2011 14:06:28 +0200 Subject: [PATCH 015/374] [FIX] cannot open from of task when project caldav is installed bzr revid: tfr@openerp.com-20110708120628-i6eyl0kdpkgt2ara --- addons/project_caldav/project_caldav.py | 2 +- addons/project_caldav/project_caldav_view.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/project_caldav/project_caldav.py b/addons/project_caldav/project_caldav.py index ada89d35e69..c0f780dfc57 100644 --- a/addons/project_caldav/project_caldav.py +++ b/addons/project_caldav/project_caldav.py @@ -42,11 +42,11 @@ class project_task(osv.osv): help='If the task is created the state is \'Draft\'.\n If the task is started, the state becomes \'In Progress\'.\n If review is needed the task is in \'Pending\' state.\ \n If the task is over, the states is set to \'Done\'.'), } + _defaults = { 'state': 'draft', } - def open_task(self, cr, uid, ids, context=None): """ Open Task Form for Project Task. diff --git a/addons/project_caldav/project_caldav_view.xml b/addons/project_caldav/project_caldav_view.xml index d27a4474fc9..f361dc9580b 100644 --- a/addons/project_caldav/project_caldav_view.xml +++ b/addons/project_caldav/project_caldav_view.xml @@ -66,8 +66,7 @@ - + From 461e41910255a1366270cd8e54d263b267c299de Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Fri, 8 Jul 2011 15:12:03 +0200 Subject: [PATCH 016/374] [FIX] event.todo don't erase project.task column anymore bzr revid: tfr@openerp.com-20110708131203-o9cduv00he161ahl --- addons/project_caldav/project_caldav.py | 2 +- addons/project_caldav/project_caldav_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/project_caldav/project_caldav.py b/addons/project_caldav/project_caldav.py index c0f780dfc57..f17ef3050d4 100644 --- a/addons/project_caldav/project_caldav.py +++ b/addons/project_caldav/project_caldav.py @@ -28,7 +28,7 @@ from project.project import task as base_project_task class project_task(osv.osv): _name = "project.task" - _inherit = ["calendar.todo", "project.task"] + _inherit = ["project.task", "calendar.todo"] _columns = { # force inherit from project.project_task so that # calendar.todo.active is masked oute diff --git a/addons/project_caldav/project_caldav_view.xml b/addons/project_caldav/project_caldav_view.xml index f361dc9580b..57e9e75a53b 100644 --- a/addons/project_caldav/project_caldav_view.xml +++ b/addons/project_caldav/project_caldav_view.xml @@ -66,7 +66,7 @@ - + From a2dcc919cea8e2bce788ab656c4d6674f2a67490 Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Fri, 8 Jul 2011 15:35:02 +0200 Subject: [PATCH 017/374] [CLEAN] clean recurrent option view in task, but deactivate reccurency for task in openerp since it's not well implemented bzr revid: tfr@openerp.com-20110708133502-gqdovbyhm717xdgx --- addons/project_caldav/project_caldav_view.xml | 64 +++++++++++-------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/addons/project_caldav/project_caldav_view.xml b/addons/project_caldav/project_caldav_view.xml index 57e9e75a53b..0d566be4619 100644 --- a/addons/project_caldav/project_caldav_view.xml +++ b/addons/project_caldav/project_caldav_view.xml @@ -65,7 +65,8 @@ form - + + @@ -78,46 +79,57 @@ form - - - - - - - - - - - + + + + + + + + + + - + + - - + + - + + - + - - + + - - - - - - + + + + From 7c75f19da5e025fd7971d10c233c1c5a45037158 Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Fri, 8 Jul 2011 17:35:07 +0200 Subject: [PATCH 018/374] [FIX] creation of todo bzr revid: tfr@openerp.com-20110708153507-0old9j33jus9grmc --- addons/base_calendar/base_calendar.py | 3 +-- addons/caldav/caldav_node.py | 2 +- addons/project_caldav/project_caldav.py | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 5f24b08884a..e50bb52abd9 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1208,7 +1208,7 @@ rule or repeating pattern of time to exclude from the recurring rule."), def remove_virtual_id(self, ids): - if isinstance(ids, (str, int)): + if isinstance(ids, (str, int, long)): return base_calendar_id2real_id(ids) if isinstance(ids, (list, tuple)): @@ -1239,7 +1239,6 @@ rule or repeating pattern of time to exclude from the recurring rule."), if until_date: continue until_date = arg[2] - res = super(calendar_event, self).search(cr, uid, args_without_date, \ 0, 0, order, context, count=False) res = self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit, context=context) diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py index 5272d0fc1fd..71e9bdc2468 100644 --- a/addons/caldav/caldav_node.py +++ b/addons/caldav/caldav_node.py @@ -324,7 +324,6 @@ class node_calendar(nodes.node_class): uid = self.context.uid res = self.set_data(cr, data) - if res and len(res): # We arbitrarily construct only the first node of the data # that have been imported. ICS may have had more elements, @@ -332,6 +331,7 @@ class node_calendar(nodes.node_class): assert isinstance(res[0], (int, long)) fnodes = fil_obj.get_calendar_objects(cr, uid, [self.calendar_id], self, domain=[('id','=',res[0])], context=ctx) + if self.context.get('DAV-client','') in ('iPhone', 'iCalendar',): # For those buggy clients, register the alias bca_obj = fil_obj.pool.get('basic.calendar.alias') diff --git a/addons/project_caldav/project_caldav.py b/addons/project_caldav/project_caldav.py index f17ef3050d4..782f167d69b 100644 --- a/addons/project_caldav/project_caldav.py +++ b/addons/project_caldav/project_caldav.py @@ -109,6 +109,8 @@ class project_task(osv.osv): self.write(cr, uid, [exists], val) ids.append(exists) else: + #set user_id with id, needed later + val.update({'user_id' : uid}) task_id = self.create(cr, uid, val) ids.append(task_id) return ids From aedeaadb4663a57e0ee9c45b7b372d5bae000946 Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Mon, 11 Jul 2011 14:20:55 +0200 Subject: [PATCH 019/374] [FIX] caldav write_date problem + attendees synchronization bzr revid: tfr@openerp.com-20110711122055-63syh4xflmko9ajb --- addons/caldav/calendar.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index a70a31bc017..94d28e4ad37 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -121,10 +121,10 @@ def str2mailto(emailstr, multi=False): for mas in mailz: m = mege.match(mas.strip()) if not m: - # one of the rare non-matching strings is "sad" :( - # retz.append({ 'name': mas.strip() }) - # continue - raise ValueError("Invalid email address %r" % mas) + #one of the rare non-matching strings is "sad" :( + retz.append({ 'name': mas.strip() }) + continue + # raise ValueError("Invalid email address %r" % mas) rd = { 'name': m.group(1).strip(), 'email': m.group(5), } if m.group(2): @@ -189,6 +189,9 @@ def map_data(cr, uid, obj, context=None): field = obj.ical_get(map_dict, 'field') field_type = obj.ical_get(map_dict, 'type') if field: + #ignore write date, this field is resered for the orm + if field == 'write_date': + continue if field_type == 'selection': if not map_val: continue @@ -299,7 +302,6 @@ class CalDAV(object): att_data = [] exdates = [] _server_tzinfo = pytz.timezone(tools.get_server_timezone()) - for cal_data in child.getChildren(): if cal_data.name.lower() == 'organizer': dmail = { 'name': cal_data.params.get('CN', ['',])[0], @@ -552,7 +554,7 @@ class CalDAV(object): @param data_id: Get Data’s ID or False @param context: A standard dictionary for contextual values """ - + ical_data = content self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, context) parsedCal = vobject.readOne(ical_data) From 0a583564912137386a36da42c5fefb651add8ee9 Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Mon, 11 Jul 2011 17:51:29 +0200 Subject: [PATCH 020/374] [IMP] in progress translate rrule into openerp data bzr revid: tfr@openerp.com-20110711155129-jjhuvaby3m5eryuu --- addons/base_calendar/base_calendar.py | 80 ++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index e50bb52abd9..dfa898c633f 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -991,14 +991,80 @@ class calendar_event(osv.osv): """ result = {} + if not isinstance(ids, list): + ids = [ids] + for datas in self.read(cr, uid, ids, ['id','byday','recurrency', 'month_list','end_date', 'rrule_type', 'select1', 'interval', 'count', 'end_type', 'mo', 'tu', 'we', 'th', 'fr', 'sa', 'su', 'exrule', 'day', 'week_list' ], context=context): event = datas['id'] if datas.get('interval', 0) < 0: raise osv.except_osv(_('Warning!'), _('Interval can not be Negative')) if datas.get('count', 0) < 0: raise osv.except_osv(_('Warning!'), _('Count can not be Negative')) - result[event] = self.compute_rule_string(datas) + if datas['recurrency']: + result[event] = self.compute_rule_string(datas) + else: + result[event] = "" return result + + def _parse_rrule(self, rule, data): + day_list = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] + r = rrule.rrulestr(rule) + data['count'] = r._count + data['interval'] = r._interval + data['end_date'] = r._until and r._until.strftime("%Y-%m-%d %H:%M:%S") + #repeat weekly + if r._byweekday: + for i in xrange(0,7): + if i in r._byweekday: + data[day_list[i]] = True + data['rrule_type'] = 'weekly' + #repeat monthly bynweekday ((weekday, weeknumber), ) + if r._bynweekday: + data['week_list'] = day_list[r._bynweekday[0][0]].upper() + data['byday'] = r._bynweekday[0][1] + data['rrule_type'] = 'monthly' + + #end of recurrence + #in case of repeat for ever that we do not support right now + if not (data.get('count') or data.get('end_date')): + data['count'] = 100 + if data.get('count'): + data['end_type'] = 'count' + else: + data['end_type'] = 'end_date' + return data + + def _write_rrule(self, cr, uid, ids, field_name, field_value, arg, context): + print field_name, field_value + data = { + 'byday' : False, + 'recurrency' : False, + 'month_list' : False, + 'end_date' : False, + 'rrule_type' : False, + 'select1' : False, + 'interval' : 0, + 'count' : False, + 'end_type' : False, + 'mo' : False, + 'tu' : False, + 'we' : False, + 'th' : False, + 'fr' : False, + 'sa' : False, + 'su' : False, + 'exrule' : False, + 'day' : False, + 'week_list' : False + } + + if field_value: + update_data = self._parse_rrule(field_value, dict(data)) + print update_data + #parse_rrule + self.write(cr, uid, ids, data, context=context) + + print "rrule", self._get_rulestring(cr, uid, ids, None, arg, context) _columns = { 'id': fields.integer('ID'), @@ -1022,7 +1088,7 @@ class calendar_event(osv.osv): defines the list of date/time exceptions for a recurring calendar component."), 'exrule': fields.char('Exception Rule', size=352, help="Defines a \ rule or repeating pattern of time to exclude from the recurring rule."), - 'rrule': fields.function(_get_rulestring, type='char', size=124, \ + 'rrule': fields.function(_get_rulestring, fnct_inv=_write_rrule, type='char', size=124, \ store=True, string='Recurrent Rule'), 'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \ ('weekly', 'Weekly'), ('monthly', 'Monthly'), \ @@ -1173,7 +1239,7 @@ rule or repeating pattern of time to exclude from the recurring rule."), @param self: the object pointer @param datas: dictionary of freq and interval value. """ - + print "compute rule string" def get_week_string(freq, datas): weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] if freq == 'weekly': @@ -1277,6 +1343,8 @@ rule or repeating pattern of time to exclude from the recurring rule."), except Exception: return True + + def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if context is None: context = {} @@ -1284,6 +1352,9 @@ rule or repeating pattern of time to exclude from the recurring rule."), select = [ids] else: select = ids + + + new_ids = [] res = False for event_id in select: @@ -1335,6 +1406,9 @@ rule or repeating pattern of time to exclude from the recurring rule."), context=context) vals.update(updated_vals.get('value', {})) if new_ids: + if 'rrule' in vals.keys(): + print "write, rrule" + print "write ", vals res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context) if ('alarm_id' in vals or 'base_calendar_alarm_id' in vals)\ From 842b67f5b095a11c2185307102eba11e2e7ceeae Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Tue, 12 Jul 2011 12:03:12 +0200 Subject: [PATCH 021/374] [IMP] support caldav recurrency bzr revid: tfr@openerp.com-20110712100312-lj0uib1rnx90dbhc --- addons/base_calendar/base_calendar.py | 155 +++++++++++++++----------- 1 file changed, 92 insertions(+), 63 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index dfa898c633f..1e71ea65634 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1006,66 +1006,9 @@ class calendar_event(osv.osv): result[event] = "" return result - def _parse_rrule(self, rule, data): - day_list = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] - r = rrule.rrulestr(rule) - data['count'] = r._count - data['interval'] = r._interval - data['end_date'] = r._until and r._until.strftime("%Y-%m-%d %H:%M:%S") - #repeat weekly - if r._byweekday: - for i in xrange(0,7): - if i in r._byweekday: - data[day_list[i]] = True - data['rrule_type'] = 'weekly' - #repeat monthly bynweekday ((weekday, weeknumber), ) - if r._bynweekday: - data['week_list'] = day_list[r._bynweekday[0][0]].upper() - data['byday'] = r._bynweekday[0][1] - data['rrule_type'] = 'monthly' - - #end of recurrence - #in case of repeat for ever that we do not support right now - if not (data.get('count') or data.get('end_date')): - data['count'] = 100 - if data.get('count'): - data['end_type'] = 'count' - else: - data['end_type'] = 'end_date' - return data + + - def _write_rrule(self, cr, uid, ids, field_name, field_value, arg, context): - print field_name, field_value - data = { - 'byday' : False, - 'recurrency' : False, - 'month_list' : False, - 'end_date' : False, - 'rrule_type' : False, - 'select1' : False, - 'interval' : 0, - 'count' : False, - 'end_type' : False, - 'mo' : False, - 'tu' : False, - 'we' : False, - 'th' : False, - 'fr' : False, - 'sa' : False, - 'su' : False, - 'exrule' : False, - 'day' : False, - 'week_list' : False - } - - if field_value: - update_data = self._parse_rrule(field_value, dict(data)) - print update_data - #parse_rrule - self.write(cr, uid, ids, data, context=context) - - print "rrule", self._get_rulestring(cr, uid, ids, None, arg, context) - _columns = { 'id': fields.integer('ID'), 'sequence': fields.integer('Sequence'), @@ -1088,7 +1031,7 @@ class calendar_event(osv.osv): defines the list of date/time exceptions for a recurring calendar component."), 'exrule': fields.char('Exception Rule', size=352, help="Defines a \ rule or repeating pattern of time to exclude from the recurring rule."), - 'rrule': fields.function(_get_rulestring, fnct_inv=_write_rrule, type='char', size=124, \ + 'rrule': fields.function(_get_rulestring, type='char', size=124, \ store=True, string='Recurrent Rule'), 'rrule_type': fields.selection([('none', ''), ('daily', 'Daily'), \ ('weekly', 'Weekly'), ('monthly', 'Monthly'), \ @@ -1239,7 +1182,6 @@ rule or repeating pattern of time to exclude from the recurring rule."), @param self: the object pointer @param datas: dictionary of freq and interval value. """ - print "compute rule string" def get_week_string(freq, datas): weekdays = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] if freq == 'weekly': @@ -1271,7 +1213,85 @@ rule or repeating pattern of time to exclude from the recurring rule."), return '' interval_srting = datas.get('interval') and (';INTERVAL=' + str(datas.get('interval'))) or '' return 'FREQ=' + freq.upper() + get_week_string(freq, datas) + interval_srting + get_end_date(datas) + get_month_string(freq, datas) + + def _get_empty_rrule_data(self): + return { + 'byday' : False, + 'recurrency' : False, + 'end_date' : False, + 'rrule_type' : False, + 'select1' : False, + 'interval' : 0, + 'count' : False, + 'end_type' : False, + 'mo' : False, + 'tu' : False, + 'we' : False, + 'th' : False, + 'fr' : False, + 'sa' : False, + 'su' : False, + 'exrule' : False, + 'day' : False, + 'week_list' : False + } + def _write_rrule(self, cr, uid, ids, field_value, rule_date=False, context=None): + data = self._get_empty_rrule_data() + + if field_value: + data['recurrency'] = True + for event in self.browse(cr, uid, ids, context=context): + rdate = rule_date or event.date + update_data = self._parse_rrule(field_value, dict(data), rdate) + data.update(update_data) + #parse_rrule + self.write(cr, uid, event.id, data, context=context) + + + def _parse_rrule(self, rule, data, date_start): + day_list = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] + rrule_type = ['yearly', 'monthly', 'weekly', 'daily'] + r = rrule.rrulestr(rule, dtstart=datetime.strptime(date_start, "%Y-%m-%d %H:%M:%S")) + + if r._freq > 0 and r._freq < 4: + data['rrule_type'] = rrule_type[r._freq] + + data['count'] = r._count + data['interval'] = r._interval + data['end_date'] = r._until and r._until.strftime("%Y-%m-%d %H:%M:%S") + #repeat weekly + if r._byweekday: + for i in xrange(0,7): + if i in r._byweekday: + data[day_list[i]] = True + data['rrule_type'] = 'weekly' + #repeat monthly bynweekday ((weekday, weeknumber), ) + if r._bynweekday: + data['week_list'] = day_list[r._bynweekday[0][0]].upper() + data['byday'] = r._bynweekday[0][1] + data['select1'] = 'day' + data['rrule_type'] = 'monthly' + + if r._bymonthday: + data['day'] = r._bymonthday[0] + data['select1'] = 'date' + data['rrule_type'] = 'monthly' + + #yearly but for openerp it's monthly, take same information as monthly but interval is 12 times + if r._bymonth: + data['interval'] = data['interval'] * 12 + + #FIXEME handle forever case + #end of recurrence + #in case of repeat for ever that we do not support right now + if not (data.get('count') or data.get('end_date')): + data['count'] = 100 + if data.get('count'): + data['end_type'] = 'count' + else: + data['end_type'] = 'end_date' + return data def remove_virtual_id(self, ids): if isinstance(ids, (str, int, long)): @@ -1407,8 +1427,12 @@ rule or repeating pattern of time to exclude from the recurring rule."), vals.update(updated_vals.get('value', {})) if new_ids: if 'rrule' in vals.keys(): - print "write, rrule" - print "write ", vals + if 'date' in vals.keys(): + date_to_write = vals['date'] + else: + date_to_write = False + self._write_rrule(cr, uid, new_ids, vals['rrule'], date_to_write, context) + res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context) if ('alarm_id' in vals or 'base_calendar_alarm_id' in vals)\ @@ -1535,6 +1559,11 @@ rule or repeating pattern of time to exclude from the recurring rule."), if vals.get('vtimezone', '') and vals.get('vtimezone', '').startswith('/freeassociation.sourceforge.net/tzfile/'): vals['vtimezone'] = vals['vtimezone'][40:] + + if 'date' in vals and 'rrule' in vals and vals['rrule']: + update_datas = self._parse_rrule(vals['rrule'], self._get_empty_rrule_data(), vals['date']) + update_datas['recurrency'] = True + vals.update(update_datas) updated_vals = self.onchange_dates(cr, uid, [], vals.get('date', False), From cac9fb4e0322ad041acc2cdb9e9a90322b9decba Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Tue, 12 Jul 2011 16:02:13 +0200 Subject: [PATCH 022/374] [FIX] get hostname using tools.get_hostname bzr revid: tfr@openerp.com-20110712140213-flf80sbimzhkmekx --- addons/caldav/wizard/caldav_browse.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/caldav/wizard/caldav_browse.py b/addons/caldav/wizard/caldav_browse.py index f6ecc5dccd5..49b313b9886 100644 --- a/addons/caldav/wizard/caldav_browse.py +++ b/addons/caldav/wizard/caldav_browse.py @@ -24,6 +24,7 @@ from tools import config import base64 import addons from tools.translate import _ +import tools class caldav_browse(osv.osv_memory): @@ -239,12 +240,8 @@ class user_preference(osv.osv_memory): return ids[0] def _get_default_host(self, cr, uid, context): - ids=self.search(cr,uid,[]) - host_name = '' - if ids: - ids = len(ids)> 1 and len(ids)-1 or ids[0] # Use len(ids)-1 for taking the value of last id - host_name = self.browse(cr, uid,[ids],context=context)[0].host_name - return host_name + + return tools.get_hostname(self, cr, uid) _defaults={ 'service': 'webdav', From e84d292ceb36d53f40aba7c0a842b4f779ea4006 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Mon, 18 Jul 2011 15:23:44 +0530 Subject: [PATCH 023/374] [IMP] sale: Improved code by adding context argument wherever required. * product_visible_discount, warning: Added remaining context argument on product_id_change method. bzr revid: uco@tinyerp.com-20110718095344-tdlsys7uueqp9kdy --- addons/product_visible_discount/product_visible_discount.py | 5 +++-- addons/sale/sale.py | 2 +- addons/sale/sale_view.xml | 2 +- addons/sale_layout/sale_layout_view.xml | 2 +- addons/warning/warning.py | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/product_visible_discount/product_visible_discount.py b/addons/product_visible_discount/product_visible_discount.py index c2f939c1618..2571855ec89 100644 --- a/addons/product_visible_discount/product_visible_discount.py +++ b/addons/product_visible_discount/product_visible_discount.py @@ -40,7 +40,8 @@ class sale_order_line(osv.osv): def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, - lang=False, update_tax=True,date_order=False,packaging=False,fiscal_position=False, flag=False): + lang=False, update_tax=True, date_order=False, packaging=False, + fiscal_position=False, flag=False, context=None): def get_real_price(res_dict, product_id, qty, uom, pricelist): item_obj = self.pool.get('product.pricelist.item') @@ -70,7 +71,7 @@ class sale_order_line(osv.osv): res=super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, uom, qty_uos, uos, name, partner_id, - lang, update_tax,date_order,fiscal_position=fiscal_position,flag=flag) + lang, update_tax, date_order, fiscal_position=fiscal_position, flag=flag, context=context) context = {'lang': lang, 'partner_id': partner_id} result=res['value'] diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 06bdbf44a10..ad79506f8a8 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1024,7 +1024,7 @@ class sale_order_line(osv.osv): if flag: res = self.product_id_change(cr, uid, ids, pricelist=pricelist, product=product, qty=qty, uom=uom, partner_id=partner_id, - packaging=packaging, flag=False) + packaging=packaging, flag=False, context=context) warning_msgs = res.get('warning') and res['warning']['message'] products = product_obj.browse(cr, uid, product, context=context) diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 72314f945da..d191cd3553f 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -142,7 +142,7 @@ diff --git a/addons/sale_layout/sale_layout_view.xml b/addons/sale_layout/sale_layout_view.xml index 407d15a5c04..c4e20b979ab 100644 --- a/addons/sale_layout/sale_layout_view.xml +++ b/addons/sale_layout/sale_layout_view.xml @@ -38,7 +38,7 @@ name="product_packaging" attrs="{'readonly':[('layout_type','!=','article')]}" context="{'partner_id':parent.partner_id,'quantity':product_uom_qty,'pricelist':parent.pricelist_id,'shop':parent.shop_id,'uom':product_uom}" - on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True)" + on_change="product_packaging_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, parent.partner_id, product_packaging, True, context)" domain="[('product_id','=',product_id)]" groups="base.group_extended"/> diff --git a/addons/warning/warning.py b/addons/warning/warning.py index ab7a5926653..e5bdf07aef3 100644 --- a/addons/warning/warning.py +++ b/addons/warning/warning.py @@ -197,7 +197,7 @@ class sale_order_line(osv.osv): def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, - fiscal_position=False, flag=False): + fiscal_position=False, flag=False, context=None): warning = {} if not product: return {'value': {'th_weight' : 0, 'product_packaging': False, @@ -218,7 +218,7 @@ class sale_order_line(osv.osv): result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty, uom, qty_uos, uos, name, partner_id, - lang, update_tax, date_order, packaging, fiscal_position, flag) + lang, update_tax, date_order, packaging, fiscal_position, flag, context=context) if result.get('warning',False): warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title'] From c38c7d055cbb198f0696048e5b2fdac6aac12592 Mon Sep 17 00:00:00 2001 From: Manu <> Date: Tue, 19 Jul 2011 18:37:40 +0530 Subject: [PATCH 024/374] [FIX] account : improved the dates in recurring entries lp bug: https://launchpad.net/bugs/800767 fixed bzr revid: bde@tinyerp.com-20110719130740-eq87ant192zguo0n --- addons/account/account.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 03a9b628922..64aab95ee29 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1331,7 +1331,7 @@ class account_move(osv.osv): def _centralise(self, cr, uid, move, mode, context=None): assert mode in ('debit', 'credit'), 'Invalid Mode' #to prevent sql injection - currency_obj = self.pool.get('res.currency') + currency_obj = self.pool.get('res.currency') if context is None: context = {} @@ -1593,7 +1593,7 @@ class account_tax_code(osv.osv): (parent_ids,) + where_params) res=dict(cr.fetchall()) obj_precision = self.pool.get('decimal.precision') - res2 = {} + res2 = {} for record in self.browse(cr, uid, ids, context=context): def _rec_get(record): amount = res.get(record.id, 0.0) @@ -2120,7 +2120,7 @@ class account_model(osv.osv): period_id = period_id[0] for model in self.browse(cr, uid, ids, context=context): - entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')} + entry['name'] = model.name%{'year':context.get('date',time.strftime('%Y')), 'month':context.get('date',time.strftime('%m')), 'date':context.get('date',time.strftime('%d'))} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], 'period_id': period_id, @@ -2141,7 +2141,7 @@ class account_model(osv.osv): 'analytic_account_id': analytic_account_id } - date_maturity = time.strftime('%Y-%m-%d') + date_maturity = context.get('date',time.strftime('%Y-%m-%d')) if line.date_maturity == 'partner': if not line.partner_id: raise osv.except_osv(_('Error !'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \ From e955394d4503d207c135a5476c684e2f32e2a96c Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Wed, 20 Jul 2011 17:09:53 +0530 Subject: [PATCH 025/374] [IMP] account : improved the context date in account model bzr revid: bde@tinyerp.com-20110720113953-h6774pxnk7gqpeu7 --- addons/account/account.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 64aab95ee29..0364858fc58 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -21,6 +21,7 @@ import time from datetime import datetime +from time import mktime from dateutil.relativedelta import relativedelta from operator import itemgetter @@ -2120,7 +2121,10 @@ class account_model(osv.osv): period_id = period_id[0] for model in self.browse(cr, uid, ids, context=context): - entry['name'] = model.name%{'year':context.get('date',time.strftime('%Y')), 'month':context.get('date',time.strftime('%m')), 'date':context.get('date',time.strftime('%d'))} + context_date = context.get('date') + str_date = time.strptime(context_date,"%Y-%m-%d") + date = datetime.fromtimestamp(mktime(str_date)) + entry['name'] = model.name%{'year':date.strftime("%Y"), 'month':date.strftime("%m"), 'date': date.strftime("%Y-%m")} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], 'period_id': period_id, From 2f198e85766e432dcf8d628a96ca3d1d55a9bfee Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Tue, 26 Jul 2011 12:09:59 +0530 Subject: [PATCH 026/374] [FIX] account_cancel: re-open invoice assigned to useability/no one lp bug: https://launchpad.net/bugs/807543 fixed bzr revid: ara@tinyerp.com-20110726063959-lh8o2qjc697xe1jo --- addons/account_cancel/account_cancel_view.xml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/addons/account_cancel/account_cancel_view.xml b/addons/account_cancel/account_cancel_view.xml index 9e8b532e931..786afb9e9f0 100644 --- a/addons/account_cancel/account_cancel_view.xml +++ b/addons/account_cancel/account_cancel_view.xml @@ -12,5 +12,30 @@ + + + invoice.form.inherit + account.invoice + form + + + +