From e64f03c185a899ede0335aaa163fa88907a88457 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Wed, 21 Oct 2020 14:02:58 +0000 Subject: [PATCH] [IMP] *: restrict the deletion of used currencies --- addons/lunch/models/lunch_cashmove.py | 2 +- addons/sale/models/sale.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/lunch/models/lunch_cashmove.py b/addons/lunch/models/lunch_cashmove.py index bb7a0380c3b..a0125ac4073 100644 --- a/addons/lunch/models/lunch_cashmove.py +++ b/addons/lunch/models/lunch_cashmove.py @@ -11,7 +11,7 @@ class LunchCashMove(models.Model): _description = 'Lunch Cashmove' _order = 'date desc' - currency_id = fields.Many2one('res.currency', default=lambda self: self.env.company.currency_id) + currency_id = fields.Many2one('res.currency', default=lambda self: self.env.company.currency_id, required=True) user_id = fields.Many2one('res.users', 'User', default=lambda self: self.env.uid) date = fields.Date('Date', required=True, default=fields.Date.context_today) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 914ad11148c..e3f24dcb0f1 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -190,7 +190,7 @@ class SaleOrder(models.Model): required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", tracking=1, help="If you change the pricelist, only newly added lines will be affected.") - currency_id = fields.Many2one(related='pricelist_id.currency_id', depends=["pricelist_id"], store=True) + currency_id = fields.Many2one(related='pricelist_id.currency_id', depends=["pricelist_id"], store=True, ondelete="restrict") analytic_account_id = fields.Many2one( 'account.analytic.account', 'Analytic Account', readonly=True, copy=False, check_company=True, # Unrequired company