From 41740aad0de1634838bbbc0b6f05e84079e6474e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 17 Jan 2017 16:30:27 +0100 Subject: [PATCH] [FIX] event_sale, website_event_sale: price tax included Commit 5f5f8d8efee6 introduces the possibility to display prices for B2B or B2C channels, i.e. prices with taxes excluded or taxes included. However, the module `event_sale` was not included in this improvement. This is an issue since it is not possible to display the event ticket prices with taxes included. opw-702209 --- addons/event_sale/models/event.py | 8 ++++++++ .../views/website_event_sale_templates.xml | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/event_sale/models/event.py b/addons/event_sale/models/event.py index d5a4fdf07f0..1110072837d 100644 --- a/addons/event_sale/models/event.py +++ b/addons/event_sale/models/event.py @@ -44,6 +44,7 @@ class EventTicket(models.Model): is_expired = fields.Boolean(string='Is Expired', compute='_compute_is_expired') price_reduce = fields.Float(string="Price Reduce", compute="_compute_price_reduce", digits=dp.get_precision('Product Price')) + price_reduce_taxinc = fields.Float(compute='_get_price_reduce_tax', string='Price Reduce Tax inc') # seats fields seats_availability = fields.Selection([('limited', 'Limited'), ('unlimited', 'Unlimited')], string='Available Seat', required=True, store=True, compute='_compute_seats', default="limited") @@ -71,6 +72,13 @@ class EventTicket(models.Model): discount = product.lst_price and (product.lst_price - product.price) / product.lst_price or 0.0 record.price_reduce = (1.0 - discount) * record.price + def _get_price_reduce_tax(self): + for record in self: + # sudo necessary here since the field is most probably accessed through the website + tax_ids = record.sudo().product_id.taxes_id.filtered(lambda r: r.company_id == record.event_id.company_id) + taxes = tax_ids.compute_all(record.price_reduce, record.event_id.company_id.currency_id, 1.0, product=record.product_id) + record.price_reduce_taxinc = taxes['total_included'] + @api.multi @api.depends('seats_max', 'registration_ids.state') def _compute_seats(self): diff --git a/addons/website_event_sale/views/website_event_sale_templates.xml b/addons/website_event_sale/views/website_event_sale_templates.xml index edb2b1583d2..d0005892fd6 100644 --- a/addons/website_event_sale/views/website_event_sale_templates.xml +++ b/addons/website_event_sale/views/website_event_sale_templates.xml @@ -51,7 +51,11 @@ + }' groups="sale.group_show_price_subtotal"/> +