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 @@
+
+
+
diff --git a/modules/account/view/move_line_receivable_payable_context_form.xml b/modules/account/view/move_line_receivable_payable_context_form.xml
index 3101220078..cf2967e7f0 100644
--- a/modules/account/view/move_line_receivable_payable_context_form.xml
+++ b/modules/account/view/move_line_receivable_payable_context_form.xml
@@ -1,11 +1,15 @@
-
diff --git a/modules/account/view/move_template_list.xml b/modules/account/view/move_template_list.xml
index b4d89538b1..6a95fed743 100644
--- a/modules/account/view/move_template_list.xml
+++ b/modules/account/view/move_template_list.xml
@@ -2,5 +2,6 @@
+
diff --git a/modules/account/view/open_journal_ask_form.xml b/modules/account/view/open_journal_ask_form.xml
index 1a4073e0f6..8e5df958a6 100644
--- a/modules/account/view/open_journal_ask_form.xml
+++ b/modules/account/view/open_journal_ask_form.xml
@@ -1,9 +1,12 @@
-
diff --git a/modules/account_export/account.xml b/modules/account_export/account.xml
index 94b9450795..59b15a1d3b 100644
--- a/modules/account_export/account.xml
+++ b/modules/account_export/account.xml
@@ -24,10 +24,7 @@ this repository contains the full copyright notices and license terms. -->
Move Exports
account.move.export
-
+
diff --git a/modules/account_move_line_grouping/account.xml b/modules/account_move_line_grouping/account.xml
index ac88f85dae..0dc20d4930 100644
--- a/modules/account_move_line_grouping/account.xml
+++ b/modules/account_move_line_grouping/account.xml
@@ -79,11 +79,9 @@ this repository contains the full copyright notices and license terms. -->
Payable/Receivable Lines (Grouped)
account.move.line.group
account.move.line.receivable_payable.context
-
+
diff --git a/modules/account_rule/account.xml b/modules/account_rule/account.xml
index 4eb97c09eb..cffb2a11f1 100644
--- a/modules/account_rule/account.xml
+++ b/modules/account_rule/account.xml
@@ -18,7 +18,8 @@ this repository contains the full copyright notices and license terms. -->
Account Rules
account.account.rule
-
+
+