Skip to content

Commit

Permalink
Merge remote-tracking branch 'odoo/16.0' into 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OCA-git-bot committed Dec 12, 2022
2 parents c2d598c + 16eb358 commit 543bb4d
Show file tree
Hide file tree
Showing 49 changed files with 784 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</t>

<t t-name="account.AccountFileUploader" owl="1">
<div>
<div t-att-class="props.record and props.record.data ? 'oe_kanban_color_' + props.record.data.color : ''">
<FileUploader
acceptedFileExtensions="props.acceptedFileExtensions"
fileUploadClass="'account_file_uploader'"
Expand Down
2 changes: 1 addition & 1 deletion addons/account/views/account_journal_dashboard_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<field name="alias_domain"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="d-flex flex-column flex-fill #{!selection_mode ? kanban_color(record.color.raw_value) : ''}">
<div t-attf-class="d-flex flex-column flex-fill">
<t t-value="JSON.parse(record.kanban_dashboard.raw_value)" t-set="dashboard"/>
<t t-value="record.type.raw_value" t-set="journal_type"/>
<t t-call="JournalTop"/>
Expand Down
10 changes: 8 additions & 2 deletions addons/event_booth_sale/models/event_booth_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ def _compute_price(self):
def _compute_price_reduce(self):
for category in self:
product = category.product_id
list_price = product.list_price + product.price_extra
discount = (list_price - product._get_contextual_price()) / list_price if list_price else 0.0
pricelist = product.product_tmpl_id._get_contextual_pricelist()
lst_price = product.currency_id._convert(
product.lst_price,
pricelist.currency_id,
self.env.company,
fields.Datetime.now()
)
discount = (lst_price - product._get_contextual_price()) / lst_price if lst_price else 0.0
category.price_reduce = (1.0 - discount) * category.price

@api.depends_context('pricelist', 'quantity')
Expand Down
7 changes: 6 additions & 1 deletion addons/event_booth_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ def _get_display_price(self):
if self.event_booth_pending_ids and self.event_id:
company = self.event_id.company_id or self.env.company
currency = company.currency_id
total_price = sum([booth.price for booth in self.event_booth_pending_ids])
product = self.event_booth_pending_ids.booth_category_id.product_id
pricelist = product.product_tmpl_id._get_contextual_pricelist()
if pricelist.discount_policy == "with_discount":
total_price = sum([booth.booth_category_id.price_reduce for booth in self.event_booth_pending_ids])
else:
total_price = sum([booth.price for booth in self.event_booth_pending_ids])
return currency._convert(
total_price, self.order_id.currency_id,
self.order_id.company_id or self.env.company.id,
Expand Down
12 changes: 8 additions & 4 deletions addons/event_sale/models/event_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ def _compute_description(self):
def _compute_price_reduce(self):
for ticket in self:
product = ticket.product_id
# seems strange to not apply pricelist logic but still use pricelist discount...
discount = (
product.lst_price - product._get_contextual_price()
) / product.lst_price if product.lst_price else 0.0
pricelist = product.product_tmpl_id._get_contextual_pricelist()
lst_price = product.currency_id._convert(
product.lst_price,
pricelist.currency_id,
self.env.company,
fields.Datetime.now()
)
discount = (lst_price - product._get_contextual_price()) / lst_price if lst_price else 0.0
ticket.price_reduce = (1.0 - discount) * ticket.price

def _init_column(self, column_name):
Expand Down
16 changes: 11 additions & 5 deletions addons/event_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,15 @@ def _get_display_price(self):
pricelist=self.order_id.pricelist_id.id,
uom=self.product_uom.id
)
if self.order_id.pricelist_id.discount_policy == 'with_discount':
return event_ticket.price_reduce
company = event_ticket.company_id or self.env.company
currency = company.currency_id
pricelist = self.order_id.pricelist_id
if pricelist.discount_policy == "with_discount":
price = event_ticket.price_reduce
else:
return event_ticket.price
else:
return super()._get_display_price()
price = event_ticket.price
return currency._convert(
price, self.order_id.currency_id,
self.order_id.company_id or self.env.company.id,
self.order_id.date_order or fields.Date.today())
return super()._get_display_price()
2 changes: 1 addition & 1 deletion addons/hw_drivers/tools/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def odoo_restart(delay):
def path_file(filename):
platform_os = platform.system()
if platform_os == 'Linux':
return Path().absolute().parent.joinpath(filename)
return Path.home() / filename
elif platform_os == 'Windows':
return Path().absolute().parent.joinpath('server/' + filename)

