Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0] [REF] Web: form widget max upload size #54

Open
wants to merge 8 commits into
base: 13.0
Choose a base branch
from
2 changes: 1 addition & 1 deletion addons/account/views/account_analytic_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<group/> <!-- put Accounting group under Amount group -->
<group name="accounting" string="Accounting">
<field name="general_account_id" options="{'no_create': True}"/>
<field name="move_id"/>
<field name="move_id" options="{'no_create': True}"/>
</group>
</group>
</data>
Expand Down
1 change: 1 addition & 0 deletions addons/mail/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def read_followers(self, follower_ids, res_model):
followers.append({
'id': follower.id,
'name': follower.partner_id.name or follower.channel_id.name,
'display_name': follower.partner_id.display_name or follower.channel_id.display_name,
'email': follower.partner_id.email if follower.partner_id else None,
'res_model': 'res.partner' if follower.partner_id else 'mail.channel',
'res_id': follower.partner_id.id or follower.channel_id.id,
Expand Down
2 changes: 1 addition & 1 deletion addons/mail/static/src/xml/followers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
t-att-data-oe-model="record.res_model"
t-att-data-oe-id="record.res_id">
<img t-att-src="record.avatar_url" alt="Avatar" class="o_image_64_cover"/>
<t t-esc="record.name"/>
<t t-esc="record.name or record.display_name"/>
</a>
<button t-if="record.is_editable"
class="btn btn-icon fa fa-pencil o_edit_subtype d-none"
Expand Down
43 changes: 40 additions & 3 deletions addons/sale/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,43 @@ def _get_display_price(self, product):
# negative discounts (= surcharge) are included in the display price
return max(base_price, final_price)

def _get_default_price_unit_from_product(self, product):
self.ensure_one()

currency = self.order_id.currency_id
fiscal_position = self.order_id.fiscal_position_id or self.order_id.partner_id.property_account_position_id
product_taxes = self.product_id.taxes_id.filtered(lambda r: r.company_id == self.order_id.company_id)
product_taxes_after_fp = fiscal_position.map_tax(product_taxes, partner=self.order_id.partner_id)
price_unit = self._get_display_price(product)

if set(product_taxes.ids) != set(product_taxes_after_fp.ids):
flattened_taxes = product_taxes._origin.flatten_taxes_hierarchy()
if any(tax.price_include for tax in flattened_taxes):
taxes_res = flattened_taxes.compute_all(
price_unit,
quantity=self.product_uom_qty,
currency=currency,
product=self.product_id,
partner=self.order_id.partner_id,
)
price_unit = currency.round(taxes_res['total_excluded'])

flattened_taxes = product_taxes_after_fp._origin.flatten_taxes_hierarchy()
if any(tax.price_include for tax in flattened_taxes):
taxes_res = flattened_taxes.compute_all(
price_unit,
quantity=self.product_uom_qty,
currency=currency,
product=self.product_id,
partner=self.order_id.partner_id,
handle_price_include=False,
)
for tax_res in taxes_res['taxes']:
tax = self.env['account.tax'].browse(tax_res['id'])
if tax.price_include:
price_unit += tax_res['amount']
return price_unit

@api.onchange('product_id')
def product_id_change(self):
if not self.product_id:
Expand Down Expand Up @@ -1575,13 +1612,13 @@ def product_id_change(self):
pricelist=self.order_id.pricelist_id.id,
uom=self.product_uom.id
)

vals.update(name=self.get_sale_order_line_multiline_description_sale(product))

self._compute_tax_id()

if self.order_id.pricelist_id and self.order_id.partner_id:
vals['price_unit'] = self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_id, self.company_id)
vals['price_unit'] = self._get_default_price_unit_from_product(product)

self.update(vals)

title = False
Expand Down Expand Up @@ -1614,7 +1651,7 @@ def product_uom_change(self):
uom=self.product_uom.id,
fiscal_position=self.env.context.get('fiscal_position')
)
self.price_unit = self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_id, self.company_id)
self.price_unit = self._get_default_price_unit_from_product(product)

def name_get(self):
result = []
Expand Down
1 change: 1 addition & 0 deletions addons/sale/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from . import test_sale_refund
from . import test_sale_signature
from . import test_sale_transaction
from . import test_sale_fiscal_position
131 changes: 131 additions & 0 deletions addons/sale/tests/test_sale_fiscal_position.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# -*- coding: utf-8 -*-
from odoo import fields
from odoo.addons.account.tests.account_test_savepoint import AccountTestInvoicingCommon
from odoo.tests import tagged
from odoo.tests.common import Form


@tagged('post_install', '-at_install')
class TestSaleFiscalPosition(AccountTestInvoicingCommon):

