[FIX] account: default date_format on res_lang lookup

Steps to reproduce:
-install accounting
-go to accounting > accounting > assets
-create a deprecable asset (account moves for deprecations
are set automatically)
-change your user's language to blank
-try to post one of the automatically created deprecations line

Previous behavior:
you get a traceback error
"TypeError: strftime() argument 1 must be str, not bool"

Current behavior:
you get the intended error message

opw-2162318

closes odoo/odoo#42641

X-original-commit: 6cd38a64893428db5c2b30e85b09a34b90aa8f4f
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
jerome hanke (jhk)
2020-01-02 17:33:37 +00:00
parent a45c1b53cc
commit c8841c8eca
+2 -2
View File
@@ -2053,7 +2053,7 @@ class AccountMove(models.Model):
if not move.line_ids.filtered(lambda line: not line.display_type):
raise UserError(_('You need to add a line before posting.'))
if move.auto_post and move.date > fields.Date.today():
date_msg = move.date.strftime(self.env['res.lang']._lang_get(self.env.user.lang).date_format)
date_msg = move.date.strftime(get_lang(self.env).date_format)
raise UserError(_("This move is configured to be auto-posted on %s" % date_msg))
if not move.partner_id:
@@ -2084,7 +2084,7 @@ class AccountMove(models.Model):
self.mapped('line_ids').create_analytic_lines()
for move in self:
if move.auto_post and move.date > fields.Date.today():
raise UserError(_("This move is configured to be auto-posted on {}".format(move.date.strftime(self.env['res.lang']._lang_get(self.env.user.lang).date_format))))
raise UserError(_("This move is configured to be auto-posted on {}".format(move.date.strftime(get_lang(self.env).date_format))))
move.message_subscribe([p.id for p in [move.partner_id, move.commercial_partner_id] if p not in move.sudo().message_partner_ids])