diff --git a/addons/account/wizard/wizard_partner_balance_report.py b/addons/account/wizard/wizard_partner_balance_report.py index c4241f7f4e9..3031440c33e 100644 --- a/addons/account/wizard/wizard_partner_balance_report.py +++ b/addons/account/wizard/wizard_partner_balance_report.py @@ -62,7 +62,7 @@ period_fields = { 'default': lambda *a:False, 'help': 'Keep empty for all open fiscal year' }, - 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty','states':{'none':[('readonly',True)],'bydate':[('readonly',True)]}}, + 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}, 'result_selection':{ 'string':"Partner", 'type':'selection', diff --git a/addons/base_setup/wizard/wizard_base_setup.py b/addons/base_setup/wizard/wizard_base_setup.py index 10c75bd092e..aca4b185ade 100644 --- a/addons/base_setup/wizard/wizard_base_setup.py +++ b/addons/base_setup/wizard/wizard_base_setup.py @@ -111,43 +111,51 @@ class wizard_base_setup(wizard.interface): return res def _get_company(self, cr, uid, data, context): - pool=pooler.get_pool(cr.dbname) - company_obj=pool.get('res.company') + pool = pooler.get_pool(cr.dbname) + company_obj = pool.get('res.company') ids=company_obj.search(cr, uid, []) if not ids: return {} - company=company_obj.browse(cr, uid, ids)[0] - self.fields['name']['default']=company.name - self.fields['currency']['default']=company.currency_id.id - serv_pro_id = pooler.get_pool(cr.dbname).get('ir.module.module').search(cr, uid, [('name','=','profile_service')]) or False + company = company_obj.browse(cr, uid, ids)[0] + + res = {'currency': company.currency_id.id} + + for field in 'name logo rml_header1 rml_footer1 rml_footer2'.split(): + res[field] = company[field] + + if company.partner_id.address: + address = company.partner_id.address[0] + for field in 'street street2 zip city email phone'.split(): + res[field] = address[field] + + for field in 'country_id state_id'.split(): + if address[field]: + res[field] = address[field].id + + serv_pro_id = pool.get('ir.module.module').search(cr, uid, [('name','=','profile_service')]) or False if serv_pro_id: - return {'profile':serv_pro_id[0]} - return {} + res['profile'] = serv_pro_id[0] + + return res + + + def _get_all(self, cr, uid, context, model): + pool = pooler.get_pool(cr.dbname) + obj = pool.get(model) + ids = obj.search(cr, uid, []) + res = [(o.id, o.name) for o in obj.browse(cr, uid, ids, context=context)] + res.append((-1, '')) + res.sort(key=lambda x: x[1]) + return res def _get_states(self, cr, uid, context): - pool=pooler.get_pool(cr.dbname) - state_obj=pool.get('res.country.state') - ids=state_obj.search(cr, uid, []) - res=[(state.id, state.name) for state in state_obj.browse(cr, uid, ids, context=context)] - res.append((-1, '')) - res.sort(lambda x,y: cmp(x[1],y[1])) - return res + return self._get_all(cr, uid, context, 'res.country.state') def _get_countries(self, cr, uid, context): - pool=pooler.get_pool(cr.dbname) - country_obj=pool.get('res.country') - ids=country_obj.search(cr, uid, []) - res=[(country.id, country.name) for country in country_obj.browse(cr, uid, ids, context=context)] - res.sort(lambda x,y: cmp(x[1],y[1])) - return res + return self._get_all(cr, uid, context, 'res.country') def _get_currency(self, cr, uid, context): - pool=pooler.get_pool(cr.dbname) - currency_obj=pool.get('res.currency') - ids=currency_obj.search(cr, uid, []) - res=[(currency.id, currency.name) for currency in currency_obj.browse(cr, uid, ids, context=context)] - res.sort(lambda x,y: cmp(x[1],y[1])) - return res + return self._get_all(cr, uid, context, 'res.currency') def _update(self, cr, uid, data, context): pool=pooler.get_pool(cr.dbname) @@ -256,7 +264,6 @@ class wizard_base_setup(wizard.interface): 'string':'Profile', 'type':'selection', 'selection':_get_profiles, -# 'default': _get_service_profile, 'required': True, }, diff --git a/addons/product/report/product_pricelist.py b/addons/product/report/product_pricelist.py index 22bad5ee1f1..9387a7cb33d 100644 --- a/addons/product/report/product_pricelist.py +++ b/addons/product/report/product_pricelist.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -25,14 +25,6 @@ from report import report_sxw from osv import osv import pooler -from tools.translate import _ - -parents = { - 'tr':1, - 'li':1, - 'story': 0, - 'section': 0 -} class product_pricelist(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(product_pricelist, self).__init__(cr, uid, name, context) @@ -44,44 +36,30 @@ class product_pricelist(report_sxw.rml_parse): 'get_currency': self._get_currency, 'get_categories': self._get_categories, 'get_price': self._get_price, - 'get_quantity':self._get_quantity, - 'qty_header':self._qty_header, }) - def _qty_header(self,form): - def _get_unit_text(obj, cr, uid, par_qty): - if form[q]==1: - return _('%d unit')%(par_qty) - else: - return _('%d units')%(par_qty) - qty=[] - self.pricelist=form['price_list'] + def _set_quantity(self,form): for i in range(1,6): q = 'qty%d'%i if form[q]: self.quantity.append(form[q]) - qty.append(_get_unit_text(self, self.cr, self.uid, form[q])) - return qty + return True - - def _get_quantity(self,form): - qty=[] - for i in range(1,6): - q = 'qty%d'%i - if form[q]: - qty.append(form[q]) - return qty def _get_pricelist(self, pricelist_id): pool = pooler.get_pool(self.cr.dbname) pricelist = pool.get('product.pricelist').read(self.cr,self.uid,[pricelist_id],['name'])[0] return pricelist['name'] + def _get_currency(self, pricelist_id): pool = pooler.get_pool(self.cr.dbname) pricelist = pool.get('product.pricelist').read(self.cr,self.uid,[pricelist_id],['currency_id'])[0] return pricelist['currency_id'][1] - def _get_categories(self, products): + + def _get_categories(self, products,form): cat_ids=[] res=[] + self.pricelist = form['price_list'] + self._set_quantity(form) pool = pooler.get_pool(self.cr.dbname) pro_ids=[] for product in products: @@ -98,10 +76,11 @@ class product_pricelist(report_sxw.rml_parse): 'name':product.name, 'code':product.code } + i = 1 for qty in self.quantity: - val[str(qty)]=self._get_price(self.pricelist,product.id,qty) + val['qty'+str(i)]=self._get_price(self.pricelist,product.id,qty) + i += 1 products.append(val) - res.append({'name':cat.name,'products':products}) return res @@ -115,42 +94,6 @@ class product_pricelist(report_sxw.rml_parse): price = self.formatLang(res[0]['list_price']) return price - def repeatIn(self, lst, name, nodes_parent=False,value=[],width=False,type=False): - self._node.data = '' - node = self._find_parent(self._node, nodes_parent or parents) - ns = node.nextSibling - if not lst: - lst.append(1) - for ns in node.childNodes : - if ns and ns.nodeName!='#text' and ns.tagName=='blockTable' and len(value) : - width_str = ns._attrs['colWidths'].nodeValue - ns.removeAttribute('colWidths') - if not width or width=='': - width=30 - if type.lower() in ('title'): - width=width*len(value) - width_str= '%d'%(float(width_str)+width) - ns.setAttribute('colWidths',width_str) - else: - for v in value: - width_str +=',%d'%width - - ns.setAttribute('colWidths',width_str) - child_list = ns.childNodes - for child in child_list: - if child.nodeName=='tr': - lc = child.childNodes[1] - t=0 - for v in value: - newnode = lc.cloneNode(1) - if type.lower() in ('string'): - newnode.childNodes[1].lastChild.data="[[ %s['%s'] ]]"%(name,v) - elif type.lower() in ('label'): - newnode.childNodes[1].lastChild.data= "%s"%(v) - child.appendChild(newnode) - newnode=False - return super(product_pricelist,self).repeatIn(lst, name, nodes_parent=False) -#end report_sxw.report_sxw('report.product.pricelist','product.product','addons/product/report/product_pricelist.rml',parser=product_pricelist) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product/report/product_pricelist.rml b/addons/product/report/product_pricelist.rml index ddeb5023768..473920f6535 100644 --- a/addons/product/report/product_pricelist.rml +++ b/addons/product/report/product_pricelist.rml @@ -13,103 +13,175 @@ - + - + + + + + - + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + - Products Price List + Products Price List - - - - - + - Price List Name : [[ get_pricelist (data['form']['price_list']) ]] - Currency : [[ get_currency ( data['form']['price_list']) ]] - Printing Date: [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] - - - -
- [[repeatIn([],'qty_header',width=59,value=qty_header(data['form']),type='label') ]] - - - - Description - - - -
-
- [[ repeatIn(get_categories(objects), 'c',width=59,value=get_quantity(data['form']),type='title') ]] - - - - [[ c['name'] ]] - - - - -
- [[repeatIn(c['products'], 'p',width=59,value=get_quantity(data['form']),type='string') ]] - - - - [[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]] - - - -
-
- + + + + Price List Name: + + + [[ get_pricelist(data['form']['price_list']) ]] + + + + + Currency : + + + [[ get_currency ( data['form']['price_list']) ]] + + + + + Printing Date : + + + [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] + + + + + + + + + + Description + + + [[str( data['form']['qty1']) ]] units + + + [[ str(data['form']['qty2'] )]] units + + + [[ str(data['form']['qty3']) ]] units + + + [[ str(data['form']['qty4']) ]] units + + + [[ str(data['form']['qty5'] ) ]] units + + + + + + + + [[repeatIn(get_categories(objects,data['form']), 'c')]][[ c['name'] ]] + + + + + [[repeatIn(c['products'], 'p')]][[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]] + + + [[p['qty1'] ]] + + + [[ p['qty2'] ]] + + + [[ p['qty3'] ]] + + + [[ p['qty4'] ]] + + + [[ p['qty5'] ]] + + + + + + + + +
diff --git a/addons/project/project_wizard.xml b/addons/project/project_wizard.xml index 3e441e3f8f0..109a003da4a 100644 --- a/addons/project/project_wizard.xml +++ b/addons/project/project_wizard.xml @@ -3,5 +3,6 @@ + diff --git a/addons/project/wizard/__init__.py b/addons/project/wizard/__init__.py index 27c629e8d93..e8ef05292ac 100644 --- a/addons/project/wizard/__init__.py +++ b/addons/project/wizard/__init__.py @@ -22,6 +22,7 @@ import close_task import task_delegate +import task_attachment # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project/wizard/task_attachment.py b/addons/project/wizard/task_attachment.py new file mode 100644 index 00000000000..8f872db758c --- /dev/null +++ b/addons/project/wizard/task_attachment.py @@ -0,0 +1,50 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import wizard +import pooler + +'''View the attachments of the parent + children tasks''' + +def _show_attachment(self, cr, uid, data, context): + task_obj = pooler.get_pool(cr.dbname).get('project.task') + task_browse_id = task_obj.browse(cr, uid, [data['id']], context)[0] + attachment_list = [child_id.id for child_id in task_browse_id.child_ids] + attachment_list.extend([task_browse_id.parent_id.id]) + value = { + 'domain': [('res_model','=',data['model']),('res_id','in',attachment_list)], + 'name': 'Attachments', + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'ir.attachment', + 'context': { }, + 'type': 'ir.actions.act_window' + } + return value +class wizard_attachment(wizard.interface): + states = { + 'init': { + 'actions': [], + 'result': {'type':'action', 'action':_show_attachment, 'state': 'end'}, + }, + } +wizard_attachment('project.task.attachment') diff --git a/addons/sale/sale.py b/addons/sale/sale.py index ed908dff6bb..cd1f8ab26ce 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -880,7 +880,7 @@ class sale_order_line(osv.osv): pack = self.pool.get('product.packaging').browse(cr, uid, packaging, context) q = product_uom_obj._compute_qty(cr, uid, uom, pack.qty, default_uom) # qty = qty - qty % q + q - if not (qty % q) == 0 : + if qty and (not (qty % q) == 0): ean = pack.ean qty_pack = pack.qty type_ul = pack.ul