[FIX] event_sale, website_event_sale: price tax included

Commit 5f5f8d8efe 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
This commit is contained in:
Nicolas Martinelli
2017-01-18 10:01:54 +01:00
parent 8e94783778
commit 41740aad0d
2 changed files with 13 additions and 1 deletions
+8
View File
@@ -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):
@@ -51,7 +51,11 @@
<span t-field="ticket.price_reduce" t-options='{
"widget": "monetary",
"display_currency": website.pricelist_id.currency_id
}'/>
}' groups="sale.group_show_price_subtotal"/>
<span t-field="ticket.price_reduce_taxinc" t-options='{
"widget": "monetary",
"display_currency": website.pricelist_id.currency_id
}' groups="sale.group_show_price_total"/>
<span itemprop="price" style="display:none;" t-esc="ticket.price"/>
<span itemprop="priceCurrency" style="display:none;" t-esc="website.pricelist_id.currency_id.name"/>
</t>