diff --git a/addons/account/models/company.py b/addons/account/models/company.py
index 5ea0db1cd95..ea47862f89e 100644
--- a/addons/account/models/company.py
+++ b/addons/account/models/company.py
@@ -12,6 +12,22 @@ from odoo.tools.float_utils import float_round, float_is_zero
from odoo.tools import date_utils
+MONTH_SELECTION = [
+ ('1', 'January'),
+ ('2', 'February'),
+ ('3', 'March'),
+ ('4', 'April'),
+ ('5', 'May'),
+ ('6', 'June'),
+ ('7', 'July'),
+ ('8', 'August'),
+ ('9', 'September'),
+ ('10', 'October'),
+ ('11', 'November'),
+ ('12', 'December'),
+]
+
+
class ResCompany(models.Model):
_inherit = "res.company"
@@ -20,7 +36,7 @@ class ResCompany(models.Model):
#TODO check all the options/fields are in the views (settings + company form view)
fiscalyear_last_day = fields.Integer(default=31, required=True)
- fiscalyear_last_month = fields.Selection([(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], default=12, required=True)
+ fiscalyear_last_month = fields.Selection(MONTH_SELECTION, default='12', required=True)
period_lock_date = fields.Date(string="Lock Date for Non-Advisers", help="Only users with the 'Adviser' role can edit accounts prior to and inclusive of this date. Use it for period locking inside an open fiscal year, for example.")
fiscalyear_lock_date = fields.Date(string="Lock Date", help="No users, including Advisers, can edit accounts prior to and inclusive of this date. Use it for fiscal year locking for example.")
transfer_account_id = fields.Many2one('account.account',
@@ -93,7 +109,7 @@ Best Regards,'''))
def _check_fiscalyear_last_day(self):
# if the user explicitly chooses the 29th of February we allow it:
# there is no "fiscalyear_last_year" so we do not know his intentions.
- if self.fiscalyear_last_day == 29 and self.fiscalyear_last_month == 2:
+ if self.fiscalyear_last_day == 29 and self.fiscalyear_last_month == '2':
return
if self.account_opening_date:
@@ -101,7 +117,7 @@ Best Regards,'''))
else:
year = datetime.now().year
- max_day = calendar.monthrange(year, self.fiscalyear_last_month)[1]
+ max_day = calendar.monthrange(year, int(self.fiscalyear_last_month))[1]
if self.fiscalyear_last_day > max_day:
raise ValidationError(_("Invalid fiscal year last day"))
@@ -214,7 +230,7 @@ Best Regards,'''))
}
date_from, date_to = date_utils.get_fiscal_year(
- current_date, day=self.fiscalyear_last_day, month=self.fiscalyear_last_month)
+ current_date, day=self.fiscalyear_last_day, month=int(self.fiscalyear_last_month))
date_from_str = date_from.strftime(DEFAULT_SERVER_DATE_FORMAT)
date_to_str = date_to.strftime(DEFAULT_SERVER_DATE_FORMAT)
@@ -357,7 +373,7 @@ Best Regards,'''))
raise UserError(_("Please install a chart of accounts or create a miscellaneous journal before proceeding."))
today = datetime.today().date()
- opening_date = today.replace(month=self.fiscalyear_last_month, day=self.fiscalyear_last_day) + timedelta(days=1)
+ opening_date = today.replace(month=int(self.fiscalyear_last_month), day=self.fiscalyear_last_day) + timedelta(days=1)
if opening_date > today:
opening_date = opening_date + relativedelta(years=-1)
diff --git a/addons/account/tests/test_account_fiscal_year.py b/addons/account/tests/test_account_fiscal_year.py
index 7fe5e6a966e..0bbf73249aa 100644
--- a/addons/account/tests/test_account_fiscal_year.py
+++ b/addons/account/tests/test_account_fiscal_year.py
@@ -28,7 +28,7 @@ class TestFiscalPosition(AccountingTestCase):
'''Basic case with a fiscal year xxxx-01-01 - xxxx-12-31.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 31
- company.fiscalyear_last_month = 12
+ company.fiscalyear_last_month = '12'
self.check_compute_fiscal_year(
company,
@@ -48,7 +48,7 @@ class TestFiscalPosition(AccountingTestCase):
'''Case with a leap year ending the 29 February.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 29
- company.fiscalyear_last_month = 2
+ company.fiscalyear_last_month = '2'
self.check_compute_fiscal_year(
company,
@@ -68,7 +68,7 @@ class TestFiscalPosition(AccountingTestCase):
'''Case with a leap year ending the 28 February.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 28
- company.fiscalyear_last_month = 2
+ company.fiscalyear_last_month = '2'
self.check_compute_fiscal_year(
company,
@@ -88,7 +88,7 @@ class TestFiscalPosition(AccountingTestCase):
'''Case with custom fiscal years.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 31
- company.fiscalyear_last_month = 12
+ company.fiscalyear_last_month = '12'
# Create custom fiscal year covering the 6 first months of 2017.
self.env['account.fiscal.year'].create({
diff --git a/addons/account/wizard/setup_wizards.py b/addons/account/wizard/setup_wizards.py
index 2aac7495fd5..cde10af75f1 100644
--- a/addons/account/wizard/setup_wizards.py
+++ b/addons/account/wizard/setup_wizards.py
@@ -16,8 +16,7 @@ class FinancialYearOpeningWizard(models.TransientModel):
opening_date = fields.Date(string='Opening Date', required=True, related='company_id.account_opening_date', help="Date from which the accounting is managed in Odoo. It is the date of the opening entry.", readonly=False)
fiscalyear_last_day = fields.Integer(related="company_id.fiscalyear_last_day", required=True, readonly=False,
help="Fiscal year last day.")
- fiscalyear_last_month = fields.Selection(selection=[(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')],
- related="company_id.fiscalyear_last_month", readonly=False,
+ fiscalyear_last_month = fields.Selection(related="company_id.fiscalyear_last_month", readonly=False,
required=True,
help="Fiscal year last month.")
@@ -33,7 +32,7 @@ class FinancialYearOpeningWizard(models.TransientModel):
# fields is done one field at a time.
for wiz in self:
try:
- date(2020, wiz.fiscalyear_last_month, wiz.fiscalyear_last_day)
+ date(2020, int(wiz.fiscalyear_last_month), wiz.fiscalyear_last_day)
except ValueError:
raise ValidationError(
_('Incorrect fiscal year date: day is out of range for month. Month: %s; Day: %s') %
diff --git a/addons/stock/models/res_config_settings.py b/addons/stock/models/res_config_settings.py
index ebf7d339d39..3eca680cce7 100644
--- a/addons/stock/models/res_config_settings.py
+++ b/addons/stock/models/res_config_settings.py
@@ -8,9 +8,9 @@ class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
module_procurement_jit = fields.Selection([
- (1, 'Immediately after sales order confirmation'),
- (0, 'Manually or based on automatic scheduler')
- ], "Reservation",
+ ('1', 'Immediately after sales order confirmation'),
+ ('0', 'Manually or based on automatic scheduler')
+ ], "Reservation", default='0',
help="Reserving products manually in delivery orders or by running the scheduler is advised to better manage priorities in case of long customer lead times or/and frequent stock-outs.")
module_product_expiry = fields.Boolean("Expiration Dates",
help="Track following dates on lots & serial numbers: best before, removal, end of life, alert. \n Such dates are set automatically at lot/serial number creation based on values set on the product (in days).")
diff --git a/addons/stock/wizard/stock_quantity_history.py b/addons/stock/wizard/stock_quantity_history.py
index 595a5c8de88..e925073bc0c 100644
--- a/addons/stock/wizard/stock_quantity_history.py
+++ b/addons/stock/wizard/stock_quantity_history.py
@@ -9,15 +9,15 @@ class StockQuantityHistory(models.TransientModel):
_description = 'Stock Quantity History'
compute_at_date = fields.Selection([
- (0, 'Current Inventory'),
- (1, 'At a Specific Date')
- ], string="Compute", help="Choose to analyze the current inventory or from a specific date in the past.")
+ ('0', 'Current Inventory'),
+ ('1', 'At a Specific Date')
+ ], default='0', string="Compute", help="Choose to analyze the current inventory or from a specific date in the past.")
date = fields.Datetime('Inventory at Date', help="Choose a date to get the inventory at that date", default=fields.Datetime.now)
def open_table(self):
self.ensure_one()
- if self.compute_at_date:
+ if int(self.compute_at_date):
tree_view_id = self.env.ref('stock.view_stock_product_tree').id
form_view_id = self.env.ref('stock.product_form_view_procurement_button').id
# We pass `to_date` in the context so that `qty_available` will be computed across
diff --git a/addons/stock/wizard/stock_quantity_history.xml b/addons/stock/wizard/stock_quantity_history.xml
index c464bf7b42d..bc18695e5c6 100644
--- a/addons/stock/wizard/stock_quantity_history.xml
+++ b/addons/stock/wizard/stock_quantity_history.xml
@@ -8,7 +8,7 @@
-
+