bzr revid: fp@tinyerp.com-20090505203033-kfza1c9o2jvkgy8k
This commit is contained in:
Fabien Pinckaers 2009-05-05 22:30:33 +02:00
commit 8efceccd5d
8 changed files with 237 additions and 163 deletions

View File

@ -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',

View File

@ -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,
},

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 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:

View File

@ -13,103 +13,175 @@
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" />
<lineStyle kind="GRID" colorName="black"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,0"/>
<blockBackground colorName="#e6e6e6" start="4,0" stop="4,0"/>
<blockBackground colorName="#e6e6e6" start="5,0" stop="5,0"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="GRID" colorName="black"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="9.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="9.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="8.0" leading="10"/>
<paraStyle name="P6" fontName="Times-Bold" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman" fontSize="12"/>
<paraStyle name="P1" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica-Bold" fontSize="16.0" leading="20" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="8.0" leading="10"/>
<paraStyle name="P9" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Bold" fontSize="8.0" leading="8" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="cat" fontName="Times-Bold" textColor="blue" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
</stylesheet>
<story>
<para style="P5">
<font color="white"> </font>
</para>
<blockTable colWidths="530.0" repeatRows="1" style="Table1">
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">
<font color="white"> </font>
</para>
<para style="P8">
<font color="white"> </font>
</para>
<blockTable colWidths="482.0" style="Table1">
<tr>
<td>
<para style="P8">Products Price List</para>
<para style="P2">Products Price List</para>
</td>
</tr>
</blockTable>
<para style="P5">
<font color="white"> </font>
</para>
<para style="Standard">
<para style="P8">
<font color="white"> </font>
</para>
<para style="Standard">Price List Name : [[ get_pricelist (data['form']['price_list']) ]]</para>
<para style="Standard">Currency : [[ get_currency ( data['form']['price_list']) ]]</para>
<para style="Standard">Printing Date: [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]]</para>
<para style="P7">
<font color="white"> </font>
</para>
<section>
<para style="P6">[[repeatIn([],'qty_header',width=59,value=qty_header(data['form']),type='label') ]]</para>
<blockTable colWidths="227.0" style="Table6">
<tr>
<td>
<para style="P6">Description</para>
</td>
</tr>
</blockTable>
</section>
<section>
<para style="Standard">[[ repeatIn(get_categories(objects), 'c',width=59,value=get_quantity(data['form']),type='title') ]]</para>
<blockTable colWidths="227.0" style="Table3">
<tr>
<td>
<para style="cat">[[ c['name'] ]]</para>
</td>
</tr>
</blockTable>
<section>
<para style="Standard">[[repeatIn(c['products'], 'p',width=59,value=get_quantity(data['form']),type='string') ]]</para>
<blockTable colWidths="227.0" style="Table3">
<tr>
<td>
<para style="P1">[[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]]</para>
</td>
</tr>
</blockTable>
</section>
</section>
<para style="P5"/>
<blockTable colWidths="117.0,364.0" style="Table2">
<tr>
<td>
<para style="P1">Price List Name:</para>
</td>
<td>
<para style="P3">[[ get_pricelist(data['form']['price_list']) ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P1">Currency :</para>
</td>
<td>
<para style="P3">[[ get_currency ( data['form']['price_list']) ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P1">Printing Date :</para>
</td>
<td>
<para style="P3">[[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]]</para>
<para style="P4">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P3">
<font color="white"> </font>
</para>
<blockTable colWidths="80.0,80.0,80.0,80.0,80.0,80.0" style="Table7">
<tr>
<td>
<para style="P6">Description</para>
</td>
<td>
<para style="P5">[[str( data['form']['qty1']) ]] units</para>
</td>
<td>
<para style="P6">[[ str(data['form']['qty2'] )]] units</para>
</td>
<td>
<para style="P6">[[ str(data['form']['qty3']) ]] units</para>
</td>
<td>
<para style="P6">[[ str(data['form']['qty4']) ]] units</para>
</td>
<td>
<para style="P6">[[ str(data['form']['qty5'] ) ]] units</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="482.0" style="Table3">
<tr>
<td>
<para style="P17">
<font face="Times-Roman">[[repeatIn(get_categories(objects,data['form']), 'c')]][[ c['name'] ]]</font>
</para>
<blockTable colWidths="79.0,79.0,79.0,79.0,79.0,79.0" style="Table5">
<tr>
<td>
<para style="P12">[[repeatIn(c['products'], 'p')]][[ p['code'] and '[' + p['code'] + '] ' or '' ]] [[ p['name'] ]]</para>
</td>
<td>
<para style="P7">[[p['qty1'] ]]</para>
</td>
<td>
<para style="P7">[[ p['qty2'] ]]</para>
</td>
<td>
<para style="P7">[[ p['qty3'] ]]</para>
</td>
<td>
<para style="P7">[[ p['qty4'] ]]</para>
</td>
<td>
<para style="P7">[[ p['qty5'] ]]</para>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<para style="P1">
<font color="white"> </font>
</para>
</story>
</document>

View File

@ -3,5 +3,6 @@
<data>
<wizard id="wizard_close_task" menu="False" model="project.task" name="project.task.close" string="Close Task"/>
<wizard id="wizard_delegate_task" menu="False" model="project.task" name="project.task.delegate" string="Delegate Task"/>
<wizard id="wizard_attachment_task" model="project.task" name="project.task.attachment" string="All Attachments"/>
</data>
</openerp>

View File

@ -22,6 +22,7 @@
import close_task
import task_delegate
import task_attachment
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,50 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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')

View File

@ -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