[IMP] account,sale,repair,website,purchase: remove setting and display correction

Before this commit, the accounting module had a setting on the selection of taxes used by the sales, purchase, website_sale, ... modules. In addition, the website_sale module had the same setting related to the accounting one.
This PR isolates the tax selection parameter in the website_sale module, and instead of using the tax selection, the accounting module will use rounding method (round per line, round globally).
Selecting one of the two will change the display of all account_move or other view using the tax selection setting.

Display changes:
In round per line, a column tax excluded will always be displayed while a column tax included will be in optional hide.
On the other hand, in the round globally, only the tax excluded columns will be available.

closes odoo/odoo#99209

Task-id: 2954332
Related: odoo/upgrade#3826
Related: odoo/enterprise#30853
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
maximilien(malb)
2023-03-02 19:24:45 +01:00
committed by Maximilien (malb)
parent 3e175f4519
commit ee2c82700e
44 changed files with 282 additions and 239 deletions
+3 -1
View File
@@ -282,7 +282,9 @@ class AccountMove(models.Model):
)
needed_terms = fields.Binary(compute='_compute_needed_terms')
needed_terms_dirty = fields.Boolean(compute='_compute_needed_terms')
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
string='Tax calculation rounding method', readonly=True)
# === Partner fields === #
partner_id = fields.Many2one(
'res.partner',
+3 -1
View File
@@ -345,7 +345,9 @@ class AccountMoveLine(models.Model):
digits='Discount',
default=0.0,
)
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
string='Tax calculation rounding method', readonly=True)
# === Invoice sync fields === #
term_key = fields.Binary(compute='_compute_term_key')
tax_key = fields.Binary(compute='_compute_tax_key')
@@ -71,28 +71,10 @@ class ResConfigSettings(models.TransientModel):
module_account_accountant = fields.Boolean(string='Accounting')
group_warning_account = fields.Boolean(string="Warnings in Invoices", implied_group='account.group_warning_account')
group_cash_rounding = fields.Boolean(string="Cash Rounding", implied_group='account.group_cash_rounding')
# group_show_line_subtotals_tax_excluded and group_show_line_subtotals_tax_included are opposite,
# so we can assume exactly one of them will be set, and not the other.
# We need both of them to coexist so we can take advantage of automatic group assignation.
group_show_line_subtotals_tax_excluded = fields.Boolean(
"Show line subtotals without taxes (B2B)",
implied_group='account.group_show_line_subtotals_tax_excluded',
group='base.group_portal,base.group_user,base.group_public',
compute='_compute_group_show_line_subtotals', store=True, readonly=False)
group_show_line_subtotals_tax_included = fields.Boolean(
"Show line subtotals with taxes (B2C)",
implied_group='account.group_show_line_subtotals_tax_included',
group='base.group_portal,base.group_user,base.group_public',
compute='_compute_group_show_line_subtotals', store=True, readonly=False)
group_show_sale_receipts = fields.Boolean(string='Sale Receipt',
implied_group='account.group_sale_receipts')
group_show_purchase_receipts = fields.Boolean(string='Purchase Receipt',
implied_group='account.group_purchase_receipts')
show_line_subtotals_tax_selection = fields.Selection([
('tax_excluded', 'Tax Excluded'),
('tax_included', 'Tax Included')], string="Line Subtotals Tax Display",
required=True, default='tax_excluded',
config_parameter='account.show_line_subtotals_tax_selection')
module_account_budget = fields.Boolean(string='Budget Management')
module_account_payment = fields.Boolean(string='Invoice Online Payment')
module_account_reports = fields.Boolean("Dynamic Reports")
@@ -208,12 +190,6 @@ class ResConfigSettings(models.TransientModel):
self.has_chart_of_accounts = bool(self.company_id.chart_template)
self.has_accounting_entries = self.company_id._existing_accounting()
@api.depends('show_line_subtotals_tax_selection')
def _compute_group_show_line_subtotals(self):
for wizard in self:
wizard.group_show_line_subtotals_tax_included = wizard.show_line_subtotals_tax_selection == "tax_included"
wizard.group_show_line_subtotals_tax_excluded = wizard.show_line_subtotals_tax_selection == "tax_excluded"
@api.onchange('group_analytic_accounting')
def onchange_analytic_accounting(self):
if self.group_analytic_accounting:
-22
View File
@@ -5,28 +5,6 @@ from odoo import api, models, _
from odoo.exceptions import ValidationError
class Users(models.Model):
_inherit = "res.users"
@api.constrains('groups_id')
def _check_one_user_type(self):
super(Users, self)._check_one_user_type()
g1 = self.env.ref('account.group_show_line_subtotals_tax_included', False)
g2 = self.env.ref('account.group_show_line_subtotals_tax_excluded', False)
if not g1 or not g2:
# A user cannot be in a non-existant group
return
for user in self:
if user._has_multiple_groups([g1.id, g2.id]):
raise ValidationError(_("A user cannot have both Tax B2B and Tax B2C.\n"
"You should go in General Settings, and choose to display Product Prices\n"
"either in 'Tax-Included' or in 'Tax-Excluded' mode\n"
"(or switch twice the mode if you are already in the desired one)."))
class GroupsView(models.Model):
_inherit = 'res.groups'
@@ -38,18 +38,6 @@
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_show_line_subtotals_tax_excluded" model="res.groups">
<field name="name">Tax display B2B</field>
<field name="comment">Show line subtotals without taxes (B2B)</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_show_line_subtotals_tax_included" model="res.groups">
<field name="name">Tax display B2C</field>
<field name="comment">Show line subtotals with taxes included (B2C)</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_account_readonly" model="res.groups">
<field name="name">Show Accounting Features - Readonly</field>
<field name="category_id" ref="base.module_category_hidden"/>
@@ -105,16 +93,6 @@
<field name="groups" eval="[(4, ref('account.group_account_invoice'))]"/>
</record>
<record id="base.group_public" model="res.groups">
<field name="implied_ids" eval="[(4, ref('account.group_show_line_subtotals_tax_excluded'))]"/>
</record>
<record id="base.group_portal" model="res.groups">
<field name="implied_ids" eval="[(4, ref('account.group_show_line_subtotals_tax_excluded'))]"/>
</record>
<record id="base.group_user" model="res.groups">
<field name="implied_ids" eval="[(4, ref('account.group_show_line_subtotals_tax_excluded'))]"/>
</record>
<record id="base.default_user" model="res.users">
<field name="groups_id" eval="[(4,ref('account.group_account_manager'))]"/>
</record>
-1
View File
@@ -23,7 +23,6 @@ from . import test_account_journal_dashboard
from . import test_chart_template
from . import test_fiscal_position
from . import test_sequence_mixin
from . import test_settings
from . import test_tax
from . import test_invoice_taxes
from . import test_mail_performance
+21 -10
View File
@@ -745,6 +745,7 @@
<field name="statement_id" invisible="1"/>
<field name="payment_id" invisible="1"/>
<field name="tax_country_id" invisible="1"/>
<field name="tax_calculation_rounding_method" invisible="1"/>
<field name="tax_cash_basis_created_move_ids" invisible="1"/>
<field name="quick_edit_mode" invisible="1"/>
<field name="hide_post_button" invisible="1"/>
@@ -916,11 +917,11 @@
options="{'no_create': True}"
optional="show"/>
<field name="price_subtotal"
string="Subtotal"
groups="account.group_show_line_subtotals_tax_excluded"/>
string="Tax excl."/>
<field name="price_total"
string="Total"
groups="account.group_show_line_subtotals_tax_included"/>
string="Tax incl."
attrs="{'column_invisible': [('parent.tax_calculation_rounding_method', '=', 'round_globally')]}"
optional="hide"/>
<!-- Others fields -->
<field name="partner_id" invisible="1"/>
@@ -936,8 +937,12 @@
<!-- Displayed fields -->
<field name="name"/>
<field name="product_id"/>
<field name="price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<field name="price_total" groups="account.group_show_line_subtotals_tax_included"/>
<field name="price_subtotal"
string="Tax excl."/>
<field name="price_total"
string="Tax incl."
attrs="{'invisible': [('tax_calculation_rounding_method', '=', 'round_globally')]}"
optional="hide"/>
<field name="quantity"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="product_uom_id" groups="uom.group_uom"/>
@@ -957,8 +962,8 @@
</div>
<div class="col-auto">
<strong class="float-end text-end">
<t t-out="record.price_subtotal.value" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-out="record.price_total.value" groups="account.group_show_line_subtotals_tax_included"/>
<t t-out="record.price_subtotal.value"/>
<t t-out="record.price_total.value" t-if="tax_calculation_rounding_method == 'round_per_line'"/>
</strong>
</div>
</div>
@@ -986,6 +991,7 @@
</templates>
<!-- Others fields -->
<field name="tax_calculation_rounding_method" invisible="1"/>
<field name="currency_id" invisible="1"/>
<field name="company_currency_id" invisible="1"/>
<field name="display_type" force_save="1" invisible="1"/>
@@ -994,6 +1000,7 @@
<!-- Form view to cover mobile use -->
<form>
<sheet>
<field name="tax_calculation_rounding_method" invisible="1"/>
<field name="display_type" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="partner_id" invisible="1"/>
@@ -1015,8 +1022,12 @@
<label for="name" string="Note" attrs="{'invisible': [('display_type', '!=', 'line_note')]}"/>
<field name="name" widget="text"/>
<group>
<field name="price_subtotal" string="Subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<field name="price_total" string="Total" groups="account.group_show_line_subtotals_tax_included"/>
<field name="price_subtotal"
string="Tax excl."/>
<field name="price_total"
string="Tax incl."
attrs="{'invisible': [('tax_calculation_rounding_method', '=', 'round_globally')]}"
optional="hide"/>
</group>
</sheet>
</form>
+11 -6
View File
@@ -100,18 +100,21 @@
</th>
<th name="th_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
<th name="th_subtotal" class="text-end">
<span groups="account.group_show_line_subtotals_tax_excluded">Amount</span>
<span groups="account.group_show_line_subtotals_tax_included">Total Price</span>
<span>Tax excl.</span>
</th>
<th t-if="o.tax_calculation_rounding_method == 'round_per_line'" name="th_total" class="text-end">
<span>Tax incl.</span>
</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_total" t-value="0"/>
<t t-set="lines" t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>
<t t-foreach="lines" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_total + line.price_total"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="line.display_type == 'product'" name="account_invoice_line_accountable">
@@ -130,8 +133,10 @@
<span t-out="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))" id="line_tax_ids"/>
</td>
<td class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<span class="text-nowrap" t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<span class="text-nowrap" t-field="line.price_subtotal"/>
</td>
<td t-if="o.tax_calculation_rounding_method == 'round_per_line'" class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_total"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
@@ -114,11 +114,6 @@
<setting id="invoice_delivery_addresses" documentation="/applications/sales/sales/send_quotations/different_addresses.html" help="Select specific invoice and delivery addresses">
<field name="group_sale_delivery_address"/>
</setting>
<setting id="line_subtotals" help="Line subtotals tax display">
<field name="show_line_subtotals_tax_selection" class="o_light_label" widget="radio"/>
<field name="group_show_line_subtotals_tax_excluded" invisible="1"/>
<field name="group_show_line_subtotals_tax_included" invisible="1"/>
</setting>
<setting id="get_invoice_warnings" string="Warnings" help="Get warnings when invoicing specific customers">
<field name="group_warning_account"/>
</setting>
@@ -21,6 +21,9 @@ class EventBoothCategory(models.Model):
price = fields.Float(
string='Price', compute='_compute_price', digits='Product Price', readonly=False,
store=True, groups="event.group_event_registration_desk")
price_incl = fields.Float(
string='Price incl', compute='_compute_price_incl', digits='Product Price', readonly=False,
groups="event.group_event_registration_desk")
currency_id = fields.Many2one(related='product_id.currency_id', groups="event.group_event_registration_desk")
price_reduce = fields.Float(
string='Price Reduce', compute='_compute_price_reduce',
@@ -44,6 +47,16 @@ class EventBoothCategory(models.Model):
if category.product_id and category.product_id.list_price:
category.price = category.product_id.list_price + category.product_id.price_extra
@api.depends('product_id', 'product_id.taxes_id', 'price')
def _compute_price_incl(self):
for category in self:
if category.product_id and category.price:
tax_ids = category.product_id.taxes_id
taxes = tax_ids.compute_all(category.price, category.currency_id, 1.0, product=category.product_id)
category.price_incl = taxes['total_included']
else:
category.price_incl = 0
@api.depends_context('pricelist', 'quantity')
@api.depends('product_id', 'price')
def _compute_price_reduce(self):
@@ -65,7 +78,7 @@ class EventBoothCategory(models.Model):
for category in self:
tax_ids = category.product_id.taxes_id
taxes = tax_ids.compute_all(category.price_reduce, category.currency_id, 1.0, product=category.product_id)
category.price_reduce_taxinc = taxes['total_included']
category.price_reduce_taxinc = taxes['total_included'] or 0
def _init_column(self, column_name):
""" Initialize product_id for existing columns when installing sale
+13
View File
@@ -113,6 +113,9 @@ class EventTicket(models.Model):
price_reduce_taxinc = fields.Float(
string='Price Reduce Tax inc', compute='_compute_price_reduce_taxinc',
compute_sudo=True)
price_incl = fields.Float(
string='Price include', compute='_compute_price_incl',
digits='Product Price', readonly=False)
def _compute_price_reduce_taxinc(self):
for event in self:
@@ -121,6 +124,16 @@ class EventTicket(models.Model):
taxes = tax_ids.compute_all(event.price_reduce, event.event_id.company_id.currency_id, 1.0, product=event.product_id)
event.price_reduce_taxinc = taxes['total_included']
@api.depends('product_id', 'product_id.taxes_id', 'price')
def _compute_price_incl(self):
for event in self:
if event.product_id and event.price:
tax_ids = event.product_id.taxes_id.filtered(lambda r: r.company_id == event.event_id.company_id)
taxes = tax_ids.compute_all(event.price, event.currency_id, 1.0, product=event.product_id)
event.price_incl = taxes['total_included']
else:
event.price_incl = 0
@api.depends('product_id.active')
def _compute_sale_available(self):
inactive_product_tickets = self.filtered(lambda ticket: not ticket.product_id.active)
+6 -9
View File
@@ -126,24 +126,21 @@
<attribute name="t-value">current_subtotal + l10n_ar_values['price_subtotal']</attribute>
</t>
<!-- if b2c we still wants the latam subtotal -->
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" position="attributes">
<t t-set="current_total" t-value="current_total + line.price_total" position="attributes">
<attribute name="t-value">current_subtotal + l10n_ar_values['price_subtotal']</attribute>
</t>
<!-- label amount for subtotal column on b2b and b2c -->
<xpath expr="//th[@name='th_subtotal']/span[@groups='account.group_show_line_subtotals_tax_included']" position="replace">
<span groups="account.group_show_line_subtotals_tax_included">Amount</span>
<xpath expr="//th[@name='th_subtotal']/span" position="replace">
<span>Amount</span>
</xpath>
<xpath expr="//th[@name='th_total']/span" position="replace"/>
<span t-field="line.price_subtotal" position="attributes">
<attribute name="t-field"></attribute>
<attribute name="t-out">l10n_ar_values['price_subtotal']</attribute>
<attribute name="t-options">{"widget": "monetary", "display_currency": o.currency_id}</attribute>
</span>
<!-- if b2c we still wants the latam subtotal -->
<span t-field="line.price_total" position="attributes">
<attribute name="t-field"></attribute>
<attribute name="t-out">l10n_ar_values['price_subtotal']</attribute>
<attribute name="t-options">{"widget": "monetary", "display_currency": o.currency_id}</attribute>
</span>
<span t-field="line.price_total" position="replace"/>
<t t-set="tax_totals" position="attributes">
<attribute name="t-value">o._l10n_ar_get_invoice_totals_for_report()</attribute>
+6 -2
View File
@@ -170,16 +170,20 @@
<attribute name="t-value">current_subtotal + l10n_cl_values['price_subtotal']</attribute>
</t>
<xpath expr="//th[@name='th_subtotal']/span[@groups='account.group_show_line_subtotals_tax_included']" position="replace">
<span groups="account.group_show_line_subtotals_tax_included">Amount</span>
<xpath expr="//th[@name='th_subtotal']/span" position="replace">
<span>Amount</span>
</xpath>
<xpath expr="//th[@name='th_total']/span" position="replace"/>
<span t-field="line.price_subtotal" position="attributes">
<attribute name="t-field"></attribute>
<attribute name="t-out">l10n_cl_values['price_subtotal']</attribute>
<attribute name="t-options">{"widget": "monetary", "display_currency": o.currency_id}</attribute>
</span>
<span t-field="line.price_total" position="replace"/>
<t t-set="tax_totals" position="attributes">
<attribute name="t-value">o._l10n_cl_get_invoice_totals_for_report()</attribute>
</t>
@@ -264,12 +264,9 @@
<t t-set="lines"
t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>
<t t-foreach="lines" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"
groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total"
groups="account.group_show_line_subtotals_tax_included"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_subtotal + line.price_total" t-if="o.tax_calculation_rounding_method == 'round_per_line'"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="line.display_type not in ('line_note', 'line_section')" name="account_invoice_line_accountable">
+7 -2
View File
@@ -121,6 +121,9 @@ class PurchaseOrder(models.Model):
# Avoid access error on fiscal position, when reading a purchase order with company != user.company_ids
compute_sudo=True,
help="Technical field to filter the available taxes depending on the fiscal country and fiscal position.")
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
string='Tax calculation rounding method', readonly=True)
payment_term_id = fields.Many2one('account.payment.term', 'Payment Terms', domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
incoterm_id = fields.Many2one('account.incoterms', 'Incoterm', states={'done': [('readonly', True)]}, help="International Commercial Terms are a series of predefined commercial terms used in international transactions.")
@@ -189,7 +192,7 @@ class PurchaseOrder(models.Model):
return result
@api.depends('order_line.taxes_id', 'order_line.price_subtotal', 'amount_total', 'amount_untaxed')
def _compute_tax_totals(self):
def _compute_tax_totals(self):
for order in self:
order_lines = order.order_line.filtered(lambda x: not x.display_type)
order.tax_totals = self.env['account.tax']._prepare_tax_totals(
@@ -966,7 +969,9 @@ class PurchaseOrderLine(models.Model):
product_packaging_id = fields.Many2one('product.packaging', string='Packaging', domain="[('purchase', '=', True), ('product_id', '=', product_id)]", check_company=True,
compute="_compute_product_packaging_id", store=True, readonly=False)
product_packaging_qty = fields.Float('Packaging Quantity', compute="_compute_product_packaging_qty", store=True, readonly=False)
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
string='Tax calculation rounding method', readonly=True)
display_type = fields.Selection([
('line_section', "Section"),
('line_note', "Note")], default=False, help="Technical field for UX purpose.")
@@ -53,14 +53,19 @@
<th name="th_date_req" class="text-center"><strong>Date Req.</strong></th>
<th name="th_quantity" class="text-end"><strong>Qty</strong></th>
<th name="th_price_unit" class="text-end"><strong>Unit Price</strong></th>
<th name="th_amount" class="text-end"><strong>Amount</strong></th>
<th name="th_subtotal" class="text-end">
<strong>Tax excl.</strong>
</th>
<th t-if="o.company_id.tax_calculation_rounding_method == 'round_per_line'" name="th_total" class="text-end">
<strong>Tax incl.</strong>
</th>
</tr>
</thead>
<tbody>
<t t-set="current_subtotal" t-value="0"/>
<t t-foreach="o.order_line" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_subtotal + line.price_total" t-if="o.company_id.tax_calculation_rounding_method == 'round_per_line'"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type">
@@ -84,6 +89,10 @@
<span t-field="line.price_subtotal"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
<td t-if="o.company_id.tax_calculation_rounding_method == 'round_per_line'" class="text-end">
<span t-field="line.price_total"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<td colspan="99" id="section">
+10 -6
View File
@@ -268,8 +268,10 @@
<span>Taxes</span>
</th>
<th class="text-end" t-if="order.state in ['purchase', 'done']" >
<span groups="account.group_show_line_subtotals_tax_excluded">Amount</span>
<span groups="account.group_show_line_subtotals_tax_included">Total Price</span>
<span>Tax excl.</span>
</th>
<th class="text-end" t-if="order.state in ['purchase', 'done'] and order.tax_calculation_rounding_method == 'round_per_line'" >
<span>Tax incl.</span>
</th>
</tr>
</thead>
@@ -279,8 +281,8 @@
<t t-foreach="order.order_line" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_subtotal + line.price_total" t-if="order.tax_calculation_rounding_method == 'round_per_line'"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic text-break' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type">
@@ -318,8 +320,10 @@
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.taxes_id))"/>
</td>
<td class="text-end" t-if="not update_dates and order.state in ['purchase', 'done']">
<span class="oe_order_line_price_subtotal" t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<span class="oe_order_line_price_total" t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<span class="oe_order_line_price_subtotal" t-field="line.price_subtotal"/>
</td>
<td class="text-end" t-if="not update_dates and order.state in ['purchase', 'done'] and order.tax_calculation_rounding_method == 'round_per_line'" >
<span class="oe_order_line_price_total" t-field="line.price_total"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
+23 -8
View File
@@ -178,6 +178,7 @@
<field name="id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="currency_id" invisible="1" groups="!base.group_multi_currency"/>
<field name="tax_calculation_rounding_method" invisible="1"/>
</group>
<group>
<field name="date_order" attrs="{'invisible': [('state','in',('purchase','done'))]}"/>
@@ -219,6 +220,7 @@
<create name="add_section_control" string="Add a section" context="{'default_display_type': 'line_section'}"/>
<create name="add_note_control" string="Add a note" context="{'default_display_type': 'line_note'}"/>
</control>
<field name="tax_calculation_rounding_method" invisible="1"/>
<field name="display_type" invisible="1"/>
<field name="currency_id" invisible="1"/>
<field name="state" invisible="1"/>
@@ -257,11 +259,14 @@
<field name="price_unit" attrs="{'readonly': [('qty_invoiced', '!=', 0)]}"/>
<button name="action_purchase_history" type="object" icon="fa-history" title="Purchase History" attrs="{'invisible': [('id', '=', False)]}"/>
<field name="taxes_id" widget="many2many_tags" domain="[('type_tax_use','=','purchase'), ('company_id', '=', parent.company_id), ('country_id', '=', parent.tax_country_id)]" context="{'default_type_tax_use': 'purchase', 'search_view_ref': 'account.account_tax_view_search'}" options="{'no_create': True}" optional="show"/>
<field name="price_subtotal" widget="monetary"/>
<field name="price_total" invisible="1"/>
<field name="price_tax" invisible="1"/>
<field name="price_subtotal" string="Tax excl."/>
<field name="price_total"
string="Tax incl."
attrs="{'column_invisible': [('parent.tax_calculation_rounding_method', '=', 'round_globally')]}"
optional="hide"/>
</tree>
<form string="Purchase Order Line">
<field name="tax_calculation_rounding_method" invisible="1"/>
<field name="state" invisible="1"/>
<field name="display_type" invisible="1"/>
<group attrs="{'invisible': [('display_type', '!=', False)]}">
@@ -304,18 +309,19 @@
<label for="name" string="Section Name (eg. Products, Services)" attrs="{'invisible': [('display_type', '!=', 'line_section')]}"/>
<label for="name" string="Note" attrs="{'invisible': [('display_type', '!=', 'line_note')]}"/>
<field name="name" nolabel="1" attrs="{'invisible': [('display_type', '=', False)]}"/>
</form>
<kanban class="o_kanban_mobile">
</form>
<kanban class="o_kanban_mobile">
<field name="name"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom" groups="uom.group_uom"/>
<field name="price_subtotal"/>
<field name="price_tax" invisible="1"/>
<field name="price_total" invisible="1"/>
<field name="price_total"/>
<field name="price_unit"/>
<field name="display_type"/>
<field name="taxes_id" invisible="1"/>
<field name="tax_calculation_rounding_method" invisible="1"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card oe_kanban_global_click {{ record.display_type.raw_value ? 'o_is_' + record.display_type.raw_value : '' }}">
@@ -328,18 +334,27 @@
</div>
<div class="col-4">
<strong>
<span t-esc="record.price_subtotal.value" class="float-end text-end"/>
<span>
Tax excl.: <t t-esc="record.price_subtotal.value" class="float-end text-end"/>
</span>
</strong>
</div>
</div>
<div class="row">
<div class="col-12 text-muted">
<div class="col-8 text-muted">
<span>
Quantity:
<t t-esc="record.product_qty.value"/>
<t t-esc="record.product_uom.value" groups="uom.group_uom"/>
</span>
</div>
<div class="col-4" t-if="record.tax_calculation_rounding_method.raw_value === 'round_per_line'">
<strong>
<span>
Tax incl.: <t t-esc="record.price_total.value"/>
</span>
</strong>
</div>
</div>
<div class="row">
<div class="col-12 text-muted">
+6
View File
@@ -134,6 +134,9 @@ class Repair(models.Model):
tracking = fields.Selection(string='Product Tracking', related="product_id.tracking", readonly=False)
invoice_state = fields.Selection(string='Invoice State', related='invoice_id.state')
priority = fields.Selection([('0', 'Normal'), ('1', 'Urgent')], default='0', string="Priority")
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
string='Tax calculation rounding method', readonly=True)
@api.depends('product_id')
def _compute_allowed_picking_type_ids(self):
@@ -716,6 +719,9 @@ class RepairLine(models.Model):
copy=False, readonly=True, required=True,
help='The status of a repair line is set automatically to the one of the linked repair order.')
tracking = fields.Selection(string='Product Tracking', related="product_id.tracking")
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
string='Tax calculation rounding method', readonly=True)
@api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id', 'tax_id', 'repair_id.invoice_method')
def _compute_price_total_and_subtotal(self):
+10 -4
View File
@@ -102,6 +102,7 @@
<field name="pricelist_id" groups="product.group_product_pricelist" context="{'product_id':product_id}" attrs="{'invisible':[('invoice_method','=', 'none')]}"/>
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>
<field name="currency_id" invisible="1"/>
<field name="tax_calculation_rounding_method" invisible="1"/>
</group>
</group>
<notebook>
@@ -151,8 +152,10 @@
<field name="product_uom" string="UoM" groups="uom.group_uom" optional="show"/>
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary" groups="account.group_show_line_subtotals_tax_excluded"/>
<field name="price_total" widget="monetary" groups="account.group_show_line_subtotals_tax_included"/>
<field name="price_subtotal" string="Tax excl." widget="monetary"/>
<field name="price_total" string="Tax incl." widget="monetary"
attrs="{'column_invisible': [('parent.tax_calculation_rounding_method', '=', 'round_globally')]}"
optional="hide"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
@@ -196,8 +199,11 @@
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom" optional="show"/>
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary" groups="account.group_show_line_subtotals_tax_excluded"/>
<field name="price_total" widget="monetary" groups="account.group_show_line_subtotals_tax_included"/>
<field name="price_subtotal" string="Tax excl." widget="monetary"/>
<field name="price_total" string="Tax incl." widget="monetary"
attrs="{'column_invisible': [('parent.tax_calculation_rounding_method', '=', 'round_globally')]}"
optional="hide"/>
<field name="currency_id" invisible="1"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
+11 -9
View File
@@ -83,14 +83,16 @@
<td style="width: 150px;"><span style="font-weight:bold;">Products</span></td>
<td></td>
<td width="15%" align="center"><span style="font-weight:bold;">Quantity</span></td>
<td width="20%" align="right"><span style="font-weight:bold;">
<t t-if="object.user_id.has_group('account.group_show_line_subtotals_tax_excluded')">
VAT Excl.
</t>
<t t-else="">
VAT Incl.
</t>
</span></td>
<td width="20%" align="right">
<span style="font-weight:bold;">
<t t-if="object.company_id.tax_calculation_rounding_method == 'round_per_line'">
VAT Excl.
</t>
<t t-else="">
VAT Incl.
</t>
</span>
</td>
</tr>
</table>
<t t-foreach="object.order_line" t-as="line">
@@ -121,7 +123,7 @@
<td align="left" t-out="line.product_id.name or ''"> Taking care of Trees Course</td>
<td width="15%" align="center" t-out="line.product_uom_qty or ''">1</td>
<td width="20%" align="right"><span style="font-weight:bold;">
<t t-if="object.user_id.has_group('account.group_show_line_subtotals_tax_excluded')">
<t t-if="object.company_id.tax_calculation_rounding_method == 'round_per_line'">
<t t-out="format_amount(line.price_reduce_taxexcl, object.currency_id) or ''">$ 10.00</t>
</t>
<t t-else="">
+3
View File
@@ -274,6 +274,9 @@ class SaleOrder(models.Model):
partner_credit_warning = fields.Text(
compute='_compute_partner_credit_warning',
groups='account.group_account_invoice,account.group_account_readonly')
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
depends=['company_id'])
tax_country_id = fields.Many2one(
comodel_name='res.country',
compute='_compute_tax_country_id',
+3
View File
@@ -255,6 +255,9 @@ class SaleOrderLine(models.Model):
compute='_compute_product_updatable')
product_uom_readonly = fields.Boolean(
compute='_compute_product_uom_readonly')
tax_calculation_rounding_method = fields.Selection(
related='company_id.tax_calculation_rounding_method',
string='Tax calculation rounding method', readonly=True)
#=== COMPUTE METHODS ===#
@@ -78,8 +78,10 @@
</th>
<th name="th_taxes" class="text-end">Taxes</th>
<th name="th_subtotal" class="text-end">
<span groups="account.group_show_line_subtotals_tax_excluded">Amount</span>
<span groups="account.group_show_line_subtotals_tax_included">Total Price</span>
<span>Tax excl.</span>
</th>
<th t-if="doc.company_id.tax_calculation_rounding_method == 'round_per_line'" name="th_total" class="text-end">
<span>Tax incl.</span>
</th>
</tr>
</thead>
@@ -89,8 +91,8 @@
<t t-foreach="lines_to_report" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_subtotal + line.price_total" t-if="doc.company_id.tax_calculation_rounding_method == 'round_per_line'"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type">
@@ -109,8 +111,10 @@
<span t-out="', '.join(map(lambda x: (x.description or x.name), line.tax_id))"/>
</td>
<td t-if="not line.is_downpayment" name="td_subtotal" class="text-end o_price_total">
<span t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<span t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<span t-field="line.price_subtotal"/>
</td>
<td name="td_total" class="text-end o_price_total" t-if="doc.company_id.tax_calculation_rounding_method == 'round_per_line'" >
<span t-field="line.price_total"/>
</td>
</t>
<t t-elif="line.display_type == 'line_section'">
+17 -5
View File
@@ -285,6 +285,7 @@
<field name="currency_id" invisible="1"/>
<field name="pricelist_id" invisible="1" groups="!product.group_product_pricelist"/>
<field name="tax_country_id" invisible="1"/>
<field name="tax_calculation_rounding_method" invisible="1"/>
<field name="payment_term_id" options="{'no_open':True,'no_create': True}"/>
</group>
</group>
@@ -520,8 +521,13 @@
/>
<field name="discount" string="Disc.%" groups="product.group_discount_per_so_line" optional="show" widget="sol_discount"/>
<field name="is_downpayment" invisible="1"/>
<field name="price_subtotal" widget="monetary" groups="account.group_show_line_subtotals_tax_excluded" attrs="{'invisible': [('is_downpayment', '=', True)]}"/>
<field name="price_total" widget="monetary" groups="account.group_show_line_subtotals_tax_included" attrs="{'invisible': [('is_downpayment', '=', True)]}"/>
<field name="price_subtotal" string="Tax excl." attrs="{'invisible': [('is_downpayment', '=', True)]}"/>
<field name="price_total"
string="Tax incl."
attrs="{'column_invisible': [('parent.tax_calculation_rounding_method', '=', 'round_globally')],'invisible': [('is_downpayment', '=', True)]}"
optional="hide"/>
<!-- Others fields -->
<field name="tax_calculation_rounding_method" invisible="1"/>
<field name="state" invisible="1"/>
<field name="invoice_status" invisible="1"/>
<field name="currency_id" invisible="1"/>
@@ -541,6 +547,7 @@
<field name="display_type"/>
<field name="tax_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="tax_calculation_rounding_method" invisible="1"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card oe_kanban_global_click ps-0 pe-0 {{ record.display_type.raw_value ? 'o_is_' + record.display_type.raw_value : '' }}">
@@ -555,8 +562,8 @@
<strong t-out="record.product_id.value" />
</div>
<div class="col-auto">
<t t-set="line_price" t-value="record.price_subtotal.value" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="line_price" t-value="record.price_total.value" groups="account.group_show_line_subtotals_tax_included"/>
<strong>Tax excl.: </strong>
<t t-set="line_price" t-value="record.price_subtotal.value"/>
<strong class="float-end text-end" t-out="line_price" />
</div>
</div>
@@ -567,10 +574,15 @@
</div>
</div>
<div class="row">
<div class="col-12 text-muted">
<div class="col text-muted">
Unit Price:
<t t-out="record.price_unit.value"/>
</div>
<div class="col-auto" t-if="record.tax_calculation_rounding_method.raw_value === 'round_per_line'">
<strong>Tax incl.: </strong>
<t t-set="line_price" t-value="record.price_total.value"/>
<strong class="float-end text-end" t-out="line_price" />
</div>
</div>
</div>
</div>
+11 -7
View File
@@ -478,9 +478,11 @@
<th t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Taxes</span>
</th>
<th class="text-end" >
<span groups="account.group_show_line_subtotals_tax_excluded">Amount</span>
<span groups="account.group_show_line_subtotals_tax_included">Total Price</span>
<th class="text-end">
<span>Tax excl.</span>
</th>
<th class="text-end" t-if="sale_order.tax_calculation_rounding_method == 'round_per_line'">
<span>Tax incl.</span>
</th>
</tr>
</thead>
@@ -491,8 +493,8 @@
<t t-foreach="lines_to_report" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_subtotal + line.price_total" t-if="sale_order.tax_calculation_rounding_method == 'round_per_line'"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type">
@@ -525,8 +527,10 @@
<span t-out="', '.join(map(lambda x: (x.description or x.name), line.tax_id))"/>
</td>
<td t-if="not line.is_downpayment" class="text-end">
<span class="oe_order_line_price_subtotal" t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<span class="oe_order_line_price_total" t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<span class="oe_order_line_price_subtotal" t-field="line.price_subtotal"/>
</td>
<td class="text-end" t-if="sale_order.tax_calculation_rounding_method == 'round_per_line' and not line.is_downpayment" >
<span class="oe_order_line_price_total" t-field="line.price_total"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
@@ -18,7 +18,7 @@ registry.category("web_tour.tours").add('event_sale_with_product_configurator_to
trigger: '.ui-menu-item > a:contains("Tajine Saucisse")',
auto: true,
}, {
trigger: "a:contains('Add a product')",
trigger: 'a:contains("Add a product")',
}, {
trigger: 'div[name="product_template_id"] input',
run: 'text event (',
@@ -48,7 +48,7 @@ registry.category("web_tour.tours").add('event_sale_with_product_configurator_to
trigger: '.o_event_sale_js_event_configurator_ok'
}, {
trigger: 'a:contains("Add a product")',
extra_trigger: '.o_monetary_cell span:contains("16.50")', // wait for the optional product line
extra_trigger: 'td[name="price_subtotal"]:contains("16.50")', // wait for the optional product line
}, {
trigger: 'div[name="product_template_id"] input',
extra_trigger: '[name="product_template_id"] .o_dropdown_button',
@@ -84,7 +84,7 @@ registry.category("web_tour.tours").add('event_sale_with_product_configurator_to
trigger: '.o_event_sale_js_event_configurator_ok'
}, {
trigger: 'a:contains("Add a product")',
extra_trigger: '.o_monetary_cell span:contains("150.00")', // wait for the adult tickets line
extra_trigger: 'td[name="price_subtotal"]:contains("150.00")', // wait for the adult tickets line
}, {
trigger: 'div[name="product_template_id"] input',
extra_trigger: '[name="product_template_id"] .o_dropdown_button',
@@ -45,31 +45,31 @@ registry.category("web_tour.tours").add('event_booth_sale_pricelists_different_c
...getPriceListChecksSteps({
pricelistName: "EUR With Discount Included",
eventName: "Test Event Booths",
price: "90.00",
priceSelected: "90",
price: "99.00",
priceSelected: "99",
priceCart: "99.00",
}),
...getPriceListChecksSteps({
pricelistName: "EUR Without Discount Included",
eventName: "Test Event Booths",
price: "90.00",
priceSelected: "90",
price: "99.00",
priceSelected: "99",
priceCart: "99.00",
priceBeforeDiscount: "100.00",
priceBeforeDiscount: "110.00",
}),
...getPriceListChecksSteps({
pricelistName: "EX With Discount Included",
eventName: "Test Event Booths",
price: "900.00",
priceSelected: "900",
price: "990.00",
priceSelected: "990",
priceCart: "990.00",
}),
...getPriceListChecksSteps({
pricelistName: "EX Without Discount Included",
eventName: "Test Event Booths",
price: "900.00",
priceSelected: "900",
price: "990.00",
priceSelected: "990",
priceCart: "990.00",
priceBeforeDiscount: "1,000.00",
priceBeforeDiscount: "1,100.00",
}),
]});
@@ -15,7 +15,7 @@ class TestWebsiteEventBoothSale(HttpCase, TestWebsiteEventSaleCommon):
def setUp(self):
super().setUp()
self.env['ir.config_parameter'].sudo().set_param('account.show_line_subtotals_tax_selection', 'tax_included')
self.env["res.company"].sudo().search([]).show_line_subtotals_tax_selection = 'tax_included'
self.tax = self.env['account.tax'].sudo().create({
'name': 'Tax 10',
'amount': 10,
@@ -4,24 +4,30 @@
<template id="event_booth_registration" inherit_id="website_event_booth.event_booth_registration">
<xpath expr="//h5[@name='booth_category_name']" position="after">
<t t-if="booth_category.price">
<t t-if="(booth_category.price - booth_category.price_reduce) &gt; 1 and website.get_current_pricelist().discount_policy == 'without_discount'">
<t t-if="(booth_category.price - booth_category.price_reduce) &gt; 0 and website.get_current_pricelist().discount_policy == 'without_discount'">
<del class="text-danger me-1"
t-field="booth_category.price"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.get_current_pricelist().currency_id}"/>
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.get_current_pricelist().currency_id}"
t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'"/>
<del class="text-danger me-1"
t-field="booth_category.price_incl"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.get_current_pricelist().currency_id}"
t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'"/>
</t>
<span t-field="booth_category.price_reduce" class="fw-normal text-muted"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
groups="account.group_show_line_subtotals_tax_excluded"/>
t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'"/>
<span t-field="booth_category.price_reduce_taxinc" class="fw-normal text-muted"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
groups="account.group_show_line_subtotals_tax_included"/>
t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'"/>
</t>
<span t-else="" class="fw-normal text-muted">Free</span>
</xpath>
<xpath expr="//input[@name='booth_category_id']" position="attributes">
<attribute name="t-att-data-price">
event.company_id.sudo().currency_id._convert(
booth_category.price_reduce_taxinc if env.user.has_group('account.group_show_line_subtotals_tax_included') else booth_category.price_reduce,
booth_category.price_reduce_taxinc if env.company.show_line_subtotals_tax_selection == 'tax_included' else booth_category.price_reduce,
website.get_current_pricelist().currency_id,
event.company_id,
datetime.date.today()
@@ -15,15 +15,22 @@
<!-- Add price information on tickets (multi tickets, aka in collapse) -->
<xpath expr="//div[hasclass('o_wevent_registration_multi_select')]" position="inside">
<t t-if="ticket.price">
<t t-if="(ticket.price - ticket.price_reduce) &gt; 1 and website.pricelist_id and website.pricelist_id.discount_policy == 'without_discount'">
<del class="text-danger me-1" t-field="ticket.price" t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"/>
<t t-if="(ticket.price - ticket.price_reduce) &gt; 0 and website.pricelist_id and website.pricelist_id.discount_policy == 'without_discount'">
<del class="text-danger me-1"
t-field="ticket.price"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'"/>
<del class="text-danger me-1"
t-field="ticket.price_incl"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'"/>
</t>
<span t-field="ticket.price_reduce"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
groups="account.group_show_line_subtotals_tax_excluded"/>
t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'"/>
<span t-field="ticket.price_reduce_taxinc"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
groups="account.group_show_line_subtotals_tax_included"/>
t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'"/>
<span itemprop="price" class="d-none" t-out="ticket.price"/>
<span itemprop="priceCurrency" class="d-none" t-out="website.currency_id.name"/>
</t>
@@ -48,15 +55,22 @@
<xpath expr="//div[hasclass('o_wevent_registration_single')]//h6" position="after">
<div class="px-2 text-dark d-flex align-items-center align-self-stretch">
<t t-if="tickets.price">
<t t-if="(tickets.price - tickets.price_reduce) &gt;1 and website.pricelist_id and website.get_current_pricelist().discount_policy == 'without_discount'">
<del class="text-danger me-1" t-field="tickets.price" t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"/>
<t t-if="(tickets.price - tickets.price_reduce) &gt;0 and website.pricelist_id and website.get_current_pricelist().discount_policy == 'without_discount'">
<del class="text-danger me-1"
t-field="tickets.price"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'"/>
<del class="text-danger me-1"
t-field="tickets.price_incl"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'"/>
</t>
<span t-field="tickets.price_reduce"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
groups="account.group_show_line_subtotals_tax_excluded"/>
t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'"/>
<span t-field="tickets.price_reduce_taxinc"
t-options="{'widget': 'monetary', 'from_currency': event.company_id.sudo().currency_id, 'display_currency': website.currency_id}"
groups="account.group_show_line_subtotals_tax_included"/>
t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'"/>
<span itemprop="price" class="d-none" t-out="tickets.price"/>
<span itemprop="priceCurrency" class="d-none" t-out="website.currency_id.name"/>
</t>
@@ -99,7 +99,7 @@ class Product(models.Model):
def _get_contextual_price_tax_selection(self):
self.ensure_one()
price = self._get_contextual_price()
line_tax_type = self.env['ir.config_parameter'].sudo().get_param('account.show_line_subtotals_tax_selection')
line_tax_type = self.env.company.show_line_subtotals_tax_selection
if line_tax_type == "tax_included" and self.taxes_id:
price = self.taxes_id.compute_all(price, product=self, partner=self.env['res.partner'])['total_included']
return price
@@ -189,7 +189,7 @@ class ProductTemplate(models.Model):
price_reduce = self.env['account.tax']._fix_tax_included_price_company(
price_reduce, product_taxes, taxes, self.env.company)
tax_display = self.user_has_groups('account.group_show_line_subtotals_tax_excluded') and 'total_excluded' or 'total_included'
tax_display = 'total_excluded' if self.env.company.show_line_subtotals_tax_selection == 'tax_excluded' else 'total_included'
price_reduce = taxes.compute_all(price_reduce, currency, 1, template, partner_sudo)[tax_display]
template_price_vals = {
@@ -316,8 +316,8 @@ class ProductTemplate(models.Model):
price = self.env['account.tax']._fix_tax_included_price_company(
price, product_taxes, taxes, company_id
)
show_tax_excluded = self.user_has_groups('account.group_show_line_subtotals_tax_excluded')
tax_display = 'total_excluded' if show_tax_excluded else 'total_included'
show_tax = self.env.company.show_line_subtotals_tax_selection
tax_display = 'total_excluded' if show_tax == 'tax_excluded' else 'total_included'
# The list_price is always the price of one.
return taxes.compute_all(price, currency, 1, product, partner)[tax_display]
@@ -7,6 +7,11 @@ from odoo import api, fields, models
class ResCompany(models.Model):
_inherit = 'res.company'
show_line_subtotals_tax_selection = fields.Selection([
('tax_excluded', 'Tax Excluded'),
('tax_included', 'Tax Included')], string="Line Subtotals Tax Display",
required=True, default='tax_excluded',
)
website_sale_onboarding_payment_provider_state = fields.Selection([('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done")], string="State of the website sale onboarding payment provider step", default='not_done')
@api.model
@@ -63,6 +63,11 @@ class ResConfigSettings(models.TransientModel):
website_sale_prevent_zero_price_sale = fields.Boolean(string="Prevent Sale of Zero Priced Product", related='website_id.prevent_zero_price_sale', readonly=False)
website_sale_contact_us_button_url = fields.Char(string="Button URL", related='website_id.contact_us_button_url', readonly=False)
website_sale_enabled_portal_reorder_button = fields.Boolean(string="Re-order From Portal", related='website_id.enabled_portal_reorder_button', readonly=False)
show_line_subtotals_tax_selection = fields.Selection(
required=True,
readonly=False,
related="company_id.show_line_subtotals_tax_selection",
)
@api.depends('website_id')
def _compute_terms_url(self):
@@ -188,8 +188,6 @@ odoo.define('website_sale_tour.tour', function (require) {
args: [{
'auth_signup_uninvited': 'b2b',
'show_line_subtotals_tax_selection': 'tax_included',
'group_show_line_subtotals_tax_excluded': false,
'group_show_line_subtotals_tax_included': true,
}],
});
var def2 = def1.then(function (resId) {
+1
View File
@@ -21,5 +21,6 @@ from . import test_website_sale_visitor
from . import test_website_sale_product
from . import test_website_sale_shop_variant_exclusion
from . import test_website_editor
from . import test_setting
from . import test_website_sale_reorder_from_portal
from . import test_website_sale_snippets
@@ -119,8 +119,6 @@ class TestUi(HttpCaseWithUserDemo):
self.env['res.config.settings'].create({
'auth_signup_uninvited': 'b2c',
'show_line_subtotals_tax_selection': 'tax_excluded',
'group_show_line_subtotals_tax_excluded': True,
'group_show_line_subtotals_tax_included': False,
}).execute()
self.start_tour("/", 'website_sale_tour_1')
@@ -15,26 +15,9 @@ class TestSettings(AccountTestInvoicingCommon):
# at each setting change, all users should be removed from one group and added to the other
# so picking an arbitrary witness should be equivalent to checking that everything worked.
config = self.env['res.config.settings'].create({})
self.switch_tax_settings(config)
def switch_tax_settings(self, config):
config.show_line_subtotals_tax_selection = "tax_excluded"
config.flush_recordset()
config.execute()
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_excluded'), True)
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_included'), False)
config.show_line_subtotals_tax_selection = "tax_included"
config.flush_recordset()
config.execute()
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_excluded'), False)
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_included'), True)
self.assertEqual(self.env.user.company_id.show_line_subtotals_tax_selection, "tax_included")
config.show_line_subtotals_tax_selection = "tax_excluded"
config.flush_recordset()
config.execute()
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_excluded'), True)
self.assertEqual(self.env.user.has_group('account.group_show_line_subtotals_tax_included'), False)
def test_switch_taxB2B_taxB2C_multicompany(self):
"""
@@ -43,15 +26,15 @@ class TestSettings(AccountTestInvoicingCommon):
if one is done in SQL and the other via the ORM.
Because the latter automatically takes into account record rules that
might make some users invisible.
This one is identical to the previous, except that we do the actions
with a non-superuser user, and in a new company with one user in common
with another company which has a different taxB2X setting.
"""
user = self.env.ref('base.user_admin')
company = self.env['res.company'].create({'name': 'oobO'})
user.write({'company_ids': [(4, company.id)], 'company_id': company.id})
Settings = self.env['res.config.settings'].with_user(user.id)
config = Settings.create({})
self.switch_tax_settings(config)
Settings = self.env['res.config.settings'].with_user(self.env.user.id)
config = Settings.create({})
config.show_line_subtotals_tax_selection = "tax_included"
self.assertEqual(self.env.user.company_id.show_line_subtotals_tax_selection, "tax_included")
self.env.user.company_id = self.company_data_2["company"].id
self.assertEqual(self.env.user.company_id.show_line_subtotals_tax_selection, "tax_excluded")
@@ -58,10 +58,7 @@ class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, Tes
self.assertEqual(combination_info['has_discounted_price'], False)
# CASE: B2C setting
group_tax_included = self.env.ref('account.group_show_line_subtotals_tax_included').with_context(active_test=False)
group_tax_excluded = self.env.ref('account.group_show_line_subtotals_tax_excluded').with_context(active_test=False)
group_tax_excluded.users -= self.env.user
group_tax_included.users |= self.env.user
self.env.company.show_line_subtotals_tax_selection = 'tax_included'
combination_info = product_template._get_combination_info(pricelist=pricelist)
self.assertEqual(combination_info['price'], 2222 * discount_rate * currency_ratio * tax_ratio)
@@ -119,10 +116,7 @@ class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, Tes
computer_ssd_attribute_lines.product_template_value_ids[0].price_extra = 200
# Enable tax included
group_tax_included = self.env.ref('account.group_show_line_subtotals_tax_included').with_context(active_test=False)
group_tax_excluded = self.env.ref('account.group_show_line_subtotals_tax_excluded').with_context(active_test=False)
group_tax_excluded.users -= self.env.user
group_tax_included.users |= self.env.user
self.env.company.show_line_subtotals_tax_selection = 'tax_included'
combination_info = product._get_combination_info(pricelist=pricelist)
self.assertEqual(combination_info['price'], 575, "500$ + 15% tax")
@@ -77,8 +77,6 @@
<div class="content-group">
<div class="mt16">
<field name="show_line_subtotals_tax_selection" class="o_light_label" widget="radio"/>
<field name="group_show_line_subtotals_tax_included" invisible="1"/>
<field name="group_show_line_subtotals_tax_excluded" invisible="1"/>
</div>
</div>
</setting>
+6 -6
View File
@@ -1141,10 +1141,10 @@
</template>
<template id="website_sale.tax_indication" active="False">
<span groups="account.group_show_line_subtotals_tax_excluded" class="h6 text-muted">
<span t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'" class="h6 text-muted">
VAT Excluded
</span>
<span groups="account.group_show_line_subtotals_tax_included" class="h6 text-muted">
<span t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'" class="h6 text-muted">
VAT Included
</span>
</template>
@@ -1450,10 +1450,10 @@
<t t-set="combination" t-value="line.product_id.product_template_attribute_value_ids + line.product_no_variant_attribute_value_ids"/>
<t t-set="combination_info" t-value="line.product_id.product_tmpl_id._get_combination_info(combination, pricelist=website_sale_order.pricelist_id, add_qty=line.product_uom_qty)"/>
<t groups="account.group_show_line_subtotals_tax_excluded">
<t t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'">
<span t-field="line.price_reduce_taxexcl" style="white-space: nowrap;" t-options="{'widget': 'monetary', 'display_currency': website_sale_order.currency_id}"/>
</t>
<t groups="account.group_show_line_subtotals_tax_included">
<t t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'">
<span t-field="line.price_reduce_taxinc" style="white-space: nowrap;" t-options="{'widget': 'monetary', 'display_currency': website_sale_order.currency_id}"/>
</t>
<t t-if="line.discount">
@@ -2117,8 +2117,8 @@
</t>
</td>
<td class="text-center td-price">
<span t-field="line.price_reduce_taxexcl" style="white-space: nowrap;" t-options="{'widget': 'monetary', 'display_currency': website_sale_order.currency_id}" groups="account.group_show_line_subtotals_tax_excluded" />
<span t-field="line.price_reduce_taxinc" style="white-space: nowrap;" t-options="{'widget': 'monetary', 'display_currency': website_sale_order.currency_id}" groups="account.group_show_line_subtotals_tax_included" />
<span t-field="line.price_reduce_taxexcl" style="white-space: nowrap;" t-options="{'widget': 'monetary', 'display_currency': website_sale_order.currency_id}" t-if="env.company.show_line_subtotals_tax_selection == 'tax_excluded'"/>
<span t-field="line.price_reduce_taxinc" style="white-space: nowrap;" t-options="{'widget': 'monetary', 'display_currency': website_sale_order.currency_id}" t-if="env.company.show_line_subtotals_tax_selection == 'tax_included'"/>
</td>
</tr>
</tbody>
@@ -274,9 +274,7 @@ class WebsiteSaleDelivery(WebsiteSale):
product=carrier.product_id,
partner=order.partner_shipping_id,
)
if not is_express_checkout_flow and request.env.user.has_group(
'account.group_show_line_subtotals_tax_excluded'
):
if not is_express_checkout_flow and request.env.company.show_line_subtotals_tax_selection == 'tax_excluded':
rate['price'] = taxes['total_excluded']
else:
rate['price'] = taxes['total_included']
@@ -16,7 +16,7 @@ class SaleOrder(models.Model):
@api.depends('order_line.price_unit', 'order_line.tax_id', 'order_line.discount', 'order_line.product_uom_qty')
def _compute_amount_delivery(self):
for order in self:
if self.env.user.has_group('account.group_show_line_subtotals_tax_excluded'):
if self.env.company.show_line_subtotals_tax_selection == 'tax_excluded':
order.amount_delivery = sum(order.order_line.filtered('is_delivery').mapped('price_subtotal'))
else:
order.amount_delivery = sum(order.order_line.filtered('is_delivery').mapped('price_total'))