def test_fiscal_pos_taxes_mapping_price_included_to_price_excluded(self):
''' Test mapping a price-included tax (10%) with a price-excluded tax (20%) on a price_unit of 110.0.
The price_unit should be 100.0 after applying the fiscal position.
'''
tax_price_include = self.env['account.tax'].create({
'name': '10% incl',
'type_tax_use': 'sale',
'amount_type': 'percent',
'amount': 10,
'price_include': True,
'include_base_amount': True,
})
tax_price_exclude = self.env['account.tax'].create({
'name': '15% excl',
'type_tax_use': 'sale',
'amount_type': 'percent',
'amount': 15,
})

fiscal_position = self.env['account.fiscal.position'].create({
'name': 'fiscal_pos_a',
'tax_ids': [
(0, None, {
'tax_src_id': tax_price_include.id,
'tax_dest_id': tax_price_exclude.id,
}),
],
})

product = self.env['product.product'].create({
'name': 'product',
'uom_id': self.env.ref('uom.product_uom_unit').id,
'lst_price': 110.0,
'taxes_id': [(6, 0, tax_price_include.ids)],
})

so_form = Form(self.env['sale.order'])
so_form.partner_id = self.partner_a
so_form.date_order = fields.Date.from_string('2019-01-01')
so_form.fiscal_position_id = fiscal_position
so_form.pricelist_id = self.env.ref('product.list0')
with so_form.order_line.new() as line:
line.product_id = product
so = so_form.save()

self.assertRecordValues(so.order_line, [{
'price_unit': 100.0,
'tax_id': tax_price_exclude.ids,
}])

uom_dozen = self.env.ref('uom.product_uom_dozen')
with Form(so) as so_form:
with so_form.order_line.edit(0) as line_form:
line_form.product_uom = uom_dozen

self.assertRecordValues(so.order_line, [{
'price_unit': 1200.0,
'tax_id': tax_price_exclude.ids,
}])

def test_fiscal_pos_taxes_mapping_price_included_to_price_included(self):
''' Test mapping a price-included tax (10%) with another price-included tax (20%) on a price_unit of 110.0.
The price_unit should be 120.0 after applying the fiscal position.
'''
tax_price_include_1 = self.env['account.tax'].create({
'name': '10% incl',
'type_tax_use': 'sale',
'amount_type': 'percent',
'amount': 10,
'price_include': True,
'include_base_amount': True,
})
tax_price_include_2 = self.env['account.tax'].create({
'name': '20% incl',
'type_tax_use': 'sale',
'amount_type': 'percent',
'amount': 20,
'price_include': True,
'include_base_amount': True,
})

fiscal_position = self.env['account.fiscal.position'].create({
'name': 'fiscal_pos_a',
'tax_ids': [
(0, None, {
'tax_src_id': tax_price_include_1.id,
'tax_dest_id': tax_price_include_2.id,
}),
],
})

product = self.env['product.product'].create({
'name': 'product',
'uom_id': self.env.ref('uom.product_uom_unit').id,
'lst_price': 110.0,
'taxes_id': [(6, 0, tax_price_include_1.ids)],
})

so_form = Form(self.env['sale.order'])
so_form.partner_id = self.partner_a
so_form.date_order = fields.Date.from_string('2019-01-01')
so_form.fiscal_position_id = fiscal_position
so_form.pricelist_id = self.env.ref('product.list0')
with so_form.order_line.new() as line:
line.product_id = product
so = so_form.save()

self.assertRecordValues(so.order_line, [{
'price_unit': 120.0,
'tax_id': tax_price_include_2.ids,
}])

uom_dozen = self.env.ref('uom.product_uom_dozen')
with Form(so) as so_form:
with so_form.order_line.edit(0) as line_form:
line_form.product_uom = uom_dozen

self.assertRecordValues(so.order_line, [{
'price_unit': 1440.0,
'tax_id': tax_price_include_2.ids,
}])
14 changes: 14 additions & 0 deletions addons/web/i18n/web.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2637,6 +2637,13 @@ msgstr ""
msgid "Opacity %"
msgstr ""

#. module: web
#. openerp-web
#: code:addons/web/static/src/xml/debug.xml:0
#, python-format
msgid "Open Developer Tools"
msgstr ""

#. module: web
#. openerp-web
#: code:addons/web/static/src/xml/debug.xml:0
Expand Down Expand Up @@ -2690,6 +2697,13 @@ msgstr ""
msgid "Open: "
msgstr ""

#. module: web
#. openerp-web
#: code:addons/web/static/src/js/views/list/list_renderer.js:0
#, python-format
msgid "Optional columns"
msgstr ""

