[PATCH] Upstream patch - 07022023

This commit is contained in:
Parthiv Patel
2023-02-07 08:36:25 +00:00
parent 462d87cf19
commit b8223f7af3
5 changed files with 12 additions and 6 deletions
+2 -2
View File
@@ -451,8 +451,8 @@ class AccountJournal(models.Model):
if bank_account.partner_id != company.partner_id:
raise UserError(_("The partners of the journal's company and the related bank account mismatch."))
if 'restrict_mode_hash_table' in vals and not vals.get('restrict_mode_hash_table'):
journal_entry = self.env['account.move'].search([('journal_id', '=', self.id), ('state', '=', 'posted'), ('secure_sequence_number', '!=', 0)], limit=1)
if len(journal_entry) > 0:
journal_entry = self.env['account.move'].sudo().search([('journal_id', '=', self.id), ('state', '=', 'posted'), ('secure_sequence_number', '!=', 0)], limit=1)
if journal_entry:
field_string = self._fields['restrict_mode_hash_table'].get_description(self.env)['string']
raise UserError(_("You cannot modify the field %s of a journal that already has accounting entries.", field_string))
result = super(AccountJournal, self).write(vals)
+2 -2
View File
@@ -337,7 +337,7 @@ class AccountMove(models.Model):
# ==== Hash Fields ====
restrict_mode_hash_table = fields.Boolean(related='journal_id.restrict_mode_hash_table')
secure_sequence_number = fields.Integer(string="Inalteralbility No Gap Sequence #", readonly=True, copy=False)
secure_sequence_number = fields.Integer(string="Inalteralbility No Gap Sequence #", readonly=True, copy=False, index=True)
inalterable_hash = fields.Char(string="Inalterability Hash", readonly=True, copy=False)
string_to_hash = fields.Char(compute='_compute_string_to_hash', readonly=True)
@@ -2907,7 +2907,7 @@ class AccountMove(models.Model):
""" Returns the hash to write on journal entries when they get posted"""
self.ensure_one()
#get the only one exact previous move in the securisation sequence
prev_move = self.search([('state', '=', 'posted'),
prev_move = self.sudo().search([('state', '=', 'posted'),
('company_id', '=', self.company_id.id),
('journal_id', '=', self.journal_id.id),
('secure_sequence_number', '!=', 0),
+1 -1
View File
@@ -210,7 +210,7 @@ class ResCompany(models.Model):
error_msg = _('There are still unposted entries in the period you want to lock. You should either post or delete them.')
action_error = {
'view_mode': 'tree',
'name': 'Unposted Entries',
'name': _('Unposted Entries'),
'res_model': 'account.move',
'type': 'ir.actions.act_window',
'domain': [('id', 'in', draft_entries.ids)],
+1 -1
View File
@@ -279,7 +279,7 @@ class Repair(models.Model):
return True
def action_repair_cancel(self):
if self.state == 'done':
if any(repair.state == 'done' for repair in self):
raise UserError(_("You cannot cancel a completed repair order."))
invoice_to_cancel = self.filtered(lambda repair: repair.invoice_id.state == 'draft').invoice_id
if invoice_to_cancel:
+6
View File
@@ -997,6 +997,12 @@ Reason(s) of this behavior could be:
res[group]['amount'] += t['amount']
res[group]['base'] += t['base']
res = sorted(res.items(), key=lambda l: l[0].sequence)
# round amount and prevent -0.00
for group_data in res:
group_data[1]['amount'] = currency.round(group_data[1]['amount']) + 0.0
group_data[1]['base'] = currency.round(group_data[1]['base']) + 0.0
order.amount_by_group = [(
l[0].name, l[1]['amount'], l[1]['base'],
fmt(l[1]['amount']), fmt(l[1]['base']),