[MERGE] forward port branch saas-15 up to 1f1fa35c07

This commit is contained in:
Christophe Simonis
2019-03-04 15:49:35 +01:00
12 changed files with 61 additions and 17 deletions
+4 -4
View File
@@ -654,12 +654,12 @@ class AccountInvoice(models.Model):
msg = _('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.')
raise RedirectWarning(msg, action.id, _('Go to the configuration panel'))
if type in ('out_invoice', 'out_refund'):
account_id = rec_account.id
payment_term_id = p.property_payment_term_id.id
else:
if type in ('in_invoice', 'in_refund'):
account_id = pay_account.id
payment_term_id = p.property_supplier_payment_term_id.id
else:
account_id = rec_account.id
payment_term_id = p.property_payment_term_id.id
delivery_partner_id = self.get_delivery_partner_id()
fiscal_position = self.env['account.fiscal.position'].get_fiscal_position(self.partner_id.id, delivery_id=delivery_partner_id)
@@ -10,7 +10,7 @@ class GamificationBadgeUserWizard(models.TransientModel):
employee_id = fields.Many2one('hr.employee', string='Employee', required=True)
user_id = fields.Many2one('res.users', string='User',
related='employee_id.user_id', store=True, readonly=True)
related='employee_id.user_id', store=True, readonly=True, compute_sudo=True)
# TODO 12.0/master remove this hack by changing the model
@api.model
+1 -1
View File
@@ -174,7 +174,7 @@ class Holidays(models.Model):
payslip_status = fields.Boolean('Reported in last payslips',
help='Green this button when the leave has been taken into account in the payslip.')
report_note = fields.Text('HR Comments')
user_id = fields.Many2one('res.users', string='User', related='employee_id.user_id', related_sudo=True, store=True, default=lambda self: self.env.uid, readonly=True)
user_id = fields.Many2one('res.users', string='User', related='employee_id.user_id', related_sudo=True, compute_sudo=True, store=True, default=lambda self: self.env.uid, readonly=True)
date_from = fields.Datetime('Start Date', readonly=True, index=True, copy=False,
states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]}, track_visibility='onchange')
date_to = fields.Datetime('End Date', readonly=True, copy=False,
@@ -1477,6 +1477,8 @@ td {
body {
margin: 0;
color: white !important;
/* avoid black background if backgrounds are printed */
background: initial;
}
.oe_leftbar,
.oe_loading,
+14 -8
View File
@@ -14,11 +14,17 @@ class ResPartner(models.Model):
sale_warn_msg = fields.Text('Message for Sales Order')
def _compute_sale_order_count(self):
sale_data = self.env['sale.order'].read_group(domain=[('partner_id', 'child_of', self.ids)],
fields=['partner_id'], groupby=['partner_id'])
mapped_data = dict([(m['partner_id'][0], m['partner_id_count']) for m in sale_data])
for partner in self:
# let's obtain the partner id and all its child ids
partner_ids = [partner.id] + partner.child_ids.ids
# then we can sum for all the partner's child
partner.sale_order_count = sum(mapped_data.get(child, 0) for child in partner_ids)
# retrieve all children partners and prefetch 'parent_id' on them
all_partners = self.search([('id', 'child_of', self.ids)])
all_partners.read(['parent_id'])
sale_order_groups = self.env['sale.order'].read_group(
domain=[('partner_id', 'in', all_partners.ids)],
fields=['partner_id'], groupby=['partner_id']
)
for group in sale_order_groups:
partner = self.browse(group['partner_id'][0])
while partner:
if partner in self:
partner.sale_order_count += group['partner_id_count']
partner = partner.parent_id
@@ -194,7 +194,7 @@ var FieldMany2One = AbstractField.extend({
_bindAutoComplete: function () {
var self = this;
// avoid ignoring autocomplete="off" by obfuscating placeholder, see #30439
if (this.$input.attr('placeholder')) {
if ($.browser.chrome && this.$input.attr('placeholder')) {
this.$input.attr('placeholder', function (index, val) {
return val.split('').join('\ufeff');
});
+1
View File
@@ -22,6 +22,7 @@ Quentin Lavallée-Bourdeau quentin.lavallee@savoirfairelinux.com https://github.
Rim Ben Dhaou rim.bendhaou@savoirfairelinux.com https://github.com/rimbendhaou
Yasmine El Mrini yasmine.elmrini@savoirfairelinux.com https://github.com/yasmineelmrini
Luis Garcia Ruiz luis.garcia@savoirfairelinux.com https://github.com/eilst
Dimitar Apostolov dimitar.apostolov@savoirfairelinux.com https://github.com/dapostolov-sfl
Jérome Boisvert-Chouinard jerome.boisvertchouinard@savoirfairelinux.com https://github.com/jbchouinard (up to 2017-10-17)
Julie Moussu julie.mousse@savoirfairelinux.com https://github.com/JulieSFL (up to 2017-10-17)
Pierre Lamarche pierre.lamarche@savoirfairelinux.com https://github.com/plamarche (up to 2017-10-17)
+3 -1
View File
@@ -31,6 +31,8 @@ try:
except ImportError:
astor = None
from odoo.tools.parse_version import parse_version
unsafe_eval = eval
_logger = logging.getLogger(__name__)
@@ -176,7 +178,7 @@ class QWebException(Exception):
return str(self)
# Avoid DeprecationWarning while still remaining compatible with werkzeug pre-0.9
escape = (lambda text: _escape(text, quote=True)) if getattr(werkzeug, '__version__', '0.0') < '0.9.0' else _escape
escape = (lambda text: _escape(text, quote=True)) if parse_version(getattr(werkzeug, '__version__', '0.0')) < parse_version('0.9.0') else _escape
def foreach_iterator(base_ctx, enum, name):
ctx = base_ctx.copy()
+2
View File
@@ -96,6 +96,8 @@ class IrRule(models.Model):
group_domains.append(dom)
# combine global domains and group domains
if not group_domains:
return expression.AND(global_domains)
return expression.AND(global_domains + [expression.OR(group_domains)])
@api.model
+30
View File
@@ -611,6 +611,36 @@ class TestExpression(TransactionCase):
not_be = Partner.with_context(lang='fr_FR').search([('country_id', '!=', 'Belgique')])
self.assertNotIn(agrolait, not_be)
def test_proper_combine_unit_leaves(self):
# test that unit leaves (TRUE_LEAF, FALSE_LEAF) are properly handled in specific cases
false = expression.FALSE_DOMAIN
true = expression.TRUE_DOMAIN
normal = [('foo', '=', 'bar')]
# OR with single FALSE_LEAF
expr = expression.OR([false])
self.assertEqual(expr, false)
# OR with multiple FALSE_LEAF
expr = expression.OR([false, false])
self.assertEqual(expr, false)
# OR with FALSE_LEAF and a normal leaf
expr = expression.OR([false, normal])
self.assertEqual(expr, normal)
# OR with AND of single TRUE_LEAF and normal leaf
expr = expression.OR([expression.AND([true]), normal])
self.assertEqual(expr, true)
# AND with single TRUE_LEAF
expr = expression.AND([true])
self.assertEqual(expr, true)
# AND with multiple TRUE_LEAF
expr = expression.AND([true, true])
self.assertEqual(expr, true)
# AND with TRUE_LEAF and normal leaves
expr = expression.AND([true, normal])
self.assertEqual(expr, normal)
# AND with OR with single FALSE_LEAF and normal leaf
expr = expression.AND([expression.OR([false]), normal])
self.assertEqual(expr, false)
class TestAutoJoin(TransactionCase):
+1
View File
@@ -1038,6 +1038,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
except ValidationError as e:
raise
except Exception as e:
_logger.exception('Exception while validating constraint')
raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
@api.model
+1 -1
View File
@@ -258,7 +258,7 @@ def combine(operator, unit, zero, domains):
result += domain
count += 1
result = [operator] * (count - 1) + result
return result
return result or unit
def AND(domains):