mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2026-08-19 01:34:43 -05:00
[PATCH] Upstream patch - 08062023
This commit is contained in:
@@ -2,27 +2,29 @@
|
||||
|
||||
from flectra import _, api, models
|
||||
from flectra.exceptions import UserError
|
||||
from flectra.tools import split_every
|
||||
|
||||
|
||||
class AccountTax(models.Model):
|
||||
_inherit = 'account.tax'
|
||||
|
||||
def write(self, vals):
|
||||
forbidden_fields = set([
|
||||
forbidden_fields = {
|
||||
'amount_type', 'amount', 'type_tax_use', 'tax_group_id', 'price_include',
|
||||
'include_base_amount'
|
||||
])
|
||||
}
|
||||
if forbidden_fields & set(vals.keys()):
|
||||
tax_ids = self.env['pos.order.line'].sudo().search([
|
||||
lines = self.env['pos.order.line'].sudo().search([
|
||||
('order_id.session_id.state', '!=', 'closed')
|
||||
]).read(['tax_ids'])
|
||||
# Flatten the list of taxes, see https://stackoverflow.com/questions/952914
|
||||
tax_ids = set([i for sl in [t['tax_ids'] for t in tax_ids] for i in sl])
|
||||
if tax_ids & set(self.ids):
|
||||
raise UserError(_(
|
||||
'It is forbidden to modify a tax used in a POS order not posted. '
|
||||
'You must close the POS sessions before modifying the tax.'
|
||||
))
|
||||
])
|
||||
self_ids = set(self.ids)
|
||||
for lines_chunk in map(self.env['pos.order.line'].browse, split_every(100000, lines.ids)):
|
||||
if any(tid in self_ids for ts in lines_chunk.read(['tax_ids']) for tid in ts['tax_ids']):
|
||||
raise UserError(_(
|
||||
'It is forbidden to modify a tax used in a POS order not posted. '
|
||||
'You must close the POS sessions before modifying the tax.'
|
||||
))
|
||||
lines_chunk.invalidate_cache(['tax_ids'], lines_chunk.ids)
|
||||
return super(AccountTax, self).write(vals)
|
||||
|
||||
def get_real_tax_amount(self):
|
||||
|
||||
@@ -408,7 +408,7 @@
|
||||
<t t-foreach='question.suggested_answer_ids' t-as='label'>
|
||||
<t t-set="item_idx" t-value="label_index"/>
|
||||
<t t-set="answer_selected" t-value="answer_line and answer_line.suggested_answer_id.id == label.id"/>
|
||||
<t t-set="is_correct" t-value="label.answer_score > 0.0"/>
|
||||
<t t-set="is_correct" t-value="label.is_correct"/>
|
||||
|
||||
<!--Used for print mode with corrections -->
|
||||
<t t-set="answer_class" t-if="not has_correct_answer" t-value="''" />
|
||||
@@ -471,7 +471,7 @@
|
||||
<t t-set="item_idx" t-value="label_index"/>
|
||||
<t t-set="answer_line" t-value="answer_lines.filtered(lambda line: line.suggested_answer_id == label)"/>
|
||||
<t t-set="answer_selected" t-value="answer_line and answer_line.suggested_answer_id.id == label.id"/>
|
||||
<t t-set="is_correct" t-value="label.answer_score > 0.0"/>
|
||||
<t t-set="is_correct" t-value="label.is_correct"/>
|
||||
|
||||
<!--Used for print mode with corrections -->
|
||||
<t t-set="answer_class" t-if="not has_correct_answer" t-value="''" />
|
||||
|
||||
Reference in New Issue
Block a user