Expand Down
2 changes: 1 addition & 1 deletion addons/payment_authorize/views/payment_provider_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
name="action_update_merchant_details"
string="Generate Client Key"/>
</div>
<a colspan="2" href="https://www.odoo.com/documentation/16.0/applications/general/payment_providers/authorize.html" target="_blank">
<a colspan="2" href="https://www.odoo.com/documentation/16.0/applications/finance/payment_providers/authorize.html" target="_blank">
How to get paid with Authorize.Net
</a>
</group>
Expand Down
2 changes: 1 addition & 1 deletion addons/payment_paypal/views/payment_provider_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<field name="paypal_pdt_token" groups="base.group_no_one" password="True"/>
<field name="paypal_use_ipn"
attrs="{'required':[('code', '=', 'paypal'), ('state', '!=', 'disabled')]}"/>
<a href="https://www.odoo.com/documentation/16.0/applications/general/payment_providers/paypal.html"
<a href="https://www.odoo.com/documentation/16.0/applications/finance/payment_providers/paypal.html"
target="_blank"
colspan="2">
How to configure your paypal account?
Expand Down
6 changes: 0 additions & 6 deletions addons/point_of_sale/security/point_of_sale_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@

<data noupdate="1">

<record id="rule_pos_bank_statement_user" model="ir.rule">
<field name="name">Point Of Sale Bank Statement POS User</field>
<field name="model_id" ref="account.model_account_bank_statement" />
<field name="groups" eval="[(4, ref('group_pos_user'))]"/>
<field name="domain_force">[('pos_session_id', '!=', False)]</field>
</record>
<record id="rule_pos_bank_statement_account_user" model="ir.rule">
<field name="name">Point Of Sale Bank Statement Accountant</field>
<field name="model_id" ref="account.model_account_bank_statement" />
Expand Down
2 changes: 1 addition & 1 deletion addons/product/models/product_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _get_applicable_rules_domain(self, products, date, **kwargs):

