Skip to content

Commit

Permalink
Revert "[FIX] base: bad back-port"
Browse files Browse the repository at this point in the history
This reverts commit 0ac6043.
  • Loading branch information
KangOl committed Jan 25, 2018
2 parents 1d884be + da9baf2 commit c6b2fa4
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 32 deletions.
4 changes: 3 additions & 1 deletion addons/account/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ def _prepare_refund(self, invoice, date_invoice=None, date=None, description=Non
values['state'] = 'draft'
values['number'] = False
values['origin'] = invoice.number
values['payment_term_id'] = False
values['refund_invoice_id'] = invoice.id

if date:
Expand Down Expand Up @@ -1714,14 +1715,15 @@ def _check_lines(self):
def compute(self, value, date_ref=False):
date_ref = date_ref or fields.Date.today()
amount = value
sign = value < 0 and -1 or 1
result = []
if self.env.context.get('currency_id'):
currency = self.env['res.currency'].browse(self.env.context['currency_id'])
else:
currency = self.env.user.company_id.currency_id
for line in self.line_ids:
if line.value == 'fixed':
amt = currency.round(line.value_amount)
amt = sign * currency.round(line.value_amount)
elif line.value == 'percent':
amt = currency.round(value * (line.value_amount / 100.0))
elif line.value == 'balance':
Expand Down
2 changes: 1 addition & 1 deletion addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ def _get_pair_to_reconcile(self):
elif self._context.get('skip_full_reconcile_check') == 'amount_currency_only':
field = 'amount_residual_currency'
#target the pair of move in self that are the oldest
sorted_moves = sorted(self, key=lambda a: a.date)
sorted_moves = sorted(self, key=lambda a: a.date_maturity or a.date)
debit = credit = False
for aml in sorted_moves:
if credit and debit:
Expand Down
12 changes: 7 additions & 5 deletions addons/hr/models/hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ def _default_image(self):
active = fields.Boolean('Active', related='resource_id.active', default=True, store=True)
# private partner
address_home_id = fields.Many2one(
'res.partner', 'Private Address', help='Enter here the private address of the employee, not the one linked to your company.')
'res.partner', 'Private Address', help='Enter here the private address of the employee, not the one linked to your company.',
groups="hr.group_hr_user")
is_address_home_a_company = fields.Boolean(
'The employee adress has a company linked',
compute='_compute_is_address_home_a_company',
groups="hr.group_hr_user",
)
country_id = fields.Many2one(
'res.country', 'Nationality (Country)')
'res.country', 'Nationality (Country)', groups="hr.group_hr_user")
gender = fields.Selection([
('male', 'Male'),
('female', 'Female'),
Expand All @@ -139,9 +141,9 @@ def _default_image(self):
domain="[('partner_id', '=', address_home_id)]",
groups="hr.group_hr_user",
help='Employee bank salary account')
permit_no = fields.Char('Work Permit No')
visa_no = fields.Char('Visa No')
visa_expire = fields.Date('Visa Expire Date')
permit_no = fields.Char('Work Permit No', groups="hr.group_hr_user")
visa_no = fields.Char('Visa No', groups="hr.group_hr_user")
visa_expire = fields.Date('Visa Expire Date', groups="hr.group_hr_user")

# image: all image fields are base64 encoded and PIL-supported
image = fields.Binary(
Expand Down
8 changes: 3 additions & 5 deletions addons/l10n_fr/migrations/2.0/post-migrate_tags_on_taxes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from openerp.modules.registry import RegistryManager

# -*- coding: utf-8 -*-
from odoo.addons.account.models.chart_template import migrate_tags_on_taxes

def migrate(cr, version):
registry = RegistryManager.get(cr.dbname)
from openerp.addons.account.models.chart_template import migrate_tags_on_taxes
migrate_tags_on_taxes(cr, registry)
migrate_tags_on_taxes(cr, None)
13 changes: 10 additions & 3 deletions addons/point_of_sale/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,22 @@ def _reconcile_payments(self):
for order in self:
aml = order.statement_ids.mapped('journal_entry_ids') | order.account_move.line_ids | order.invoice_id.move_id.line_ids
aml = aml.filtered(lambda r: not r.reconciled and r.account_id.internal_type == 'receivable' and r.partner_id == order.partner_id.commercial_partner_id)

# Reconcile returns first
# to avoid mixing up the credit of a payment and the credit of a return
# in the receivable account
aml_returns = aml.filtered(lambda l: (l.journal_id.type == 'sale' and l.credit) or (l.journal_id.type != 'sale' and l.debit))
try:
aml.reconcile()
aml_returns.reconcile()
(aml - aml_returns).reconcile()
except Exception:
# There might be unexpected situations where the automatic reconciliation won't
# work. We don't want the user to be blocked because of this, since the automatic
# reconciliation is introduced for convenience, not for mandatory accounting
# reasons.
_logger.error('Reconciliation did not work for order %s', order.name)
continue
# It may be interesting to have the Traceback logged anyway
# for debugging and support purposes
_logger.exception('Reconciliation did not work for order %s', order.name)

def _default_session(self):
return self.env['pos.session'].search([('state', '=', 'opened'), ('user_id', '=', self.env.uid)], limit=1)
Expand Down
2 changes: 1 addition & 1 deletion addons/point_of_sale/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ access_product_pricelist_manager,product.pricelist manager,product.model_product
access_product_pricelist_user,product.pricelist user,product.model_product_pricelist,group_pos_user,1,0,0,0
access_pos_session_user,pos.session user,model_pos_session,group_pos_user,1,1,1,0
access_pos_config_user,pos.config user,model_pos_config,group_pos_user,1,1,0,0
access_pos_config_manager,pos.config user,model_pos_config,group_pos_manager,1,1,1,0
access_pos_config_manager,pos.config manager,model_pos_config,group_pos_manager,1,1,1,1
access_product_category_pos_manager,pos.category manager,model_pos_category,group_pos_manager,1,1,1,1
access_product_category_pos_user,pos.category user,model_pos_category,group_pos_user,1,0,0,0
access_barcode_nomenclature_pos_user,barcode.nomenclature.pos.user,barcodes.model_barcode_nomenclature,group_pos_user,1,0,0,0
Expand Down
2 changes: 1 addition & 1 deletion addons/web_editor/static/src/js/widgets/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ var ViewEditor = Widget.extend({
*/
start: function () {
this.$viewEditor = this.$('#ace-view-editor');
this.$editor = this.$('.ace_editor');

this.$typeSwitcherChoices = this.$('.o_ace_type_switcher_choice');
this.$typeSwitcherBtn = this.$('.o_ace_type_switcher > .dropdown-toggle');
Expand All @@ -210,6 +209,7 @@ var ViewEditor = Widget.extend({

this.aceEditor = window.ace.edit(this.$viewEditor[0]);
this.aceEditor.setTheme('ace/theme/monokai');
this.$editor = this.$('.ace_editor');

var refX = 0;
var resizing = false;
Expand Down
11 changes: 6 additions & 5 deletions addons/website_blog/models/website_blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ def create(self, vals):

@api.multi
def write(self, vals):
self.ensure_one()
if 'website_published' in vals and 'published_date' not in vals:
if (self.published_date or '') <= fields.Datetime.now():
vals['published_date'] = vals['website_published'] and fields.Datetime.now()
result = super(BlogPost, self).write(vals)
result = True
for post in self:
copy_vals = vals
if 'website_published' in vals and 'published_date' not in vals and (post.published_date or '') <= fields.Datetime.now():
copy_vals['published_date'] = vals['website_published'] and fields.Datetime.now() or False
result &= super(BlogPost, self).write(copy_vals)
self._check_for_publication(vals)
return result

Expand Down
4 changes: 3 additions & 1 deletion addons/website_event_track/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WebsiteEventTrackController(http.Controller):

@http.route(['''/event/<model("event.event"):event>/track/<model("event.track", "[('event_id','=',event[0])]"):track>'''], type='http', auth="public", website=True)
def event_track_view(self, event, track, **post):
track = track.sudo()
track = track.sudo().with_context(tz=event.date_tz or 'UTC')
values = {'track': track, 'event': track.event_id, 'main_object': track}
return request.render("website_event_track.track_view", values)

Expand Down Expand Up @@ -67,6 +67,7 @@ def _prepare_calendar(self, event, event_track_ids):

@http.route(['''/event/<model("event.event"):event>/agenda'''], type='http', auth="public", website=True, sitemap=False)
def event_agenda(self, event, tag=None, **post):
event = event.with_context(tz=event.date_tz or 'UTC')
local_tz = pytz.timezone(event.date_tz or 'UTC')
days_tracks = collections.defaultdict(lambda: [])
for track in event.track_ids.sorted(lambda track: (track.date or '', bool(track.location_id))):
Expand All @@ -93,6 +94,7 @@ def event_agenda(self, event, tag=None, **post):
'''/event/<model("event.event"):event>/track/tag/<model("event.track.tag"):tag>'''
], type='http', auth="public", website=True, sitemap=False)
def event_tracks(self, event, tag=None, **post):
event = event.with_context(tz=event.date_tz or 'UTC')
searches = {}
if tag:
searches.update(tag=tag.id)
Expand Down
4 changes: 3 additions & 1 deletion addons/website_event_track/views/event_track_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@
</div>
<div class="panel-body">
<b>Date</b><br/>
<span t-field="track.date" t-options='{"hide_seconds":"True"}'/><br/>
<span t-field="track.date" t-options='{"hide_seconds":"True"}'/>
<t t-if="event.date_tz">(<span t-field="event.date_tz"/>)</t>
<br/>
<b>Duration</b><br/>
<span t-field="track.duration" t-options='{"widget": "duration", "unit": "hour", "round": "minute"}'/><br/>
<b>Location</b><br/>
Expand Down
11 changes: 11 additions & 0 deletions doc/cla/individual/sergeiruzkiicode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Belarus, 2017-01-17

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,

Sergei Ruzki [email protected] https://github.com/sergeiruzkiicode
4 changes: 2 additions & 2 deletions odoo/addons/base/res/res_country_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@
<field name="name">Belarus</field>
<field name="code">by</field>
<field file="base/static/img/country_flags/by.png" name="image" type="base64" />
<field name="currency_id" ref="BYR" />
<field eval="0" name="phone_code" />
<field name="currency_id" ref="BYN" />
<field eval="375" name="phone_code" />
</record>
<record id="bz" model="res.country">
<field name="name">Belize</field>
Expand Down
11 changes: 10 additions & 1 deletion odoo/addons/base/res/res_currency_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,19 @@
<field name="symbol">BR</field>
<field name="rounding">0.01</field>
<field name="active" eval="False"/>
<field name="currency_unit_label">Ruble</field>
<field name="currency_unit_label">Ruble BYR</field>
<field name="currency_subunit_label">Kapeyka</field>
</record>

<record id="BYN" model="res.currency">
<field name="name">BYN</field>
<field name="symbol">Br</field>
<field name="rounding">0.01</field>
<field name="active" eval="False"/>
<field name="currency_unit_label">Rubles</field>
<field name="currency_subunit_label">Kopeks</field>
</record>

<record id="BZD" model="res.currency">
<field name="name">BZD</field>
<field name="symbol">BZ$</field>
Expand Down
6 changes: 6 additions & 0 deletions odoo/addons/base/res/res_currency_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@
<field name="rate">10228.19</field>
</record>

<record forcecreate="0" id="rateBYN" model="res.currency.rate">
<field name="currency_id" ref="BYN" />
<field name="name">2016-07-01</field>
<field name="rate">2.23151</field>
</record>

<record forcecreate="0" id="rateBZD" model="res.currency.rate">
<field name="currency_id" ref="BZD" />
<field name="name">2010-01-01</field>
Expand Down
8 changes: 7 additions & 1 deletion odoo/addons/base/res/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from odoo.osv import expression
from odoo.service.db import check_super
from odoo.tools import partition, pycompat
from odoo.http import root

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -372,6 +373,8 @@ def write(self, values):
if any(key.startswith('context_') or key in ('lang', 'tz') for key in values):
self.context_get.clear_cache(self)
if any(key in values for key in ['active'] + USER_PRIVATE_FIELDS):
# force deletion of all sessions for these users
root.session_store.delete_sessions_for_uids(self.ids)
db = self._cr.dbname
for id in self.ids:
self.__uid_cache[db].pop(id, None)
Expand All @@ -385,7 +388,10 @@ def unlink(self):
db = self._cr.dbname
for id in self.ids:
self.__uid_cache[db].pop(id, None)
return super(Users, self).unlink()
res = super(Users, self).unlink()
# force deletion of all sessions for these users
root.session_store.delete_sessions_for_uids(self.ids)
return res

@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
Expand Down
16 changes: 12 additions & 4 deletions odoo/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,6 @@ def authenticate(self, db, login=None, password=None, uid=None):
self.db = db
self.uid = uid
self.login = login
self.password = password
request.uid = uid
request.disable_db = False

Expand All @@ -1045,7 +1044,6 @@ def check_security(self):
"""
if not self.db or not self.uid:
raise SessionExpiredException("Session expired")
security.check(self.db, self.uid, self.password)

def logout(self, keep_db=False):
for k in list(self):
Expand All @@ -1058,7 +1056,6 @@ def _default_values(self):
self.setdefault("db", None)
self.setdefault("uid", None)
self.setdefault("login", None)
self.setdefault("password", None)
self.setdefault("context", {})

def get_context(self):
Expand Down Expand Up @@ -1271,6 +1268,17 @@ def start_wrapped(status, headers):
start_response(status, new_headers)
return self.app(environ, start_wrapped)

class OdooSessionStore(werkzeug.contrib.sessions.FilesystemSessionStore):
def delete_sessions_for_uids(self, uids):
# pretty expensive on large session stores, especially non-local!
uids = set(uids)
_logger.info('Deleting all HTTP sessions for UIDs %s', uids)
for sid in self.list():
s = self.get(sid)
if s.uid and s.uid in uids:
_logger.debug('Deleting session %s', sid)
self.delete(s)

class Root(object):
"""Root WSGI application for the OpenERP Web Client.
"""
Expand All @@ -1282,7 +1290,7 @@ def session_store(self):
# Setup http sessions
path = odoo.tools.config.session_dir
_logger.debug('HTTP sessions stored in: %s', path)
return werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession)
return OdooSessionStore(path, session_class=OpenERPSession)

@lazy_property
def nodb_routing_map(self):
Expand Down

0 comments on commit c6b2fa4

Please sign in to comment.