[Merge] Merge with main addons.

bzr revid: cha@tinyerp.com-20120727050444-ds655z0nigpxldcy
This commit is contained in:
Ajay Chauhan (OpenERP)
2012-07-27 10:34:44 +05:30
14 changed files with 114 additions and 198 deletions
@@ -528,40 +528,25 @@ class account_analytic_account_summary_user(osv.osv):
def init(self, cr):
tools.sql.drop_view_if_exists(cr, 'account_analytic_analysis_summary_user')
cr.execute('CREATE OR REPLACE VIEW account_analytic_analysis_summary_user AS (' \
'SELECT ' \
'(u.account_id * u.max_user) + u."user" AS id, ' \
'u.account_id AS account_id, ' \
'u."user" AS "user", ' \
'COALESCE(SUM(l.unit_amount), 0.0) AS unit_amount ' \
'FROM ' \
'(SELECT ' \
'a.id AS account_id, ' \
'u1.id AS "user", ' \
'MAX(u2.id) AS max_user ' \
'FROM ' \
'res_users AS u1, ' \
'res_users AS u2, ' \
'account_analytic_account AS a ' \
'GROUP BY u1.id, a.id ' \
') AS u ' \
'LEFT JOIN ' \
'(SELECT ' \
'l.account_id AS account_id, ' \
'l.user_id AS "user", ' \
'SUM(l.unit_amount) AS unit_amount ' \
'FROM account_analytic_line AS l, ' \
'account_analytic_journal AS j ' \
'WHERE (j.type = \'general\') and (j.id=l.journal_id) ' \
'GROUP BY l.account_id, l.user_id ' \
') AS l '
'ON (' \
'u.account_id = l.account_id ' \
'AND u."user" = l."user"' \
') ' \
'GROUP BY u."user", u.account_id, u.max_user' \
')')
cr.execute('''CREATE OR REPLACE VIEW account_analytic_analysis_summary_user AS (
with mu as
(select max(id) as max_user from res_users)
, lu AS
(SELECT
l.account_id AS account_id,
coalesce(l.user_id, 0) AS user_id,
SUM(l.unit_amount) AS unit_amount
FROM account_analytic_line AS l,
account_analytic_journal AS j
WHERE (j.type = 'general' ) and (j.id=l.journal_id)
GROUP BY l.account_id, l.user_id
)
select (lu.account_id * mu.max_user) + lu.user_id as id,
lu.account_id as account_id,
lu.user_id as "user",
unit_amount
from lu, mu)''')
account_analytic_account_summary_user()
class account_analytic_account_summary_month(osv.osv):
+10 -19
View File
@@ -1,29 +1,20 @@
openerp.anonymous = function(instance) {
instance.web.client_actions.add("login", "instance.web.Login");
instance.web.WebClient.include({
show_login: function() {
var self = this, _super = this._super;
this.login.load_db_list().then(function() {
var dblist = self.login._db_list;
instance.web.Login.include({
start: function() {
var self = this;
return $.when(this._super()).pipe(function() {
var dblist = self._db_list;
if (dblist && dblist.length === 1) {
self.login.remember_credentials = false;
self.remember_credentials = false;
// XXX get login/pass from server (via a rpc call) ?
self.login.do_login(dblist[0], 'anonymous', 'anonymous').fail(function() {
_super.apply(self, []);
});
} else {
_super.apply(self, []);
return self.do_login(dblist[0], 'anonymous', 'anonymous')
}
});
},
restart: function() {
return this.start();
}
});
instance.web.UserMenu.include({
init: function(parent) {
this._super(parent);
@@ -39,8 +30,8 @@ openerp.anonymous = function(instance) {
var p = self.getParent();
var am = p.action_manager;
p.$element.find('.oe_leftbar').hide();
am.do_action({type:'ir.actions.client', tag:'login'});
am.inner_widget.on('login', p, p.restart);
am.do_action({type:'ir.actions.client', tag:'login', target: 'new'});
am.dialog_widget.on('login', p, p.restart);
});
}
});
+1 -1
View File
@@ -73,7 +73,7 @@
<field name="arch" type="xml">
<form string="Meetings" version="7.0">
<header>
<button name="case_open" string="Confirm" type="object" class="oe_highlight"
<button name="case_open" string="Confirm" type="object"
states="draft"/>
<button name="case_close" string="Done" type="object"
states="open"/>
-7
View File
@@ -208,7 +208,6 @@ class crm_lead(base_stage, osv.osv):
'channel_id': fields.many2one('crm.case.channel', 'Channel', help="Communication channel (mail, direct, phone, ...)"),
'contact_name': fields.char('Contact Name', size=64),
'partner_name': fields.char("Customer Name", size=64,help='The name of the future partner company that will be created while converting the lead into opportunity', select=1),
'opt_in': fields.boolean('Opt-In', oldname='optin', help="If opt-in is checked, this contact has accepted to receive emails."),
'opt_out': fields.boolean('Opt-Out', oldname='optout', help="If opt-out is checked, this contact has refused to receive emails or unsubscribed to a campaign."),
'type':fields.selection([ ('lead','Lead'), ('opportunity','Opportunity'), ],'Type', help="Type is used to separate Leads and Opportunities"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True),
@@ -279,12 +278,6 @@ class crm_lead(base_stage, osv.osv):
self.create_send_note(cr, uid, [obj_id], context=context)
return obj_id
def on_change_opt_in(self, cr, uid, ids, opt_in):
return {'value':{'opt_in':opt_in,'opt_out':False}}
def on_change_opt_out(self, cr, uid, ids, opt_out):
return {'value':{'opt_out':opt_out,'opt_in':False}}
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
if not stage_id:
return {'value':{}}
+2 -4
View File
@@ -204,8 +204,7 @@
<field name="state" groups="base.group_no_one"/>
</group>
<group string="Mailings">
<field name="opt_in" on_change="on_change_opt_in(opt_in)"/>
<field name="opt_out" on_change="on_change_opt_out(opt_out)"/>
<field name="opt_out" />
</group>
</group>
</page>
@@ -543,8 +542,7 @@
<field name="channel_id" widget="selection"/>
</group>
<group string="Mailings">
<field name="opt_in" on_change="on_change_opt_in(opt_in)"/>
<field name="opt_out" on_change="on_change_opt_out(opt_out)"/>
<field name="opt_out" />
</group>
<group string="Misc">
<field name="active"/>
+1 -1
View File
@@ -129,7 +129,7 @@
<button type="action"
string="Schedule a Meeting"
name="%(base_calendar.action_crm_meeting)d"
context="{'search_default_partner_ids': active_id}"/>
context="{'search_default_partner_ids': active_id, 'default_partner_ids' : [active_id]}"/>
<button type="action" string="Schedule a Call"
name="%(crm.crm_case_categ_phone_create_partner)d"
context="{'search_default_partner_id': active_id, 'default_duration': 1.0}" />
-1
View File
@@ -7,7 +7,6 @@
type: opportunity
stage_id: crm.stage_lead1
state: draft
opt_in: True
-
I create lead record to call Mailing opt-out onchange method.
-
+3 -3
View File
@@ -226,7 +226,7 @@
<field name="arch" type="xml">
<field name="company_id" position="before">
<field name="weight"/>
<field name="weight_net"/>
<field name="weight_net" groups="base.group_no_one"/>
</field>
</field>
</record>
@@ -251,7 +251,7 @@
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
<field name="weight"/>
<field name="weight_net"/>
<field name="weight_net" groups="base.group_no_one"/>
</xpath>
</field>
</record>
@@ -264,7 +264,7 @@
<field name="arch" type="xml">
<xpath expr="//group[@name='main_grp']" position="inside">
<field name="weight"/>
<field name="weight_net"/>
<field name="weight_net" groups="base.group_no_one"/>
</xpath>
</field>
</record>
@@ -90,32 +90,28 @@ class account_analytic_line(osv.osv):
context2 = context.copy()
context2['lang'] = partner.lang
cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id " \
cr.execute("SELECT product_id, to_invoice, sum(unit_amount), product_uom_id, name " \
"FROM account_analytic_line as line " \
"WHERE account_id = %s " \
"AND id IN %s AND to_invoice IS NOT NULL " \
"GROUP BY product_id,to_invoice,product_uom_id", (account.id, tuple(ids),))
"GROUP BY product_id, to_invoice, product_uom_id, name", (account.id, tuple(ids),))
for product_id, factor_id, qty, uom in cr.fetchall():
product = product_obj.browse(cr, uid, product_id, context2)
for product_id, factor_id, qty, uom, line_name in cr.fetchall():
if data.get('product'):
product_id = data['product'][0]
product = product_obj.browse(cr, uid, product_id, context=context2)
if not product:
raise osv.except_osv(_('Error'), _('At least one line has no product !'))
factor_name = ''
factor = invoice_factor_obj.browse(cr, uid, factor_id, context2)
if not data.get('product', False):
if factor.customer_name:
factor_name = product.name+' - '+factor.customer_name
else:
factor_name = product.name
else:
data['product'] = data['product'][0]
factor_name = product_obj.name_get(cr, uid, [data['product']], context=context)[0][1]
raise osv.except_osv(_('Error'), _('There is no product defined for the line %s. Please select one or force the product through the wizard.') % (line_name))
factor = invoice_factor_obj.browse(cr, uid, factor_id, context=context2)
factor_name = product_obj.name_get(cr, uid, [product_id], context=context2)[0][1]
if factor.customer_name:
factor_name += ' - ' + factor.customer_name
ctx = context.copy()
ctx.update({'uom':uom})
if account.pricelist_id:
pl = account.pricelist_id.id
price = pro_price_obj.price_get(cr,uid,[pl], data.get('product', False) or product_id, qty or 1.0, account.partner_id.id, context=ctx)[pl]
price = pro_price_obj.price_get(cr,uid,[pl], product_id, qty or 1.0, account.partner_id.id, context=ctx)[pl]
else:
price = 0.0
@@ -131,7 +127,7 @@ class account_analytic_line(osv.osv):
'invoice_line_tax_id': [(6,0,tax )],
'invoice_id': last_invoice,
'name': factor_name,
'product_id': data.get('product',product_id),
'product_id': product_id,
'invoice_line_tax_id': [(6,0,tax)],
'uos_id': uom,
'account_id': account_id,
@@ -179,7 +175,7 @@ class hr_timesheet_invoice_create(osv.osv_memory):
'time': fields.boolean('Time spent', help='The time of each work done will be displayed on the invoice'),
'name': fields.boolean('Description', help='The detail of each work done will be displayed on the invoice'),
'price': fields.boolean('Cost', help='The cost of each work done will be displayed on the invoice. You probably don\'t want to check this'),
'product': fields.many2one('product.product', 'Product', help='Fill this field only if you want to force to use a specific product. Keep empty to use the real product that comes from the cost.'),
'product': fields.many2one('product.product', 'Force Product', help='Fill this field only if you want to force to use a specific product. Keep empty to use the real product that comes from the cost.'),
}
_defaults = {
+51 -103
View File
@@ -20,22 +20,31 @@
##############################################################################
import time
from report import report_sxw
from report_webkit import webkit_report
from report_webkit import report_helper
from osv import osv
from tools import mod10r
import sys
import os
import re
from mako.template import Template
from mako.lookup import TemplateLookup
from mako import exceptions
from report import report_sxw
from report_webkit import webkit_report
from report_webkit import report_helper
from osv import osv
from osv.osv import except_osv
from tools import mod10r
from tools.translate import _
from tools.config import config
import wizard
import addons
import pooler
from tools.config import config
from mako.template import Template
from mako import exceptions
from tools.translate import _
from osv.osv import except_osv
class l10n_ch_report_webkit_html(report_sxw.rml_parse):
@@ -143,53 +152,26 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse):
'digits!\nPlease check your company '
'information for the invoice:\n%s') %(invoice_name)))
return ''
def mako_template(text):
"""Build a Mako template.
This template uses UTF-8 encoding
"""
tmp_lookup = TemplateLookup() #we need it in order to allow inclusion and inheritance
return Template(text, input_encoding='utf-8', output_encoding='utf-8', lookup=tmp_lookup)
class BVRWebKitParser(webkit_report.WebKitParser):
def setLang(self, lang):
if not lang:
lang = 'en_US'
self.localcontext['lang'] = lang
def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False):
"""format using the know cursor, language from localcontext"""
if digits is None:
digits = self.parser_instance.get_digits(value)
if isinstance(value, (str, unicode)) and not value:
return ''
pool_lang = self.pool.get('res.lang')
lang = self.localcontext['lang']
lang_ids = pool_lang.search(self.parser_instance.cr, self.parser_instance.uid, [('code','=',lang)])[0]
lang_obj = pool_lang.browse(self.parser_instance.cr, self.parser_instance.uid, lang_ids)
if date or date_time:
if not str(value):
return ''
date_format = lang_obj.date_format
parse_format = '%Y-%m-%d'
if date_time:
value=value.split('.')[0]
date_format = date_format + " " + lang_obj.time_format
parse_format = '%Y-%m-%d %H:%M:%S'
if not isinstance(value, time.struct_time):
return time.strftime(date_format, time.strptime(value, parse_format))
else:
date = datetime(*value.timetuple()[:6])
return date.strftime(date_format)
return lang_obj.format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary)
def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None):
"""generate the PDF"""
self.parser_instance = self.parser(
cursor,
context = context or {}
if report_xml.report_type != 'webkit':
return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
self.parser_instance = self.parser(cursor,
uid,
self.name2,
context=context
)
context=context)
self.pool = pooler.get_pool(cursor.dbname)
objs = self.getObjects(cursor, uid, ids, context)
self.parser_instance.set_context(objs, data, ids, report_xml.report_type)
@@ -201,7 +183,7 @@ class BVRWebKitParser(webkit_report.WebKitParser):
if not template and report_xml.report_webkit_data :
template = report_xml.report_webkit_data
if not template :
raise except_osv(_('Webkit Report template not found !'), _(''))
raise except_osv(_('Error'),_('Webkit Report template not found !'))
header = report_xml.webkit_header.html
footer = report_xml.webkit_header.footer_html
if not header and report_xml.header:
@@ -210,43 +192,19 @@ class BVRWebKitParser(webkit_report.WebKitParser):
_('Please set a header in company settings')
)
if not report_xml.header :
#I know it could be cleaner ...
header = u"""
<html>
<head>
<style type="text/css">
${css}
</style>
<script>
function subst() {
var vars={};
var x=document.location.search.substring(1).split('&');
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
for(var i in x) {
var y = document.getElementsByClassName(x[i]);
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
}
}
</script>
</head>
<body style="border:0; margin: 0;" onload="subst()">
</body>
</html>"""
self.parser_instance.localcontext.update({'setLang':self.setLang})
self.parser_instance.localcontext.update({'formatLang':self.formatLang})
header = ''
default_head = addons.get_module_resource('report_webkit', 'default_header.html')
with open(default_head,'r') as f:
header = f.read()
css = report_xml.webkit_header.css
if not css :
css = ''
user = self.pool.get('res.users').browse(cursor, uid, uid)
company = user.company_id
parse_template = template
#default_filters=['unicode', 'entity'] can be used to set global filter
body_mako_tpl = Template(parse_template ,input_encoding='utf-8', output_encoding='utf-8')
body_mako_tpl = mako_template(template)
#BVR specific
bvr_path = addons.get_module_resource(os.path.join('l10n_ch','report','bvr.mako'))
body_bvr_tpl = Template(file(bvr_path).read(), input_encoding='utf-8', output_encoding='utf-8')
body_bvr_tpl = mako_template(file(bvr_path).read())
helper = report_helper.WebKitHelper(cursor, uid, report_xml.id, context)
##BVR Specific
htmls = []
@@ -254,58 +212,48 @@ class BVRWebKitParser(webkit_report.WebKitParser):
self.parser_instance.localcontext['objects'] = [obj]
if not company.bvr_only:
try:
html = body_mako_tpl.render(
helper=helper,
html = body_mako_tpl.render(helper=helper,
css=css,
_=self.translate_call,
**self.parser_instance.localcontext
)
**self.parser_instance.localcontext)
except Exception, e:
raise Exception(exceptions.text_error_template().render())
htmls.append(html)
if not company.invoice_only:
try:
bvr = body_bvr_tpl.render(
helper=helper,
css=css,
_=self.translate_call,
**self.parser_instance.localcontext
)
bvr = body_bvr_tpl.render(helper=helper,
css=css,
_=self.translate_call,
**self.parser_instance.localcontext)
except Exception, e:
raise Exception(exceptions.text_error_template().render())
htmls.append(bvr)
head_mako_tpl = Template(header, input_encoding='utf-8', output_encoding='utf-8')
try:
head = head_mako_tpl.render(
helper=helper,
head = head_mako_tpl.render(helper=helper,
css=css,
_debug=False,
_=self.translate_call,
**self.parser_instance.localcontext
)
**self.parser_instance.localcontext)
except Exception, e:
raise Exception(exceptions.text_error_template().render())
foot = False
if footer and company.invoice_only :
foot_mako_tpl = Template(footer, input_encoding='utf-8', output_encoding='utf-8')
try:
foot = foot_mako_tpl.render(
helper=helper,
foot = foot_mako_tpl.render(helper=helper,
css=css,
_=self.translate_call,
**self.parser_instance.localcontext
)
**self.parser_instance.localcontext)
except Exception, e:
raise Exception(exceptions.text_error_template().render())
if report_xml.webkit_debug :
try:
deb = head_mako_tpl.render(
helper=helper,
deb = head_mako_tpl.render(helper=helper,
css=css,
_debug=html,
_=self.translate_call,
**self.parser_instance.localcontext
)
**self.parser_instance.localcontext)
except Exception, e:
raise Exception(exceptions.text_error_template().render())
return (deb, 'html')
+1 -2
View File
@@ -81,8 +81,7 @@
<field name="arch" type="xml">
<search string="Messages Search">
<field name="user_id"/>
<field name="body"/>
<field name="subject" filter_domain="['|', ('subject', 'ilike', self), ('record_name', 'ilike', self)]" />
<field name="subject" string="Content" filter_domain="['|', ('subject', 'ilike', self), ('body', 'ilike', self)]" />
<field name="type"/>
<filter icon="terp-personal+" string="My Feeds"
name="my_feeds" help="My Feeds"
+4
View File
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!-- This will set the unit of measure used in projects and tasks.-->
<record id="base.main_company" model="res.company">
<field name="project_time_mode_id" ref="product.uom_hour"></field>
</record>
<!-- Requests Links -->
<record id="req_link_project" model="res.request.link">
-3
View File
@@ -274,9 +274,6 @@
<!--
Resource: project.project
-->
<record id="base.main_company" model="res.company">
<field name="project_time_mode_id" ref="product.uom_hour"></field>
</record>
<!-- Projects -->
<!-- <record id="all_projects_account" model="project.project">
+8 -2
View File
@@ -98,9 +98,15 @@ class stock_partial_picking(osv.osv_memory):
if context is None: context = {}
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
picking_ids = context.get('active_ids', [])
if context['active_model'] == 'purchase.order':
active_model = context.get('active_model')
if active_model == 'purchase.order':
for purchase_order in self.pool.get('purchase.order').browse(cr, uid, picking_ids, context=context):
picking_ids = [picking_id.id for picking_id in purchase_order.picking_ids]
elif active_model == 'sale.order':
for sale_order in self.pool.get('sale.order').browse(cr, uid, picking_ids, context=context):
picking_ids = [picking.id for picking in sale_order.picking_ids]
if not picking_ids or len(picking_ids) != 1:
# Partial Picking Processing may only be done for one picking at a time
return res
@@ -108,7 +114,7 @@ class stock_partial_picking(osv.osv_memory):
# (already seen in previous bug where context passed was containing ir.ui.menu as active_model and the menu
# ID as active_id). Though this should be fixed in clients now, this place is sensitive enough to ensure the
# consistancy of the context.
assert context.get('active_model') in ('stock.picking', 'stock.picking.in', 'stock.picking.out', 'purchase.order'), 'Bad context propagation'
assert active_model in ('stock.picking', 'stock.picking.in', 'stock.picking.out', 'purchase.order', 'sale.order'), 'Bad context propagation'
picking_id, = picking_ids
if 'picking_id' in fields:
res.update(picking_id=picking_id)