return [
('pricelist_id', '=', self.id),
'|', ('categ_id', '=', False), ('categ_id', 'child_of', products.categ_id.ids),
'|', ('categ_id', '=', False), ('categ_id', 'parent_of', products.categ_id.ids),
'|', ('product_tmpl_id', '=', False), templates_domain,
'|', ('product_id', '=', False), products_domain,
'|', ('date_start', '=', False), ('date_start', '<=', date),
Expand Down
2 changes: 1 addition & 1 deletion addons/product/tests/test_product_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def setUpClass(cls):
'min_quantity': 2,
'compute_price': 'formula',
'base': 'list_price',
'categ_id': cls.category_5_id,
'categ_id': cls.product_category.id,
'price_discount': 5,
}),
Command.create({
Expand Down
2 changes: 1 addition & 1 deletion addons/product/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</span>
</div>
<field name="categ_id" string="Product Category"/>
<field name="product_tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_edit_color': 1}"/>
<field name="product_tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
<field name="company_id" groups="base.group_multi_company"
options="{'no_create': True}"/>
<field name="currency_id" invisible="1"/>
Expand Down
2 changes: 1 addition & 1 deletion addons/purchase_requisition/views/purchase_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</group>
<group>
<p colspan="2">
<button name="action_create_alternative" type="object" class="btn-link d-block" string="Create Alternative" icon="fa-copy" attrs="{'invisible': [('id', '=', False)]}" />
<button name="action_create_alternative" type="object" class="btn-link d-block" string="Create Alternative" icon="fa-copy"/>
<button name="action_compare_alternative_lines" type="object" class="btn-link d-block" string="Compare Product Lines" icon="fa-bar-chart" attrs="{'invisible': [('alternative_po_ids', '=', [])]}"/>
</p>
</group>
Expand Down
8 changes: 3 additions & 5 deletions addons/sale_stock/report/stock_report_deliveryslip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
<odoo>
<template id="report_delivery_document_inherit_sale_stock" inherit_id="stock.report_delivery_document">
<xpath expr="//div[@name='div_sched_date']" position="after">
<div class="row justify-content-end" t-if="o.sudo().sale_id.client_order_ref">
<div class="col-auto">
<strong>Customer Reference:</strong>
<p t-field="o.sudo().sale_id.client_order_ref"/>
</div>
<div class="col-auto justify-content-end" t-if="o.sudo().sale_id.client_order_ref">
<strong>Customer Reference:</strong>
<p t-field="o.sudo().sale_id.client_order_ref"/>
</div>
</xpath>
</template>
Expand Down
6 changes: 5 additions & 1 deletion addons/snailmail/static/src/js/snailmail_external_layout.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Change address font-size if needed
document.addEventListener('DOMContentLoaded', function (evt) {
var recipientAddress = document.querySelector(".address.row > div[name='address'] > address");
let baseSize = 120;
if (!recipientAddress) {
recipientAddress = document.querySelector("div .row.fallback_header > div.col-5.offset-7 > div:first-child");
}
var style = window.getComputedStyle(recipientAddress, null);
var height = parseFloat(style.getPropertyValue('height'));
var fontSize = parseFloat(style.getPropertyValue('font-size'));
recipientAddress.style.fontSize = (130 / (height / fontSize)) + 'px';
recipientAddress.style.fontSize = (baseSize / (height / fontSize)) + 'px';
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,28 @@ div .address.row > div[name="address"] {
max-height: 33mm;
}
}

/* Follow-up Letters */
div .pt-5:empty {
display: none;
}

div .row.fallback_header {
margin-top: -4mm !important;
height: 68mm !important;
width: 117% !important;
> div .col-5.offset-7 {
background-color: #ffffff;
margin-left: 48.5% !important;
position: relative !important;
> div:first-child {
width: 100%;
padding-left: 2mm !important;
height: 33mm;
max-height: 33mm !important;
line-height: 1.1em;
position: absolute;
bottom: 0;
}
}
}
4 changes: 2 additions & 2 deletions addons/website/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from odoo import http, models, fields, _
from odoo.exceptions import AccessError
from odoo.http import request
from odoo.http import request, SessionExpiredException
from odoo.osv import expression
from odoo.tools import OrderedSet, escape_psql, html_escape as escape
from odoo.addons.http_routing.models.ir_http import slug, slugify, _guess_mimetype
Expand Down Expand Up @@ -103,7 +103,7 @@ def index(self, **kw):
if homepage_url and homepage_url != '/':
try:
return request._serve_ir_http()
except (AccessError, NotFound):
except (AccessError, NotFound, SessionExpiredException):
pass

# Fallback on first accessible menu
Expand Down
8 changes: 8 additions & 0 deletions addons/website/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ def _get_converters(cls):
model=ModelConverter,
)

@classmethod
def _get_public_users(cls):
public_users = super()._get_public_users()
website = request.env(user=SUPERUSER_ID)['website'].get_current_website() # sudo
if website:
public_users.append(website._get_cached('user_id'))
return public_users

@classmethod
def _auth_method_public(cls):
""" If no user logged, set the public user of current website, or default
Expand Down
4 changes: 2 additions & 2 deletions addons/website/static/src/components/dialog/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ class TitleDescription extends Component {
// `NFKD` as in `http_routing` python `slugify()`
ev.target.value = ev.target.value.trim().normalize('NFKD').toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w-]+/g, '-') // Remove all non-word chars
.replace(/-\+/g, '-'); // Replace multiple - with single -
.replace(/[^\w-]+/g, '') // Remove all non-word chars
.replace(/--+/g, '-'); // Replace multiple - with single -
this.seoContext.seoName = ev.target.value;
}
}
Expand Down
12 changes: 10 additions & 2 deletions addons/website/static/src/snippets/s_table_of_content/000.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const TableOfContent = publicWidget.Widget.extend({
if (indexCallback >= 0) {
extraMenuUpdateCallbacks.splice(indexCallback, 1);
}
this._scrollingElement.scrollspy('dispose');
this.$target.css('top', '');
this.$target.find('.s_table_of_content_navbar').css('top', '');
this._super(...arguments);
Expand All @@ -39,6 +38,10 @@ const TableOfContent = publicWidget.Widget.extend({
* @private
*/
_updateTableOfContentNavbarPosition() {
if (!this.$target[0].querySelector('a.table_of_content_link')) {
// Do not start the scrollspy if the TOC is empty.
return;
}
let position = 0;
const $fixedElements = $('.o_top_fixed_element');
_.each($fixedElements, el => position += $(el).outerHeight());
Expand All @@ -49,7 +52,12 @@ const TableOfContent = publicWidget.Widget.extend({
position += $mainNavBar.length ? $mainNavBar.outerHeight() : 0;
position += isHorizontalNavbar ? this.$target.outerHeight() : 0;
this._scrollingElement = $().getScrollingElement();
this._scrollingElement.scrollspy({target: this.$target.find('.s_table_of_content_navbar'), method: 'offset', offset: position + 100, alwaysKeepFirstActive: true});
new ScrollSpy(this._scrollingElement, {
target: this.$target.find('.s_table_of_content_navbar'),
method: 'offset',
offset: position + 100,
alwaysKeepFirstActive: true
});
},
});

Expand Down
38 changes: 37 additions & 1 deletion addons/website/static/src/snippets/s_table_of_content/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ options.registry.TableOfContent = options.Class.extend({
this.observer.observe(targetNode, config);
return this._super(...arguments);
},
/**
* @override
*/
onRemove() {
this._disposeScrollSpy();
const exception = (tocEl) => tocEl === this.$target[0];
this._activateScrollSpy(exception);
},
/**
* @override
*/
Expand All @@ -31,11 +39,38 @@ options.registry.TableOfContent = options.Class.extend({
// Private
//--------------------------------------------------------------------------

/**
* @param {Function} exception
*/
_activateScrollSpy(exception) {
for (const tocEl of this.ownerDocument.querySelectorAll('#wrapwrap .s_table_of_content')) {
if (exception(tocEl)) {
continue;
}
this.trigger_up('widgets_start_request', {
$target: $(tocEl),
editableMode: true,
});
}
},
/**
* @private
*/
_disposeScrollSpy() {
const scrollingEl = $().getScrollingElement(this.ownerDocument)[0];
const scrollSpyInstance =
this.$target[0].ownerDocument.defaultView.ScrollSpy.getInstance(scrollingEl);
if (scrollSpyInstance) {
scrollSpyInstance.dispose();
}
},
/**
* @private
*/
_generateNav: function (ev) {
this.options.wysiwyg && this.options.wysiwyg.odooEditor.unbreakableStepUnactive();
// We dispose the scrollSpy because the navbar will be updated.
this._disposeScrollSpy();
const $nav = this.$target.find('.s_table_of_content_navbar');
const $headings = this.$target.find(this.targetedElements);
$nav.empty();
Expand All @@ -49,7 +84,8 @@ options.registry.TableOfContent = options.Class.extend({
$el.attr('id', id);
$el[0].dataset.anchor = 'true';
});
$nav.find('a:first').addClass('active');
const exception = (tocEl) => !tocEl.querySelector('.s_table_of_content_navbar a');
this._activateScrollSpy(exception);
},
});

Expand Down
Loading

0 comments on commit 543bb4d

Please sign in to comment.