diff --git a/modules/account/__init__.py b/modules/account/__init__.py index d3f280d944..f48993acf6 100644 --- a/modules/account/__init__.py +++ b/modules/account/__init__.py @@ -51,6 +51,7 @@ def register(): journal.JournalCashContext, journal.JournalPeriod, move.Move, + move.MoveContext, move.Reconciliation, configuration.ConfigurationTaxRounding, move.Line, diff --git a/modules/account/journal.xml b/modules/account/journal.xml index ede281249b..2000499974 100644 --- a/modules/account/journal.xml +++ b/modules/account/journal.xml @@ -134,9 +134,8 @@ this repository contains the full copyright notices and license terms. --> Journals - Periods account.journal.period - + + @@ -152,9 +151,8 @@ this repository contains the full copyright notices and license terms. --> Journals - Periods account.journal.period - + + diff --git a/modules/account/move.py b/modules/account/move.py index adea0844f5..21aed4e93e 100644 --- a/modules/account/move.py +++ b/modules/account/move.py @@ -563,6 +563,16 @@ class Move(DescriptionOriginMixin, ModelSQL, ModelView): Line.reconcile(*to_reconcile) +class MoveContext(ModelView): + __name__ = 'account.move.context' + + company = fields.Many2One('company.company', "Company", required=True) + + @classmethod + def default_company(cls): + return Transaction().context.get('company') + + class Reconciliation(ModelSQL, ModelView): __name__ = 'account.move.reconciliation' _rec_name = 'number' @@ -1886,10 +1896,15 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView): class LineReceivablePayableContext(ModelView): __name__ = 'account.move.line.receivable_payable.context' + company = fields.Many2One('company.company', "Company", required=True) reconciled = fields.Boolean("Reconciled") receivable = fields.Boolean("Receivable") payable = fields.Boolean("Payable") + @classmethod + def default_company(cls): + return Transaction().context.get('company') + @classmethod def default_reconciled(cls): return Transaction().context.get('reconciled', False) @@ -1940,22 +1955,32 @@ class WriteOff(DeactivableMixin, ModelSQL, ModelView): class OpenJournalAsk(ModelView): __name__ = 'account.move.open_journal.ask' - journal = fields.Many2One('account.journal', 'Journal', required=True) + company = fields.Many2One('company.company', "Company", required=True) + journal = fields.Many2One( + 'account.journal', 'Journal', required=True, + context={ + 'company': Eval('company', None), + }) period = fields.Many2One('account.period', 'Period', required=True, domain=[ + ('company', '=', Eval('company', -1)), ('state', '!=', 'closed'), ]) + @classmethod + def default_company(cls): + return Transaction().context.get('company') + @classmethod def default_period(cls): pool = Pool() Period = pool.get('account.period') - company = Transaction().context.get('company') - try: - period = Period.find(company) - except PeriodNotFoundError: - return None - return period.id + if company := cls.default_company(): + try: + period = Period.find(company) + except PeriodNotFoundError: + return None + return period.id class OpenJournal(Wizard): @@ -1980,6 +2005,7 @@ class OpenJournal(Wizard): and self.model.__name__ == 'account.journal.period' and self.record): return { + 'company': self.record.company.id, 'journal': self.record.journal.id, 'period': self.record.period.id, } diff --git a/modules/account/move.xml b/modules/account/move.xml index c7a3ba9924..464506e55c 100644 --- a/modules/account/move.xml +++ b/modules/account/move.xml @@ -16,9 +16,10 @@ this repository contains the full copyright notices and license terms. --> Account Moves account.move - + account.move.context + + + @@ -85,6 +86,12 @@ this repository contains the full copyright notices and license terms. --> + + account.move.context + form + move_context_form + + account.move.reconciliation form @@ -244,11 +251,9 @@ this repository contains the full copyright notices and license terms. --> Payable/Receivable Lines account.move.line account.move.line.receivable_payable.context - + diff --git a/modules/account/move_template.xml b/modules/account/move_template.xml index 991743d0bc..7a3f897142 100644 --- a/modules/account/move_template.xml +++ b/modules/account/move_template.xml @@ -16,9 +16,8 @@ this repository contains the full copyright notices and license terms. --> Moves account.move.template - + + diff --git a/modules/account/period.xml b/modules/account/period.xml index 120cf44c85..d51a208ece 100644 --- a/modules/account/period.xml +++ b/modules/account/period.xml @@ -22,9 +22,8 @@ this repository contains the full copyright notices and license terms. --> Periods account.period - + + diff --git a/modules/account/tax.xml b/modules/account/tax.xml index 04a338d8bc..276ff63e35 100644 --- a/modules/account/tax.xml +++ b/modules/account/tax.xml @@ -291,9 +291,7 @@ this repository contains the full copyright notices and license terms. --> Taxes account.tax - + @@ -456,8 +454,8 @@ this repository contains the full copyright notices and license terms. --> Rules account.tax.rule - + + diff --git a/modules/account/view/move_context_form.xml b/modules/account/view/move_context_form.xml new file mode 100644 index 0000000000..d39d983970 --- /dev/null +++ b/modules/account/view/move_context_form.xml @@ -0,0 +1,7 @@ + + +
+