diff --git a/series b/series
index af38eb1..9928b71 100644
--- a/series
+++ b/series
@@ -19,8 +19,6 @@ search_warehouse.diff # [stock] search function for warehouse
issue10467.diff # [stock_lot] add lot to grouping when assign try if lot it's required on product
issue8702.diff # [stock_supply_forecast] Support production forecast
-statement_of_account.diff # [account] Cumulate balance of previous fiscal years
-
model.diff # [trytond] Allows dynamic fields in Model as required by the wizard in sale_pos_template_quantities
issue9797.diff # [account_payment_sepa] Slowness processing sepa
@@ -57,3 +55,7 @@ issue11240.diff # [account] Check access to select account to reconcile
issue10363.diff # [production] Remove unique product constraint on BOM
issue11252.diff # [sao] Make print button sensitive for exports even without report
+
+statement_of_account.diff # [account] Cumulate balance of previous fiscal years
+
+statement_of_account_2.diff # [account] Use from_date and to_date from context in _debit_credit_context() (pending core)
\ No newline at end of file
diff --git a/statement_of_account.diff b/statement_of_account.diff
index 403f37f..ba43d7c 100644
--- a/statement_of_account.diff
+++ b/statement_of_account.diff
@@ -1,37 +1,41 @@
-diff -r 62f81d7eb78b account.py
---- a/trytond/trytond/modules/account/account.py Fri Jul 07 10:04:01 2017 +0200
-+++ b/trytond/trytond/modules/account/account.py Fri Jul 07 10:30:29 2017 +0200
-@@ -2009,7 +2009,7 @@
+diff --git a/account.py b/account.py
+index 6c17998..e463b58 100644
+--- a/trytond/trytond/modules/account/account.py
++++ b/trytond/trytond/modules/account/account.py
+@@ -1917,14 +1917,15 @@ class GeneralLedgerAccountContext(ModelView):
+ 'General Ledger Account Context'
+ __name__ = 'account.general_ledger.account.context'
+ fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
+- required=True)
++ required=False)
+ start_period = fields.Many2One('account.period', 'Start Period',
+ domain=[
+ ('fiscalyear', '=', Eval('fiscalyear')),
+ ('start_date', '<=', (Eval('end_period'), 'start_date')),
+ ],
+ states={
+- 'invisible': Eval('from_date', False) | Eval('to_date', False),
++ 'invisible': (Eval('from_date', False) | Eval('to_date', False)
++ | ~Eval('fiscalyear', False)),
+ },
+ depends=['fiscalyear', 'end_period', 'from_date', 'to_date'])
+ end_period = fields.Many2One('account.period', 'End Period',
+@@ -1933,7 +1934,8 @@ class GeneralLedgerAccountContext(ModelView):
+ ('start_date', '>=', (Eval('start_period'), 'start_date'))
+ ],
+ states={
+- 'invisible': Eval('from_date', False) | Eval('to_date', False),
++ 'invisible': (Eval('from_date', False) | Eval('to_date', False)
++ | ~Eval('fiscalyear', False)),
+ },
+ depends=['fiscalyear', 'start_period', 'from_date', 'to_date'])
+ from_date = fields.Date("From Date",
+@@ -2145,7 +2147,7 @@ class GeneralLedgerLine(ModelSQL, ModelView):
def __setup__(cls):
super(GeneralLedgerLine, cls).__setup__()
cls.__access__.add('account')
- cls._order.insert(0, ('date', 'ASC'))
+ cls._order = [('date', 'DESC'), ('id', 'DESC')]
-
+
@classmethod
def table_query(cls):
-@@ -2057,7 +2057,7 @@
- line_query, fiscalyear_ids = Line.query_get(line)
- return line.join(move, condition=line.move == move.id
- ).join(account, condition=line.account == account.id
-- ).select(*columns, where=line_query)
-+ ).select(*columns)
-
- def get_party_required(self, name):
- return self.account.party_required
-diff -r 62f81d7eb78b view/general_ledger_line_context_form.xml
---- a/trytond/trytond/modules/account/view/general_ledger_line_context_form.xml Fri Jul 07 10:04:01 2017 +0200
-+++ b/trytond/trytond/modules/account/view/general_ledger_line_context_form.xml Fri Jul 07 10:30:29 2017 +0200
-@@ -6,4 +6,12 @@
-
-
-
-+
-+
-+
-+
-+
-+
-+
-+
-
diff --git a/statement_of_account_2.diff b/statement_of_account_2.diff
new file mode 100644
index 0000000..41379c2
--- /dev/null
+++ b/statement_of_account_2.diff
@@ -0,0 +1,27 @@
+diff --git a/account.py b/account.py
+index 6c17998..dabf92a 100644
+--- a/trytond/trytond/modules/account/account.py
++++ b/trytond/trytond/modules/account/account.py
+@@ -1837,19 +1837,16 @@ class _GeneralLedgerAccount(ActivePeriodMixin, ModelSQL, ModelView):
+
+ @classmethod
+ def _debit_credit_context(cls):
+- period_ids, from_date, to_date = None, None, None
++ period_ids = None
+ context = Transaction().context
+ if context.get('start_period') or context.get('end_period'):
+ start_period_ids = set(cls.get_period_ids('start_balance'))
+ end_period_ids = set(cls.get_period_ids('end_balance'))
+ period_ids = list(end_period_ids.difference(start_period_ids))
+- elif context.get('from_date') or context.get('end_date'):
+- _, from_date = cls.get_dates('start_balance')
+- _, to_date = cls.get_dates('end_balance')
+ return {
+ 'periods': period_ids,
+- 'from_date': from_date,
+- 'to_date': to_date,
++ 'from_date': context.get('from_date'),
++ 'to_date': context.get('end_date'),
+ }
+
+ @classmethod