diff --git a/issue11006.diff b/issue11006.diff new file mode 100644 index 0000000..3154d11 --- /dev/null +++ b/issue11006.diff @@ -0,0 +1,22 @@ +diff --git a/trytond/trytond/modules/account_invoice_defer/account.py b/trytond/trytond/modules/account_invoice_defer/account.py +index 09929e7..cd9a40f 100644 +--- a/trytond/trytond/modules/account_invoice_defer/account.py ++++ b/trytond/trytond/modules/account_invoice_defer/account.py +@@ -164,7 +164,7 @@ class InvoiceDeferred(Workflow, ModelSQL, ModelView): + if journals: + self.journal, = journals + +- @fields.depends('invoice_line', 'start_date') ++ @fields.depends('invoice_line', 'start_date', 'company') + def on_change_invoice_line(self): + pool = Pool() + Currency = pool.get('currency.currency') +@@ -172,7 +172,7 @@ class InvoiceDeferred(Workflow, ModelSQL, ModelView): + if not self.start_date: + self.start_date = self.invoice_line.invoice.invoice_date + invoice = self.invoice_line.invoice +- if invoice.currency != self.company.currency: ++ if self.company and invoice.currency != self.company.currency: + with Transaction().set_context(date=invoice.currency_date): + self.amount = Currency.compute( + invoice.currency, self.invoice_line.amount, diff --git a/issue11049.diff b/issue11049.diff new file mode 100644 index 0000000..9134024 --- /dev/null +++ b/issue11049.diff @@ -0,0 +1,46 @@ +diff --git a/trytond/trytond/modules/account_invoice_defer/account.py b/trytond/trytond/modules/account_invoice_defer/account.py +index 09929e7..c58e120 100644 +--- a/trytond/trytond/modules/account_invoice_defer/account.py ++++ b/trytond/trytond/modules/account_invoice_defer/account.py +@@ -4,6 +4,7 @@ + from trytond.i18n import gettext + from trytond.model import ModelSQL, ModelView, Workflow, fields, Unique + from trytond.model.exceptions import AccessError ++from trytond.modules.account.exceptions import AccountMissing + from trytond.pool import PoolMeta, Pool + from trytond.pyson import Eval, If + from trytond.transaction import Transaction +@@ -357,9 +358,17 @@ class InvoiceDeferred(Workflow, ModelSQL, ModelView): + if invoice.type == 'out': + balance.account = configuration.get_multivalue( + 'deferred_account_revenue', company=self.company.id) ++ if not balance.account: ++ raise AccountMissing(gettext( ++ 'account_invoice_defer.' ++ 'msg_missing_deferred_account_revenue')) + else: + balance.account = configuration.get_multivalue( + 'deferred_account_expense', company=self.company.id) ++ if not balance.account: ++ raise AccountMissing(gettext( ++ 'account_invoice_defer.' ++ 'msg_missing_deferred_account_expense')) + balance.debit, balance.credit = income.credit, income.debit + if balance.account.party_required: + balance.party = invoice.party +diff --git a/trytond/trytond/modules/account_invoice_defer/message.xml b/trytond/trytond/modules/account_invoice_defer/message.xml +index cccdb09..28d1f88 100644 +--- a/trytond/trytond/modules/account_invoice_defer/message.xml ++++ b/trytond/trytond/modules/account_invoice_defer/message.xml +@@ -12,5 +12,11 @@ this repository contains the full copyright notices and license terms. --> + + You cannot delete invoice deferred "%(deferral)s" because it is not in "draft" state. + ++ ++ There is no deferred account revenue configured. ++ ++ ++ There is no deferred account expense configured. ++ + + diff --git a/issue11051.diff b/issue11051.diff new file mode 100644 index 0000000..e10bad3 --- /dev/null +++ b/issue11051.diff @@ -0,0 +1,15 @@ +diff --git a/trytond/trytond/modules/account_invoice_defer/account.py b/trytond/trytond/modules/account_invoice_defer/account.py +index 09929e7..96fd0d2 100644 +--- a/trytond/trytond/modules/account_invoice_defer/account.py ++++ b/trytond/trytond/modules/account_invoice_defer/account.py +@@ -180,6 +180,10 @@ class InvoiceDeferred(Workflow, ModelSQL, ModelView): + else: + self.amount = self.invoice_line.amount + ++ @classmethod ++ def default_company(cls): ++ return Transaction().context.get('company') ++ + @classmethod + def default_state(cls): + return 'draft' diff --git a/series b/series index fe3d08f..6952435 100644 --- a/series +++ b/series @@ -48,3 +48,7 @@ issue10161.diff # [sale] issue10161: Configuration of invoice_method and shipmen issue8952.diff # [country] Use Tryton's CDN to download postal codes Remove on 6.4 issue11181.diff # [stock] Require unit price also for view location like for storage (only 6.0) + +issue11051.diff # [account_invoice_defer] Add default company to invoice deferred (only 6.0) +issue11006.diff # [account_invoice_defer] Add company to on_change_invoice_line depends (only 6.0) +issue11049.diff # [account_invoice_defer] Raise user error message for account not configured (only 6.0)