Skip to content

Commit

Permalink
[MERGE] forward port of branch saas-5 up to 7e117b1
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Aug 28, 2014
2 parents 5e6e130 + 7e117b1 commit 8046b73
Show file tree
Hide file tree
Showing 29 changed files with 93 additions and 56 deletions.
16 changes: 8 additions & 8 deletions addons/account/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def onchange_journal_id(self, journal_id=False):
@api.multi
def onchange_payment_term_date_invoice(self, payment_term_id, date_invoice):
if not date_invoice:
date_invoice = fields.Date.today()
date_invoice = fields.Date.context_today(self)
if not payment_term_id:
# To make sure the invoice due date should contain due date which is
# entered by user when there is no payment term defined
Expand Down Expand Up @@ -729,7 +729,7 @@ def compute_invoice_totals(self, company_currency, ref, invoice_move_lines):
total_currency = 0
for line in invoice_move_lines:
if self.currency_id != company_currency:
currency = self.currency_id.with_context(date=self.date_invoice or fields.Date.today())
currency = self.currency_id.with_context(date=self.date_invoice or fields.Date.context_today(self))
line['currency_id'] = currency.id
line['amount_currency'] = line['price']
line['price'] = currency.compute(line['price'], company_currency)
Expand Down Expand Up @@ -892,7 +892,7 @@ def action_move_create(self):
'ref': inv.reference or inv.name,
'line_id': line,
'journal_id': journal.id,
'date': date,
'date': inv.date_invoice,
'narration': inv.comment,
'company_id': inv.company_id.id,
}
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def _prepare_refund(self, invoice, date=None, period_id=None, description=None,
values['journal_id'] = journal.id

values['type'] = TYPE2REFUND[invoice['type']]
values['date_invoice'] = date or fields.Date.today()
values['date_invoice'] = date or fields.Date.context_today(invoice)
values['state'] = 'draft'
values['number'] = False

Expand Down Expand Up @@ -1118,7 +1118,7 @@ def pay_and_reconcile(self, pay_amount, pay_account_id, period_id, pay_journal_i
SIGN = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
direction = SIGN[self.type]
# take the chosen date
date = self._context.get('date_p') or fields.Date.today()
date = self._context.get('date_p') or fields.Date.context_today(self)

# Take the amount in currency and the currency of the payment
if self._context.get('amount_currency') and self._context.get('currency_id'):
Expand Down Expand Up @@ -1506,7 +1506,7 @@ def base_change(self, base, currency_id=False, company_id=False, date_invoice=Fa
company = self.env['res.company'].browse(company_id)
if currency_id and company.currency_id:
currency = self.env['res.currency'].browse(currency_id)
currency = currency.with_context(date=date_invoice or fields.Date.today())
currency = currency.with_context(date=date_invoice or fields.Date.context_today(self))
base = currency.compute(base * factor, company.currency_id, round=False)
return {'value': {'base_amount': base}}

Expand All @@ -1516,14 +1516,14 @@ def amount_change(self, amount, currency_id=False, company_id=False, date_invoic
company = self.env['res.company'].browse(company_id)
if currency_id and company.currency_id:
currency = self.env['res.currency'].browse(currency_id)
currency = currency.with_context(date=date_invoice or fields.Date.today())
currency = currency.with_context(date=date_invoice or fields.Date.context_today(self))
amount = currency.compute(amount * factor, company.currency_id, round=False)
return {'value': {'tax_amount': amount}}

@api.v8
def compute(self, invoice):
tax_grouped = {}
currency = invoice.currency_id.with_context(date=invoice.date_invoice or fields.Date.today())
currency = invoice.currency_id.with_context(date=invoice.date_invoice or fields.Date.context_today(invoice))
company_currency = invoice.company_id.currency_id
for line in invoice.invoice_line:
taxes = line.invoice_line_tax_id.compute_all(
Expand Down
2 changes: 1 addition & 1 deletion addons/auth_ldap/users_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class res_company(osv.osv):
_inherit = "res.company"
_columns = {
'ldaps': fields.one2many(
'res.company.ldap', 'company', 'LDAP Parameters', copy=True),
'res.company.ldap', 'company', 'LDAP Parameters', copy=True, groups="base.group_system"),
}


Expand Down
8 changes: 4 additions & 4 deletions addons/base_gengo/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class res_company(osv.Model):
_name = "res.company"
_inherit = "res.company"
_columns = {
"gengo_private_key": fields.text("Gengo Private Key", copy=False),
"gengo_public_key": fields.text("Gengo Public Key", copy=False),
"gengo_comment": fields.text("Comments", help="This comment will be automatically be enclosed in each an every request sent to Gengo"),
"gengo_auto_approve": fields.boolean("Auto Approve Translation ?", help="Jobs are Automatically Approved by Gengo."),
"gengo_private_key": fields.text("Gengo Private Key", copy=False, groups="base.group_system"),
"gengo_public_key": fields.text("Gengo Public Key", copy=False, groups="base.group_user"),
"gengo_comment": fields.text("Comments", help="This comment will be automatically be enclosed in each an every request sent to Gengo", groups="base.group_user"),
"gengo_auto_approve": fields.boolean("Auto Approve Translation ?", help="Jobs are Automatically Approved by Gengo.", groups="base.group_user"),
"gengo_sandbox": fields.boolean("Sandbox Mode", help="Check this box if you're using the sandbox mode of Gengo, mainly used for testing purpose."),
}

Expand Down
2 changes: 1 addition & 1 deletion addons/board/static/src/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ instance.web.SearchViewDrawer.include({
add_common_inputs: function() {
this._super();
var vm = this.getParent().getParent();
if (vm.inner_action && vm.inner_action.views) {
if (vm.inner_action && vm.inner_action.id && vm.inner_action.views) {
(new instance.board.AddToDashboard(this));
}
}
Expand Down
3 changes: 2 additions & 1 deletion addons/delivery/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ def _prepare_shipping_invoice_line(self, cr, uid, picking, invoice, context=None
_('The carrier %s (id: %d) has no delivery grid!') \
% (picking.carrier_id.name,
picking.carrier_id.id))
quantity = sum([line.product_uom_qty for line in picking.move_lines])
price = grid_obj.get_price_from_picking(cr, uid, grid_id,
invoice.amount_untaxed, picking.weight, picking.volume,
context=context)
quantity, context=context)
account_id = picking.carrier_id.product_id.property_account_income.id
if not account_id:
account_id = picking.carrier_id.product_id.categ_id\
Expand Down
2 changes: 1 addition & 1 deletion addons/email_template/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_email_template,email.template,model_email_template,,1,1,1,0
access_email_template,email.template,model_email_template,base.group_user,1,1,1,0
access_email_template_system,email.template system,model_email_template,base.group_system,1,1,1,1
2 changes: 1 addition & 1 deletion addons/email_template/wizard/mail_compose_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def default_get(self, cr, uid, fields, context=None):
return res

_columns = {
'template_id': fields.many2one('email.template', 'Use template', select=True),
'template_id': fields.many2one('email.template', 'Use template', select=True, groups="base.group_user"),
}

def send_mail(self, cr, uid, ids, context=None):
Expand Down
1 change: 1 addition & 0 deletions addons/email_template/wizard/mail_compose_message_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<field name="name">mail.compose.message.form</field>
<field name="model">mail.compose.message</field>
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
<field name="groups_id" eval="[(4,ref('base.group_user'))]"/>
<field name="arch" type="xml">
<xpath expr="//footer" position="inside">
<group class="oe_right oe_form" col="1">
Expand Down
2 changes: 1 addition & 1 deletion addons/fetchmail/fetchmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ def fetch_mail(self, cr, uid, ids, context=None):
save_original=server.original,
strip_attachments=(not server.attach),
context=context)
pop_server.dele(num)
except Exception:
_logger.exception('Failed to process mail from %s server %s.', server.type, server.name)
failed += 1
if res_id and server.action_id:
action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids': [res_id], 'active_model': context.get("thread_model", server.object_id.model)})
pop_server.dele(num)
cr.commit()
_logger.info("Fetched %d email(s) on %s server %s; %d succeeded, %d failed.", numMsgs, server.type, server.name, (numMsgs - failed), failed)
except Exception:
Expand Down
10 changes: 8 additions & 2 deletions addons/hr_holidays/hr_holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,14 @@ def create(self, cr, uid, values, context=None):
if context is None:
context = {}
context = dict(context, mail_create_nolog=True)
hol_id = super(hr_holidays, self).create(cr, uid, values, context=context)
return hol_id
if values.get('state') and values['state'] not in ['draft', 'confirm', 'cancel'] and not self.pool['res.users'].has_group(cr, uid, 'base.group_hr_user'):
raise osv.except_osv(_('Warning!'), _('You cannot set a leave request as \'%s\'. Contact a human resource manager.') % values.get('state'))
return super(hr_holidays, self).create(cr, uid, values, context=context)

def write(self, cr, uid, ids, vals, context=None):
if vals.get('state') and vals['state'] not in ['draft', 'confirm', 'cancel'] and not self.pool['res.users'].has_group(cr, uid, 'base.group_hr_user'):
raise osv.except_osv(_('Warning!'), _('You cannot set a leave request as \'%s\'. Contact a human resource manager.') % vals.get('state'))
return super(hr_holidays, self).write(cr, uid, ids, vals, context=context)

def holidays_reset(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {
Expand Down
11 changes: 11 additions & 0 deletions addons/hr_holidays/security/ir_rule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
<field name="name">Employee Holidays</field>
<field name="model_id" ref="model_hr_holidays"/>
<field name="domain_force">[('employee_id.user_id','=',user.id)]</field>
<field name="perm_create" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_unlink" eval="False"/>
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
</record>

<record id="property_rule_holidays_employee_write" model="ir.rule">
<field name="name">Employee Holidays Create, Write, Unlink</field>
<field model="ir.model" name="model_id" ref="model_hr_holidays"/>
<field name="domain_force">[('employee_id.user_id','=',user.id), ('state', 'in', ['draft', 'confirm', 'cancel'])]</field>
<field name="perm_read" eval="False"/>
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
</record>

Expand Down
2 changes: 1 addition & 1 deletion addons/hw_escpos/escpos/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, idVendor, idProduct, interface=0, in_ep=0x82, out_ep=0x01):
self.interface = interface
self.in_ep = in_ep
self.out_ep = out_ep
self.open()
self.open()


def open(self):
Expand Down
2 changes: 1 addition & 1 deletion addons/mail/mail_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class mail_alias(osv.Model):

def _get_alias_domain(self, cr, uid, ids, name, args, context=None):
ir_config_parameter = self.pool.get("ir.config_parameter")
domain = ir_config_parameter.get_param(cr, uid, "mail.catchall.domain", context=context)
domain = ir_config_parameter.get_param(cr, SUPERUSER_ID, "mail.catchall.domain", context=context)
return dict.fromkeys(ids, domain or "")

_columns = {
Expand Down
2 changes: 2 additions & 0 deletions addons/mail/static/src/js/announcement.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ openerp_announcement = function(instance) {

$('.openerp_webclient_container').css('height', 'calc(100% - 64px)');
$('head').append($css);
}).fail(function(result, ev){
ev.preventDefault();
});
}
});
Expand Down
3 changes: 2 additions & 1 deletion addons/pad/pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import string
import urllib2
import logging
from openerp import SUPERUSER_ID
from openerp.tools.translate import _
from openerp.tools import html2plaintext
from py_etherpad import EtherpadLiteClient
Expand All @@ -19,7 +20,7 @@ def pad_is_configured(self, cr, uid, context=None):
return bool(user.company_id.pad_server)

def pad_generate_url(self, cr, uid, context=None):
company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id;
company = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context).company_id

pad = {
"server" : company.pad_server,
Expand Down
2 changes: 1 addition & 1 deletion addons/pad/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class company_pad(osv.osv):
_inherit = 'res.company'
_columns = {
'pad_server': fields.char('Pad Server', help="Etherpad lite server. Example: beta.primarypad.com"),
'pad_key': fields.char('Pad Api Key', help="Etherpad lite api key."),
'pad_key': fields.char('Pad Api Key', help="Etherpad lite api key.", groups="base.group_system"),
}


Expand Down
2 changes: 1 addition & 1 deletion addons/point_of_sale/point_of_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def add_payment(self, cr, uid, order_id, data, context=None):
'amount': data['amount'],
'date': data.get('payment_date', time.strftime('%Y-%m-%d')),
'name': order.name + ': ' + (data.get('payment_name', '') or ''),
'partner_id': order.partner_id and order.partner_id.id or None,
'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False,
}
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
args['account_id'] = (order.partner_id and order.partner_id.property_account_receivable \
Expand Down
4 changes: 3 additions & 1 deletion addons/product_visible_discount/product_visible_discount.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ def get_real_price(res_dict, product_id, qty, uom, pricelist):
if so_pricelist.visible_discount and list_price[pricelist] != 0 and new_list_price != 0:
if product.company_id and so_pricelist.currency_id.id != product.company_id.currency_id.id:
# new_list_price is in company's currency while price in pricelist currency
ctx = context.copy()
ctx['date'] = date_order
new_list_price = self.pool['res.currency'].compute(cr, uid,
product.company_id.currency_id.id, so_pricelist.currency_id.id,
new_list_price, context=context)
new_list_price, context=ctx)
discount = (new_list_price - price) / new_list_price * 100
if discount > 0:
result['price_unit'] = new_list_price
Expand Down
2 changes: 1 addition & 1 deletion addons/resource/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_resource_calendar,resource.calendar,model_resource_calendar,base.group_system,1,1,1,1
access_resource_calendar_attendance,resource.calendar.attendance,model_resource_calendar_attendance,base.group_system,1,1,1,1
access_resource_resource,resource.resource,model_resource_resource,base.group_system,1,0,0,0
access_resource_resource_all,resource.resource all,model_resource_resource,,1,0,0,0
access_resource_resource_all,resource.resource all,model_resource_resource,base.group_user,1,0,0,0
access_resource_calendar_leaves_user,resource.calendar.leaves,model_resource_calendar_leaves,base.group_user,1,0,0,0
access_resource_calendar_leaves,resource.calendar.leaves,model_resource_calendar_leaves,base.group_system,1,1,1,1
2 changes: 2 additions & 0 deletions addons/sale/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,8 @@ def create(self, cr, uid, values, context=None):
flag=False, # Force name update
context=context
)['value']
if defaults.get('tax_id'):
defaults['tax_id'] = [[6, 0, defaults['tax_id']]]
values = dict(defaults, **values)
return super(sale_order_line, self).create(cr, uid, values, context=context)

Expand Down
6 changes: 5 additions & 1 deletion addons/sale_margin/sale_margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
if not pricelist:
return res
if context is None:
context = {}
frm_cur = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
to_cur = self.pool.get('product.pricelist').browse(cr, uid, [pricelist])[0].currency_id.id
if product:
purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price
price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False)
ctx = context.copy()
ctx['date'] = date_order
price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False, context=ctx)
res['value'].update({'purchase_price': price})
return res

