[MERGE] forward port branch 10.0 up to 657e328903
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.osv import expression
|
||||
from odoo.tools import float_is_zero
|
||||
from odoo.tools import float_compare, float_round
|
||||
from odoo.tools import float_compare, float_round, float_repr
|
||||
from odoo.tools.misc import formatLang
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
@@ -591,7 +591,8 @@ class AccountBankStatementLine(models.Model):
|
||||
from_clause = "FROM account_move_line aml JOIN account_account acc ON acc.id = aml.account_id "
|
||||
where_clause = """WHERE aml.company_id = %(company_id)s
|
||||
AND (
|
||||
(aml.statement_id IS NULL AND aml.account_id IN %(account_payable_receivable)s)
|
||||
(aml.statement_id IS NULL AND aml.account_id IN %(account_payable_receivable)s
|
||||
AND aml.payment_id IS NOT NULL)
|
||||
OR
|
||||
("""+acc_type+""" AND aml.reconciled = false)
|
||||
)"""
|
||||
@@ -615,7 +616,7 @@ class AccountBankStatementLine(models.Model):
|
||||
precision = st_line_currency and st_line_currency.decimal_places or company_currency.decimal_places
|
||||
params = {'company_id': self.env.user.company_id.id,
|
||||
'account_payable_receivable': (self.journal_id.default_credit_account_id.id, self.journal_id.default_debit_account_id.id),
|
||||
'amount': float_round(amount, precision_digits=precision),
|
||||
'amount': float_repr(float_round(amount, precision_digits=precision), precision_digits=precision),
|
||||
'partner_id': self.partner_id.id,
|
||||
'excluded_ids': tuple(excluded_ids),
|
||||
'ref': self.name,
|
||||
@@ -636,9 +637,9 @@ class AccountBankStatementLine(models.Model):
|
||||
# Look for a single move line with the same amount
|
||||
field = currency and 'amount_residual_currency' or 'amount_residual'
|
||||
liquidity_field = currency and 'amount_currency' or amount > 0 and 'debit' or 'credit'
|
||||
liquidity_amt_clause = currency and '%(amount)s' or 'abs(%(amount)s)'
|
||||
liquidity_amt_clause = currency and '%(amount)s::numeric' or 'abs(%(amount)s::numeric)'
|
||||
sql_query = self._get_common_sql_query(excluded_ids=excluded_ids) + \
|
||||
" AND ("+field+" = %(amount)s OR (acc.internal_type = 'liquidity' AND "+liquidity_field+" = " + liquidity_amt_clause + ")) \
|
||||
" AND ("+field+" = %(amount)s::numeric OR (acc.internal_type = 'liquidity' AND "+liquidity_field+" = " + liquidity_amt_clause + ")) \
|
||||
ORDER BY date_maturity asc, aml.id asc LIMIT 1"
|
||||
self.env.cr.execute(sql_query, params)
|
||||
results = self.env.cr.fetchone()
|
||||
|
||||
@@ -454,7 +454,7 @@ class AccountInvoice(models.Model):
|
||||
@api.onchange('invoice_line_ids')
|
||||
def _onchange_invoice_line_ids(self):
|
||||
taxes_grouped = self.get_taxes_values()
|
||||
tax_lines = self.tax_line_ids.browse([])
|
||||
tax_lines = self.tax_line_ids.filtered('manual')
|
||||
for tax in taxes_grouped.values():
|
||||
tax_lines += tax_lines.new(tax)
|
||||
self.tax_line_ids = tax_lines
|
||||
|
||||
@@ -102,7 +102,7 @@ class AccountMove(models.Model):
|
||||
"""
|
||||
moves = self.search([('state', '=', 'posted'),
|
||||
('company_id', '=', company_id),
|
||||
('l10n_fr_secure_sequence_number', '!=', False)],
|
||||
('l10n_fr_secure_sequence_number', '!=', 0)],
|
||||
order="l10n_fr_secure_sequence_number ASC")
|
||||
|
||||
if not moves:
|
||||
|
||||
@@ -844,21 +844,14 @@ class PosOrderLine(models.Model):
|
||||
@api.depends('price_unit', 'tax_ids', 'qty', 'discount', 'product_id')
|
||||
def _compute_amount_line_all(self):
|
||||
for line in self:
|
||||
currency = line.order_id.pricelist_id.currency_id
|
||||
taxes = line.tax_ids.filtered(lambda tax: tax.company_id.id == line.order_id.company_id.id)
|
||||
fiscal_position_id = line.order_id.fiscal_position_id
|
||||
if fiscal_position_id:
|
||||
taxes = fiscal_position_id.map_tax(taxes, line.product_id, line.order_id.partner_id)
|
||||
price = self.env['account.tax']._fix_tax_included_price(
|
||||
line.price_unit * (1 - (line.discount or 0.0) / 100.0), line.product_id.taxes_id, taxes)
|
||||
line.price_subtotal = line.price_subtotal_incl = price * line.qty
|
||||
if taxes:
|
||||
taxes = taxes.compute_all(price, currency, line.qty, product=line.product_id, partner=line.order_id.partner_id or False)
|
||||
line.price_subtotal = taxes['total_excluded']
|
||||
line.price_subtotal_incl = taxes['total_included']
|
||||
|
||||
line.price_subtotal = currency.round(line.price_subtotal)
|
||||
line.price_subtotal_incl = currency.round(line.price_subtotal_incl)
|
||||
fpos = line.order_id.fiscal_position_id
|
||||
tax_ids_after_fiscal_position = fpos.map_tax(line.tax_ids, line.product_id, line.order_id.partner_id) if fpos else line.tax_ids
|
||||
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
||||
taxes = tax_ids_after_fiscal_position.compute_all(price, line.order_id.pricelist_id.currency_id, line.qty, product=line.product_id, partner=line.order_id.partner_id)
|
||||
line.update({
|
||||
'price_subtotal_incl': taxes['total_included'],
|
||||
'price_subtotal': taxes['total_excluded'],
|
||||
})
|
||||
|
||||
@api.onchange('product_id')
|
||||
def _onchange_product_id(self):
|
||||
@@ -870,8 +863,10 @@ class PosOrderLine(models.Model):
|
||||
price = self.order_id.pricelist_id.get_product_price(
|
||||
self.product_id, self.qty or 1.0, self.order_id.partner_id)
|
||||
self._onchange_qty()
|
||||
self.price_unit = price
|
||||
self.tax_ids = self.product_id.taxes_id
|
||||
self.tax_ids = self.product_id.taxes_id.filtered(lambda r: not self.company_id or r.company_id == self.company_id)
|
||||
fpos = self.order_id.fiscal_position_id
|
||||
tax_ids_after_fiscal_position = fpos.map_tax(self.tax_ids, line.product_id, line.order_id.partner_id) if fpos else self.tax_ids
|
||||
self.price_unit = self.env['account.tax']._fix_tax_included_price(price, self.product_id.taxes_id, tax_ids_after_fiscal_position)
|
||||
|
||||
@api.onchange('qty', 'discount', 'price_unit', 'tax_ids')
|
||||
def _onchange_qty(self):
|
||||
|
||||
@@ -20,7 +20,7 @@ class ProductTemplate(models.Model):
|
||||
if self._context.get('categ_id') or self._context.get('default_categ_id'):
|
||||
return self._context.get('categ_id') or self._context.get('default_categ_id')
|
||||
category = self.env.ref('product.product_category_all', raise_if_not_found=False)
|
||||
return category and category.id or False
|
||||
return category.id if category.type == 'normal' else False
|
||||
|
||||
def _get_default_uom_id(self):
|
||||
return self.env["product.uom"].search([], limit=1, order='id').id
|
||||
|
||||
@@ -1000,6 +1000,8 @@ class Binary(http.Controller):
|
||||
elif status != 200 and download:
|
||||
return request.not_found()
|
||||
|
||||
height = int(height)
|
||||
width = int(width)
|
||||
if content and (width or height):
|
||||
# resize maximum 500*500
|
||||
if width > 500:
|
||||
|
||||
@@ -15,7 +15,7 @@ class IrHttp(models.AbstractModel):
|
||||
context['editable'] = True
|
||||
if 'edit_translations' in request.httprequest.args and 'edit_translations' not in context:
|
||||
context['edit_translations'] = True
|
||||
if context.get('lang') != "en_US" and 'translatable' not in context:
|
||||
if context.get('edit_translations') and 'translatable' not in context:
|
||||
context['translatable'] = True
|
||||
request.context = context
|
||||
return super(IrHttp, cls)._dispatch()
|
||||
|
||||
@@ -48,7 +48,7 @@ class IrUiView(models.Model):
|
||||
|
||||
if value is not None:
|
||||
# TODO: batch writes?
|
||||
if self.get_default_lang_code() and field != 'arch' and not isinstance(Model._fields[field], fields.Html):
|
||||
if not self.env.context.get('lang') and self.get_default_lang_code():
|
||||
Model.browse(int(el.get('data-oe-id'))).with_context(lang=self.get_default_lang_code()).write({field: value})
|
||||
else:
|
||||
Model.browse(int(el.get('data-oe-id'))).write({field: value})
|
||||
|
||||
@@ -205,7 +205,7 @@ class Http(models.AbstractModel):
|
||||
path.pop(1)
|
||||
request.context = context
|
||||
return cls.reroute('/'.join(path) or '/')
|
||||
if path[1] == request.website.default_lang_code:
|
||||
if request.lang == request.website.default_lang_code:
|
||||
context['edit_translations'] = False
|
||||
if not context.get('tz'):
|
||||
context['tz'] = request.session.get('geoip', {}).get('time_zone')
|
||||
|
||||
@@ -174,6 +174,7 @@ class WebsiteBlog(http.Controller):
|
||||
v['blog'] = blog
|
||||
v['base_url'] = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
v['posts'] = request.env['blog.post'].search([('blog_id','=', blog.id)], limit=min(int(limit), 50))
|
||||
v['html2plaintext'] = html2plaintext
|
||||
r = request.render("website_blog.blog_feed", v, headers=[('Content-Type', 'application/atom+xml')])
|
||||
return r
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@
|
||||
<link t-att-href="'%s%s' % (base_url, post.website_url)"/>
|
||||
<id t-esc="'%s%s' % (base_url, post.website_url)"/>
|
||||
<author><name t-esc="post.sudo().author_id.name"/></author>
|
||||
<summary t-esc="post.subtitle"/>
|
||||
<summary t-esc="html2plaintext(post.teaser)"/>
|
||||
<updated t-esc="post.write_date.replace(' ', 'T') + 'Z'"/>
|
||||
</entry>
|
||||
</feed>
|
||||
|
||||
@@ -20,12 +20,6 @@ class website_form_model(models.Model):
|
||||
website_form_default_field_id = fields.Many2one('ir.model.fields', 'Field for custom form data', domain="[('model', '=', model), ('ttype', '=', 'text')]", help="Specify the field which will contain meta and custom form fields datas.")
|
||||
website_form_label = fields.Char("Label for form action", help="Form action label. Ex: crm.lead could be 'Send an e-mail' and project.issue could be 'Create an Issue'.")
|
||||
|
||||
def _all_inherited_model_ids(self):
|
||||
return list(itertools.chain(
|
||||
[self.id],
|
||||
*(m._all_inherited_model_ids() for m in self.inherited_model_ids)
|
||||
))
|
||||
|
||||
def _get_form_writable_fields(self):
|
||||
"""
|
||||
Restriction of "authorized fields" (fields which can be used in the
|
||||
@@ -33,16 +27,16 @@ class website_form_model(models.Model):
|
||||
builders and are writable. By default no field is writable by the
|
||||
form builder.
|
||||
"""
|
||||
excluded = {
|
||||
included = {
|
||||
field.name
|
||||
for field in self.env['ir.model.fields'].sudo().search([
|
||||
('model_id', 'in', self._all_inherited_model_ids()),
|
||||
('website_form_blacklisted', '=', True)
|
||||
('model_id', '=', self.id),
|
||||
('website_form_blacklisted', '=', False)
|
||||
])
|
||||
}
|
||||
return {
|
||||
k: v for k, v in self.get_authorized_fields(self.model).iteritems()
|
||||
if k not in excluded
|
||||
if k in included
|
||||
}
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -236,7 +236,7 @@ class website_account(website_account):
|
||||
partner = request.env['res.users'].browse(request.uid).partner_id
|
||||
invoices = request.env['account.invoice'].sudo().search_count([('partner_id', '=', partner.id), ('state', 'not in', ['draft', 'cancel'])])
|
||||
if invoices:
|
||||
if 'vat' in partner and (data['vat'] or False) != (partner.vat or False):
|
||||
if 'vat' in data and (data['vat'] or False) != (partner.vat or False):
|
||||
error['vat'] = 'error'
|
||||
error_message.append(_('Changing VAT number is not allowed once invoices have been issued for your account. Please contact us directly for this operation.'))
|
||||
if 'name' in data and (data['name'] or False) != (partner.name or False):
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
Switzerland, 30/06/2017
|
||||
|
||||
I hereby agree to the terms of the Odoo Individual Contributor License
|
||||
Agreement v1.0.
|
||||
|
||||
I declare that I am authorized and able to make this agreement and sign this
|
||||
declaration.
|
||||
|
||||
Signed,
|
||||
|
||||
Frederic Siffert frederic@treyvaud.ch https://github.com/leNeo
|
||||
@@ -526,3 +526,8 @@ class TestGroups(TransactionCase):
|
||||
# create a cycle and check
|
||||
a.implied_ids = d
|
||||
self.assertFalse(a._check_m2m_recursion('implied_ids'))
|
||||
|
||||
def test_res_group_copy(self):
|
||||
a = self.env['res.groups'].with_context(lang='en_US').create({'name': 'A'})
|
||||
b = a.copy()
|
||||
self.assertFalse(a.name == b.name)
|
||||
|
||||
+2
-1
@@ -4326,7 +4326,7 @@ class BaseModel(object):
|
||||
trans_name, source_id, target_id = get_trans(field, old, new)
|
||||
domain = [('name', '=', trans_name), ('res_id', '=', source_id)]
|
||||
new_val = new_wo_lang[name]
|
||||
if old.env.lang:
|
||||
if old.env.lang and callable(field.translate):
|
||||
# the new value *without lang* must be the old value without lang
|
||||
new_wo_lang[name] = old_wo_lang[name]
|
||||
for vals in Translation.search_read(domain):
|
||||
@@ -4335,6 +4335,7 @@ class BaseModel(object):
|
||||
del vals['module'] # duplicated vals is not linked to any module
|
||||
vals['res_id'] = target_id
|
||||
if vals['lang'] == old.env.lang and field.translate is True:
|
||||
vals['source'] = old_wo_lang[name]
|
||||
# the value should be the new value (given by copy())
|
||||
vals['value'] = new_val
|
||||
Translation.create(vals)
|
||||
|
||||
Reference in New Issue
Block a user