#. module: web
#. openerp-web
#: code:addons/web/static/src/js/views/kanban/kanban_record.js:0
Expand Down
3 changes: 3 additions & 0 deletions addons/web/static/src/js/core/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ var dom = {
if (options && options.prop) {
$input.prop(options.prop);
}
if (options && options.role) {
$input.attr('role', options.role);
}
return $container.append($input, $label);
},
/**
Expand Down
2 changes: 1 addition & 1 deletion addons/web/static/src/js/fields/basic_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ var AbstractFieldBinary = AbstractField.extend({
this._super.apply(this, arguments);
this.fields = record.fields;
this.useFileAPI = !!window.FileReader;
this.max_upload_size = 25 * 1024 * 1024; // 25Mo
this.max_upload_size = 100 * 1024 * 1024; // 100Mo
if (!this.useFileAPI) {
var self = this;
this.fileupload_id = _.uniqueId('o_fileupload');
Expand Down
2 changes: 2 additions & 0 deletions addons/web/static/src/js/views/list/list_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ var ListRenderer = BasicRenderer.extend({
'data-toggle': "dropdown",
'data-display': "static",
'aria-expanded': false,
'aria-label': _t('Optional columns'),
});
$a.appendTo($optionalColumnsDropdown);

Expand All @@ -893,6 +894,7 @@ var ListRenderer = BasicRenderer.extend({
(config.isDebug() ? (' (' + col.attrs.name + ')') : '');
var $checkbox = dom.renderCheckbox({
text: txt,
role: "menuitemcheckbox",
prop: {
name: col.attrs.name,
checked: _.contains(self.optionalColumnsEnabled, col.attrs.name),
Expand Down
2 changes: 1 addition & 1 deletion addons/web/static/src/xml/base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
</button>
</t>
<t t-if="widget.is_action_enabled('export_xlsx')">
<button type="button" class="btn btn-secondary fa fa-download o_list_export_xlsx" title="Export All"/>
<button type="button" class="btn btn-secondary fa fa-download o_list_export_xlsx" title="Export All" aria-label="Export All"/>
</t>
</div>
</t>
Expand Down
7 changes: 5 additions & 2 deletions addons/web/static/src/xml/debug.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

<t t-name="WebClient.DebugManager">
<li class="o_debug_manager" role="menuitem">
<a role="button" href="#" class="o_debug_mode" t-attf-title="Open Developer Tools#{widget.debug_mode_help}"
t-att-data-debug-mode="widget.debug_mode" aria-label="Open Developer Tools#{widget.debug_mode_help}"
<t t-set="_devtool_button_title">Open Developer Tools</t>
<a role="button" href="#" class="o_debug_mode"
t-att-title="_devtool_button_title + widget.debug_mode_help"
t-att-aria-label="_devtool_button_title + widget.debug_mode_help"
t-att-data-debug-mode="widget.debug_mode"
data-toggle="dropdown" aria-expanded="false" tabindex="-1" data-display="static">
<span class="fa fa-bug"/>
</a>
Expand Down
2 changes: 1 addition & 1 deletion odoo/addons/base/i18n/base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -24561,7 +24561,7 @@ msgstr ""
#. module: base
#: code:addons/base/models/res_partner.py:0
#, python-format
msgid "You cannot archive a contact linked to an internal user."
msgid "You cannot archive a contact linked to a portal or internal user."
msgstr ""

#. module: base
Expand Down
2 changes: 1 addition & 1 deletion odoo/addons/base/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def write(self, vals):
self.invalidate_cache(['user_ids'], self._ids)
for partner in self:
if partner.active and partner.user_ids:
raise ValidationError(_('You cannot archive a contact linked to an internal user.'))
raise ValidationError(_('You cannot archive a contact linked to a portal or internal user.'))
# res.partner must only allow to set the company_id of a partner if it
# is the same as the company of all users that inherit from this partner
# (this is to allow the code from res_users to write to the partner!) or
Expand Down
2 changes: 1 addition & 1 deletion odoo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def splittor(rs):
if lines2:
# merge first line with record's main line
for j, val in enumerate(lines2[0]):
if val or isinstance(val, bool):
if val or isinstance(val, (int, float)):
current[j] = val
# append the other lines at the end
lines += lines2[1:]
Expand Down
2 changes: 1 addition & 1 deletion odoo/tools/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'data-o-mail-quote', # quote detection
'data-oe-model', 'data-oe-id', 'data-oe-field', 'data-oe-type', 'data-oe-expression', 'data-oe-translation-id', 'data-oe-nodeid',
'data-publish', 'data-id', 'data-res_id', 'data-interval', 'data-member_id', 'data-scroll-background-ratio', 'data-view-id',
'data-class',
'data-class', 'data-mimetype',
])


Expand Down