Expand Down
8 changes: 4 additions & 4 deletions addons/stock/stock_incoterms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
</record>
<record id="incoterm_DAT" model="stock.incoterms">
<field name="code">DAT</field>
<field name="name">Delivered At Terminal</field>
<field name="name">DELIVERED AT TERMINAL</field>
</record>
<record id="incoterm_DAP" model="stock.incoterms">
<field name="code">DAP</field>
<field name="name">Delivered At Place</field>
<field name="name">DELIVERED AT PLACE</field>
</record>
<record id="incoterm_DDP" model="stock.incoterms">
<record id="incoterm_DDP" model="stock.incoterms">
<field name="code">DDP</field>
<field name="name">Delivered Duty Paid</field>
<field name="name">DELIVERED DUTY PAID</field>
</record>

</data>
Expand Down
2 changes: 1 addition & 1 deletion addons/stock/stock_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@
<xpath expr="//group[@name='propagation_group']" position="before">
<group attrs="{'invisible': [('action', '!=', 'move')]}" string="Moving Options">
<field name="procure_method" groups="stock.group_adv_location"/>
<field name="location_src_id" attrs="{'required': [('action', '=', 'move')]}"/>
<field name="location_src_id" attrs="{'required': [('action', '=', 'move')]}" domain="[('usage','!=','view')]" />
<field name="partner_address_id" groups="stock.group_adv_location" context="{'show_address': 1}" options="{'always_reload': 1}"/>
<label for="delay" string="Delay" groups="stock.group_adv_location"/>
<div groups="stock.group_adv_location">
Expand Down
3 changes: 3 additions & 0 deletions addons/web/static/src/js/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,9 @@ instance.web.UserMenu = instance.web.Widget.extend({
scope: 'userinfo',
};
instance.web.redirect('https://accounts.odoo.com/oauth2/auth?'+$.param(params));
}).fail(function(result, ev){
ev.preventDefault();
instance.web.redirect('https://accounts.openerp.com/web');
});
}
},
Expand Down
4 changes: 2 additions & 2 deletions addons/web/static/src/js/view_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -3660,10 +3660,10 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
focusout: anyoneLoosesFocus,
focus: function () { self.trigger('focused'); },
autocompleteopen: function () { ignore_blur = true; },
autocompleteclose: function () { ignore_blur = false; },
autocompleteclose: function () { setTimeout(function() {ignore_blur = false;},0); },
blur: function () {
// autocomplete open
if (ignore_blur) { return; }
if (ignore_blur) { $(this).focus(); return; }
if (_(self.getChildren()).any(function (child) {
return child instanceof instance.web.form.AbstractFormPopup;
})) { return; }
Expand Down
Loading

0 comments on commit 8046b73

Please sign in to comment.