Skip to content

Commit

Permalink
[IMP][16.0] pre-commit : add black hook (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo2302 authored Dec 9, 2024
1 parent 3e25124 commit 7941255
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 102 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ default_language_version:
python: python3
node: "14.13.0"
repos:
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
hooks:
Expand Down
2 changes: 0 additions & 2 deletions account_fr_ca_labels/models/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def get_translation_mapping(environment, term_model="translate.term.fr_ca"):


class TranslationImporter(BaseTranslationImporter):

def _load(self, reader, lang, xmlids=None):
"""
Load and apply language-specific term replacements.
Expand All @@ -108,7 +107,6 @@ def _load(self, reader, lang, xmlids=None):


class CodeTranslations(BaseCodeTranslations):

def get_web_translations(self, module_name, lang):
BaseCodeTranslations._load_web_translations(self, module_name, lang)
translations = base_get_web_translations(self, module_name, lang)
Expand Down
1 change: 0 additions & 1 deletion account_fr_ca_labels/tests/test_fr_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

@ddt
class TestTranslation(TransactionCase):

def setUp(self):
"""
Set up context and initial data for tests, including creating translation terms.
Expand Down
20 changes: 10 additions & 10 deletions account_invoice_constraint_chronology_forced/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
'name': 'Account Invoice Constraint Chronology Forced',
'version': '1.1.0',
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://www.numigi.com',
'license': 'LGPL-3',
'category': 'Accounting',
'summary': 'Add menu entries to configure bank accounts and banks of partners',
'depends': [
'account_invoice_constraint_chronology',
"name": "Account Invoice Constraint Chronology Forced",
"version": "1.1.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://www.numigi.com",
"license": "LGPL-3",
"category": "Accounting",
"summary": "Add menu entries to configure bank accounts and banks of partners",
"depends": [
"account_invoice_constraint_chronology",
],
"data": ["views/account_journal.xml"],
"installable": True,
Expand Down
2 changes: 1 addition & 1 deletion account_invoice_constraint_chronology_forced/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

def sale_journals_check_chronology(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
sale_journal_ids = env["account.journal"].search([('type', '=', 'sale')])
sale_journal_ids = env["account.journal"].search([("type", "=", "sale")])
for journal in sale_journal_ids:
journal.check_chronology = True
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ def _onchange_type(self):
if self.type == "sale":
self.check_chronology = True
if self._origin.type == "sale":
domain = [("journal_id", '=', self._origin.id), ('move_type', '=',
'out_invoice')]
moves_count = self.env['account.move'].search_count(domain)
domain = [
("journal_id", "=", self._origin.id),
("move_type", "=", "out_invoice"),
]
moves_count = self.env["account.move"].search_count(domain)
if moves_count > 0:
raise UserError(_("You cannot change the Type of the Journal because "
"there is At Least One Account Move linked to the Journal."))
raise UserError(
_(
"You cannot change the Type of the Journal because "
"there is At Least One Account Move linked to the Journal."
)
)
1 change: 0 additions & 1 deletion account_payment_cancel_group/tests/test_payment_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class TestPaymentCancel(common.SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
51 changes: 25 additions & 26 deletions account_search_date_range/tests/test_fiscal_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@

@ddt
class TestSessionInfo(common.TransactionCase):

@data(
('2018-01-01', 12, 31, '2018-01-01'),
('2018-05-15', 12, 31, '2018-01-01'),
('2018-12-31', 12, 31, '2018-01-01'),
('2018-02-28', 2, 29, '2017-03-01'),
('2018-03-01', 2, 29, '2018-03-01'),
('2018-12-31', 2, 29, '2018-03-01'),
('2018-02-01', 11, 30, '2017-12-01'),
('2018-03-01', 11, 30, '2017-12-01'),
('2018-12-31', 11, 30, '2018-12-01'),
("2018-01-01", 12, 31, "2018-01-01"),
("2018-05-15", 12, 31, "2018-01-01"),
("2018-12-31", 12, 31, "2018-01-01"),
("2018-02-28", 2, 29, "2017-03-01"),
("2018-03-01", 2, 29, "2018-03-01"),
("2018-12-31", 2, 29, "2018-03-01"),
("2018-02-01", 11, 30, "2017-12-01"),
("2018-03-01", 11, 30, "2017-12-01"),
("2018-12-31", 11, 30, "2018-12-01"),
)
@unpack
def test_fiscal_year_start(self, today, last_month, last_day, year_start):
Expand All @@ -28,26 +27,26 @@ def test_fiscal_year_start(self, today, last_month, last_day, year_start):

self.env.user.company_id.write(
{
'fiscalyear_last_month': str(last_month),
'fiscalyear_last_day': str(last_day),
"fiscalyear_last_month": str(last_month),
"fiscalyear_last_day": str(last_day),
}
)

with freeze_time(today):
context = self._get_domain_context()
assert context['fiscal_year_start'] == year_start
assert context["fiscal_year_start"] == year_start

@data(
('2018-01-01', 12, 31, '2018-01-01'),
('2018-05-15', 12, 31, '2018-04-01'),
('2018-12-31', 12, 31, '2018-10-01'),
('2018-02-01', 2, 29, '2017-12-01'),
('2018-03-01', 2, 29, '2018-03-01'),
('2018-12-31', 2, 29, '2018-12-01'),
('2018-11-30', 11, 30, '2018-09-01'),
('2018-03-01', 11, 30, '2018-03-01'),
('2018-12-31', 11, 30, '2018-12-01'),
('2018-07-15', 11, 30, '2018-06-01'),
("2018-01-01", 12, 31, "2018-01-01"),
("2018-05-15", 12, 31, "2018-04-01"),
("2018-12-31", 12, 31, "2018-10-01"),
("2018-02-01", 2, 29, "2017-12-01"),
("2018-03-01", 2, 29, "2018-03-01"),
("2018-12-31", 2, 29, "2018-12-01"),
("2018-11-30", 11, 30, "2018-09-01"),
("2018-03-01", 11, 30, "2018-03-01"),
("2018-12-31", 11, 30, "2018-12-01"),
("2018-07-15", 11, 30, "2018-06-01"),
)
@unpack
def test_trimester_start(self, today, last_month, last_day, year_start):
Expand All @@ -56,14 +55,14 @@ def test_trimester_start(self, today, last_month, last_day, year_start):

self.env.user.company_id.write(
{
'fiscalyear_last_month': str(last_month),
'fiscalyear_last_day': str(last_day),
"fiscalyear_last_month": str(last_month),
"fiscalyear_last_day": str(last_day),
}
)

with freeze_time(today):
context = self._get_domain_context()
assert context['trimester_start'] == year_start
assert context["trimester_start"] == year_start

def _get_domain_context(self):
return self.env["search.date.range"]._get_domain_context("date")
28 changes: 14 additions & 14 deletions account_show_full_features/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
'name': 'Show Full Accounting Features',
'version': '1.0.0',
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://www.numigi.com',
'license': 'LGPL-3',
'category': 'Accounting',
'summary': 'Show the accounting features hidden in Odoo community',
'depends': [
'account',
"name": "Show Full Accounting Features",
"version": "1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://www.numigi.com",
"license": "LGPL-3",
"category": "Accounting",
"summary": "Show the accounting features hidden in Odoo community",
"depends": [
"account",
],
'data': [
'data/ir_ui_menu.xml',
'data/res_groups.xml',
"data": [
"data/ir_ui_menu.xml",
"data/res_groups.xml",
],
'installable': True,
"installable": True,
}
10 changes: 6 additions & 4 deletions invoice_refund_not_earlier/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ def _reverse_moves(self, default_values_list=None, cancel=False):
for i, move in enumerate(self):
date = default_values_list[i].get("date")
if date and date < move.date:
raise ValidationError(_(
"The date of the reversal entry ({reversal_date}) "
"can not be prior to the original move date ({move_date})."
).format(reversal_date=date, move_date=move.date))
raise ValidationError(
_(
"The date of the reversal entry ({reversal_date}) "
"can not be prior to the original move date ({move_date})."
).format(reversal_date=date, move_date=move.date)
)
return super()._reverse_moves(default_values_list, cancel)
91 changes: 53 additions & 38 deletions invoice_refund_not_earlier/tests/test_journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,66 @@


class TestAccountMove(SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.journal = cls.env['account.journal'].create({
'name': 'Test',
'code': 'TEST',
'type': 'general',
})
cls.default_plan = cls.env['account.analytic.plan'].create(
{'name': 'Default', 'company_id': False})
cls.analytic = cls.env['account.analytic.account'].create({
'name': 'test',
'plan_id': cls.default_plan.id
})
cls.account_1 = cls.env['account.account'].create({
'name': 'Account 1',
'code': '501001',
'account_type': 'asset_fixed',
})
cls.account_2 = cls.env['account.account'].create({
'name': 'Account 2',
'code': '101001',
'account_type': 'expense',
})
cls.journal = cls.env["account.journal"].create(
{
"name": "Test",
"code": "TEST",
"type": "general",
}
)
cls.default_plan = cls.env["account.analytic.plan"].create(
{"name": "Default", "company_id": False}
)
cls.analytic = cls.env["account.analytic.account"].create(
{"name": "test", "plan_id": cls.default_plan.id}
)
cls.account_1 = cls.env["account.account"].create(
{
"name": "Account 1",
"code": "501001",
"account_type": "asset_fixed",
}
)
cls.account_2 = cls.env["account.account"].create(
{
"name": "Account 2",
"code": "101001",
"account_type": "expense",
}
)

cls.today = datetime.now().date()
cls.yesterday = cls.today - timedelta(1)

cls.move = cls.env['account.move'].create({
'journal_id': cls.journal.id,
'date': cls.today,
'line_ids': [
(0, 0, {
'account_id': cls.account_1.id,
'name': '/',
'debit': 100,
}),
(0, 0, {
'account_id': cls.account_2.id,
'name': '/',
'credit': 100,
})
]
})
cls.move = cls.env["account.move"].create(
{
"journal_id": cls.journal.id,
"date": cls.today,
"line_ids": [
(
0,
0,
{
"account_id": cls.account_1.id,
"name": "/",
"debit": 100,
},
),
(
0,
0,
{
"account_id": cls.account_2.id,
"name": "/",
"credit": 100,
},
),
],
}
)

def test_if_reversed_prior_to_original_move__validation_raised(self):
with pytest.raises(ValidationError):
Expand Down

0 comments on commit 7941255

Please sign in to comment.