Compare commits

...

29 Commits

Author SHA1 Message Date
Juanjo Garcia Pagan 5ce9cb6ec8
Merge b99ddd17fe into 4e5d92da90 2023-12-12 09:32:32 +01:00
Juanjo Garcia Pagan b99ddd17fe
Merge branch '6.8' into 159227 2023-12-12 09:32:28 +01:00
Albert Cervera i Areny 4e5d92da90 Add sao_document_field.diff 2023-12-06 19:52:54 +01:00
Albert Cervera i Areny 27dad682cd Remove issue7707.diff as it's been committed into core. 2023-12-03 12:14:00 +01:00
Albert Cervera i Areny f940559ffc Remove issue12553.diff as it's been committed into core. 2023-12-03 12:09:10 +01:00
Raimon Esteve 5239db778a issue7707.diff # [sao] Improve tree view
#163452
2023-11-23 14:35:43 +01:00
Bernat Brunet 227e368922 Merge branch '6.8' of github.com:nan-tic/trytond-patches into 6.8 2023-11-21 17:15:36 +01:00
Bernat Brunet 777a7399dd Fix problem when update chart of accounts.
Update trees of chart of accounts with 2 passes.
2023-11-21 17:14:17 +01:00
Raimon Esteve fd7fae7ce7 Locales
#163564+
2023-11-21 12:55:11 +01:00
Albert Cervera i Areny c4b9b91146 Remove issue7697.diff as it's been committed into core. 2023-11-18 09:57:51 +01:00
Raimon Esteve 02831de257 issue12553.diff # [sao] Select first visible siblings when page is hidden
#162155
2023-11-15 07:35:20 +01:00
Raimon Esteve 83b0e9696b issue7697.diff # [stock] Do not compute internal quantity for stock move created without product nor unit
#162753
2023-11-15 07:28:47 +01:00
Albert Cervera i Areny 14a3d8cbef Remove issue12567.diff issue12590.diff issue12626.diff issue12653.diff 2023-11-02 23:09:22 +01:00
Albert Cervera i Areny 9e7fec7798 Remove issue12570. 2023-11-02 23:06:33 +01:00
Albert Cervera i Areny 38491778dd Remove issue7677. 2023-11-02 23:04:09 +01:00
Bernat Brunet e5b55c9a63 Backport patch of core changes, that support second currency on
statement line
2023-11-01 17:13:48 +01:00
Bernat Brunet f4730c8d5d Fix bug in patch issue12678.diff. 2023-11-01 12:40:33 +01:00
Raimon Esteve e25d4a36f8 Remove patches that add ir.rule.group
Since issue4080 add default rule group in analytic account and stock inventory
#163075
2023-10-30 11:59:06 +01:00
Raimon Esteve 4afdb73f67 issue12678.diff [account_statement] Not delete statement lines when statament is not draft state
#163104
2023-10-30 10:29:56 +01:00
Raimon Esteve 306ea8d812 Revert issue12618.diff
From changeset-0299411913ab2c64c179a6ba289aa6eb4bbc148a
#163060
2023-10-27 15:59:51 +02:00
Raimon Esteve 8c855fbc51 issue12653.diff [purchase] Depend on product supplier unit to compute unit on price 2023-10-26 07:06:34 +02:00
Raimon Esteve 3680d76f87 issue12567.diff [account_invoice_defer] Defer invoice line only once
#162632
2023-10-25 16:56:34 +02:00
Raimon Esteve eeed1813d2 issue12567.diff [account_invoice_defer] Defer invoice line only once
#162243
2023-10-25 16:48:57 +02:00
Raimon Esteve e226bf4a38 Add issue12618.diff [sao] Wrap long label to 80 chars
#161626
2023-10-25 15:13:51 +02:00
Raimon Esteve aa91b072f1 Add issue12590.diff [account_payment] Do not test active clause of dunning being in a set 2023-10-23 08:35:51 +02:00
Raimon Esteve 344d6aaddb issue12570.diff [account] Do not compute account party for general ledger line without party
#162240
2023-10-16 07:33:15 +02:00
Raimon Esteve c4c2c7ab4e fix typo issue7677.diff 2023-10-06 12:22:53 +02:00
Raimon Esteve d2f8d68d8b Add issue7672.diff [stock] Always fill product and template of cost price revision
#161975
2023-10-06 12:06:48 +02:00
Raimon Esteve 473d52c242 Add issue7677.diff [trytond] Do not set rec_name for unsaved record
#162058
2023-10-06 10:01:36 +02:00
9 changed files with 768 additions and 46 deletions

View File

@ -0,0 +1,456 @@
diff --git a/tryton/modules/account_payment/account.py b/tryton/modules/account_payment/account.py
index 801a0e674e..236d5ef56e 100644
--- a/tryton/modules/account_payment/account.py
+++ b/tryton/modules/account_payment/account.py
@@ -574,7 +574,9 @@ class StatementLine(metaclass=PoolMeta):
('party', '=', Eval('party')),
()),
('state', 'in', ['processing', 'succeeded', 'failed']),
- ('currency', '=', Eval('currency', -1)),
+ If(Eval('second_currency'),
+ ('currency', '=', Eval('second_currency', -1)),
+ ('currency', '=', Eval('currency', -1))),
('kind', '=',
If(Eval('amount', 0) > 0, 'receivable',
If(Eval('amount', 0) < 0, 'payable', ''))),
diff --git a/tryton/modules/account_payment_clearing/statement.py b/tryton/modules/account_payment_clearing/statement.py
index 60e8f4955d..d76430fd44 100644
--- a/tryton/modules/account_payment_clearing/statement.py
+++ b/tryton/modules/account_payment_clearing/statement.py
@@ -110,7 +110,9 @@ class StatementLine(metaclass=PoolMeta):
]
cls.related_to.domain['account.payment.group'] = [
('company', '=', Eval('company', -1)),
- ('currency', '=', Eval('currency', -1)),
+ If(Eval('second_currency'),
+ ('currency', '=', Eval('second_currency', -1)),
+ ('currency', '=', Eval('currency', -1))),
If(Eval('statement_state') == 'draft',
('clearing_reconciled', '!=', True),
()),
diff --git a/tryton/modules/account_statement/message.xml b/tryton/modules/account_statement/message.xml
index bab7027298..0d19d9439b 100644
--- a/tryton/modules/account_statement/message.xml
+++ b/tryton/modules/account_statement/message.xml
@@ -36,6 +36,9 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_statement_post_pending_amount">
<field name="text">To post statement "%(statement)s" you must create lines for pending %(amount)s of origin "%(origin)s".</field>
</record>
+ <record model="ir.message" id="msg_statement_line_second_currency_sign">
+ <field name="text">You must set the same sign for second currency than amount.</field>
+ </record>
<record model="ir.message" id="msg_post_statement_move">
<field name="text">To post the move "%(move)s" you must post the statement "%(statement)s".</field>
</record>
diff --git a/tryton/modules/account_statement/statement.py b/tryton/modules/account_statement/statement.py
index d3227e77a5..aa93ceebdb 100644
--- a/tryton/modules/account_statement/statement.py
+++ b/tryton/modules/account_statement/statement.py
@@ -12,7 +12,7 @@ from sql.operators import Concat
from trytond.config import config
from trytond.i18n import gettext
from trytond.model import (
- DictSchemaMixin, Index, ModelSQL, ModelView, Workflow, fields,
+ Check, DictSchemaMixin, Index, ModelSQL, ModelView, Workflow, fields,
sequence_ordered)
from trytond.model.exceptions import AccessError
from trytond.modules.company import CompanyReport
@@ -672,6 +672,9 @@ def origin_mixin(_states):
company = fields.Function(
fields.Many2One('company.company', "Company"),
'on_change_with_company', searcher='search_company')
+ company_currency = fields.Function(
+ fields.Many2One('currency.currency', "Company Currency"),
+ 'on_change_with_company_currency')
number = fields.Char("Number")
date = fields.Date(
"Date", required=True, states=_states)
@@ -680,6 +683,25 @@ def origin_mixin(_states):
states=_states)
currency = fields.Function(fields.Many2One(
'currency.currency', "Currency"), 'on_change_with_currency')
+ amount_second_currency = Monetary(
+ "Amount Second Currency",
+ currency='second_currency', digits='second_currency',
+ states={
+ 'required': Bool(Eval('second_currency')),
+ 'readonly': _states['readonly'],
+ })
+ second_currency = fields.Many2One(
+ 'currency.currency', "Second Currency",
+ domain=[
+ ('id', '!=', Eval('currency', -1)),
+ If(Eval('currency', -1) != Eval('company_currency', -1),
+ ('id', '=', Eval('company_currency', -1)),
+ ()),
+ ],
+ states={
+ 'required': Bool(Eval('amount_second_currency')),
+ 'readonly': _states['readonly'],
+ })
party = fields.Many2One(
'party.party', "Party", states=_states,
context={
@@ -723,6 +745,10 @@ def origin_mixin(_states):
def search_company(cls, name, clause):
return [('statement.' + clause[0],) + tuple(clause[1:])]
+ @fields.depends('statement', '_parent_statement.company')
+ def on_change_with_company_currency(self, name=None):
+ return self.statement.company.currency if self.statement else None
+
@fields.depends('statement', '_parent_statement.journal')
def on_change_with_currency(self, name=None):
if self.statement and self.statement.journal:
@@ -750,7 +776,10 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
domain={
'account.invoice': [
('company', '=', Eval('company', -1)),
- ('currency', '=', Eval('currency', -1)),
+ If(Eval('second_currency'),
+ ('currency', '=', Eval('second_currency', -1)),
+ ('currency', '=', Eval('currency', -1))
+ ),
If(Bool(Eval('party')),
['OR',
('party', '=', Eval('party', -1)),
@@ -782,6 +811,7 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
@classmethod
def __setup__(cls):
super(Line, cls).__setup__()
+ table = cls.__table__()
cls.date.states = {
'readonly': (
(Eval('statement_state') != 'draft')
@@ -792,6 +822,14 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
'required': (Eval('party_required', False)
& (Eval('statement_state') == 'draft')),
}
+ cls._sql_constraints += [
+ ('second_currency_sign',
+ Check(
+ table,
+ Coalesce(table.amount_second_currency, 0)
+ * table.amount >= 0),
+ 'account_statement.msg_statement_line_second_currency_sign'),
+ ]
@classmethod
def __register__(cls, module):
@@ -1029,24 +1067,29 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
pool = Pool()
MoveLine = pool.get('account.move.line')
Currency = Pool().get('currency.currency')
- zero = Decimal("0.0")
if not self.amount:
return
- with Transaction().set_context(date=self.date):
- amount = Currency.compute(self.statement.journal.currency,
- self.amount, self.statement.company.currency)
- if self.statement.journal.currency != self.statement.company.currency:
- second_currency = self.statement.journal.currency.id
+ if self.second_currency == self.company_currency:
+ amount = self.amount_second_currency
+ else:
+ with Transaction().set_context(date=self.date):
+ amount = Currency.compute(
+ self.currency, self.amount, self.company_currency)
+ if self.currency != self.company_currency:
+ second_currency = self.currency
amount_second_currency = -self.amount
+ elif self.second_currency:
+ second_currency = self.second_currency
+ amount_second_currency = -self.amount_second_currency
else:
- amount_second_currency = None
second_currency = None
+ amount_second_currency = None
return MoveLine(
origin=self,
description=self.description,
- debit=amount < zero and -amount or zero,
- credit=amount >= zero and amount or zero,
+ debit=abs(amount) if amount < 0 else 0,
+ credit=abs(amount) if amount > 0 else 0,
account=self.account,
party=self.party if self.account.party_required else None,
second_currency=second_currency,
@@ -1070,6 +1113,10 @@ class LineGroup(ModelSQL, ModelView):
"Amount", currency='currency', digits='currency')
currency = fields.Function(fields.Many2One('currency.currency',
'Currency'), 'get_currency')
+ amount_second_currency = Monetary(
+ "Amount Second Currency",
+ currency='second_currency', digits='second_currency')
+ second_currency = fields.Many2One('currency.currency', "Second Currency")
party = fields.Many2One('party.party', 'Party')
move = fields.Many2One('account.move', 'Move')
@@ -1086,6 +1133,7 @@ class LineGroup(ModelSQL, ModelView):
Max(line.number).as_('number'),
Max(line.date).as_('date'),
Sum(line.amount).as_('amount'),
+ Sum(line.amount_second_currency).as_('amount_second_currency'),
Max(line.party).as_('party'),
]
@@ -1103,6 +1151,7 @@ class LineGroup(ModelSQL, ModelView):
move.create_date,
move.write_uid,
move.write_date,
+ line.second_currency,
]
columns = (std_columns + [move.id.as_('move')]
diff --git a/tryton/modules/account_statement/tests/scenario_account_statement_second_currency_invoice.rst b/tryton/modules/account_statement/tests/scenario_account_statement_second_currency_invoice.rst
new file mode 100644
index 0000000000..5209accc58
--- /dev/null
+++ b/tryton/modules/account_statement/tests/scenario_account_statement_second_currency_invoice.rst
@@ -0,0 +1,103 @@
+=========================================
+Account Statement Second Currency Invoice
+=========================================
+
+Imports::
+
+ >>> from decimal import Decimal
+ >>> import datetime as dt
+
+ >>> from proteus import Model
+ >>> from trytond.tests.tools import activate_modules
+ >>> from trytond.modules.currency.tests.tools import get_currency
+ >>> from trytond.modules.company.tests.tools import create_company
+ >>> from trytond.modules.account.tests.tools import (
+ ... create_fiscalyear, create_chart, get_accounts)
+ >>> from trytond.modules.account_invoice.tests.tools import (
+ ... set_fiscalyear_invoice_sequences)
+
+ >>> today = dt.date.today()
+
+Activate modules::
+
+ >>> config = activate_modules(['account_statement', 'account_invoice'])
+
+ >>> AccountConfiguration = Model.get('account.configuration')
+ >>> AccountJournal = Model.get('account.journal')
+ >>> Invoice = Model.get('account.invoice')
+ >>> Party = Model.get('party.party')
+ >>> Statement = Model.get('account.statement')
+ >>> StatementJournal = Model.get('account.statement.journal')
+
+Create company::
+
+ >>> usd = get_currency('USD')
+ >>> eur = get_currency('EUR')
+ >>> _ = create_company(currency=usd)
+
+Create fiscal year::
+
+ >>> fiscalyear = set_fiscalyear_invoice_sequences(create_fiscalyear())
+ >>> fiscalyear.click('create_period')
+
+Create chart of accounts::
+
+ >>> _ = create_chart()
+ >>> accounts = get_accounts()
+
+Configure currency exchange::
+
+ >>> currency_exchange_account, = (
+ ... accounts['revenue'].duplicate(
+ ... default={'name': "Currency Exchange"}))
+ >>> account_configuration = AccountConfiguration(1)
+ >>> account_configuration.currency_exchange_debit_account = (
+ ... currency_exchange_account)
+ >>> account_configuration.save()
+
+Create party::
+
+ >>> customer = Party(name="Customer")
+ >>> customer.save()
+
+Create customer invoice in alternate currency::
+
+ >>> invoice = Invoice(type='out')
+ >>> invoice.party = customer
+ >>> invoice.currency = eur
+ >>> line = invoice.lines.new()
+ >>> line.quantity = 1
+ >>> line.unit_price = Decimal('50.0000')
+ >>> line.account = accounts['revenue']
+ >>> invoice.click('post')
+ >>> invoice.state
+ 'posted'
+
+Post statement in company currency with second currency::
+
+ >>> account_journal, = AccountJournal.find([('code', '=', 'STA')], limit=1)
+ >>> statement_journal = StatementJournal(
+ ... name="Statement Journal", journal=account_journal,
+ ... currency=usd, account=accounts['cash'])
+ >>> statement_journal.save()
+
+ >>> statement = Statement(
+ ... name="Test", journal=statement_journal,
+ ... start_balance=Decimal('0.00'), end_balance=Decimal('20.00'))
+ >>> line = statement.lines.new()
+ >>> line.number = "1"
+ >>> line.date = today
+ >>> line.party = customer
+ >>> line.amount = Decimal('20.00')
+ >>> line.amount_second_currency = Decimal('50.00')
+ >>> line.second_currency = eur
+ >>> line.related_to = invoice
+ >>> statement.click('validate_statement')
+ >>> statement.state
+ 'validated'
+
+Check invoice is paid::
+
+ >>> invoice.reload()
+ >>> invoice.state
+ 'paid'
diff --git a/tryton/modules/account_statement/view/line_group_form.xml b/tryton/modules/account_statement/view/line_group_form.xml
index 24c045781e..f66bd0fd82 100644
--- a/tryton/modules/account_statement/view/line_group_form.xml
+++ b/tryton/modules/account_statement/view/line_group_form.xml
@@ -5,14 +5,17 @@ this repository contains the full copyright notices and license terms. -->
<label name="statement"/>
<field name="statement"/>
<label name="journal"/>
- <field name="journal"/>
+ <field name="journal" widget="selection"/>
+
<label name="number"/>
<field name="number"/>
<label name="date"/>
<field name="date"/>
+
<label name="amount"/>
<field name="amount"/>
- <newline/>
+ <label name="amount_second_currency"/>
+ <field name="amount_second_currency"/>
<label name="party"/>
<field name="party"/>
diff --git a/tryton/modules/account_statement/view/line_group_list.xml b/tryton/modules/account_statement/view/line_group_list.xml
index f8cd12b965..70d2516098 100644
--- a/tryton/modules/account_statement/view/line_group_list.xml
+++ b/tryton/modules/account_statement/view/line_group_list.xml
@@ -7,6 +7,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="number"/>
<field name="date"/>
<field name="amount"/>
+ <field name="amount_second_currency" optional="1"/>
<field name="party"/>
<field name="move"/>
</tree>
diff --git a/tryton/modules/account_statement/view/statement_line_form.xml b/tryton/modules/account_statement/view/statement_line_form.xml
index 04420e065c..077b9cd768 100644
--- a/tryton/modules/account_statement/view/statement_line_form.xml
+++ b/tryton/modules/account_statement/view/statement_line_form.xml
@@ -8,19 +8,29 @@ this repository contains the full copyright notices and license terms. -->
<field name="number"/>
<label name="sequence"/>
<field name="sequence"/>
+
<label name="date"/>
<field name="date"/>
<label name="amount"/>
<field name="amount"/>
+
+ <label name="amount_second_currency"/>
+ <field name="amount_second_currency"/>
+ <label name="second_currency"/>
+ <field name="second_currency"/>
+
<label name="party"/>
<field name="party"/>
<label name="account"/>
<field name="account"/>
+
<label name="related_to"/>
<field name="related_to"/>
<newline/>
+
<label name="description"/>
<field name="description" colspan="3"/>
+
<label name="move"/>
<field name="move"/>
<label name="origin"/>
diff --git a/tryton/modules/account_statement/view/statement_line_tree.xml b/tryton/modules/account_statement/view/statement_line_tree.xml
index e8b5a4fbf8..c89f272a07 100644
--- a/tryton/modules/account_statement/view/statement_line_tree.xml
+++ b/tryton/modules/account_statement/view/statement_line_tree.xml
@@ -6,6 +6,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="number"/>
<field name="date"/>
<field name="amount"/>
+ <field name="amount_second_currency" optional="1"/>
<field name="party" expand="1"/>
<field name="account" expand="1"/>
<field name="related_to" expand="1"/>
diff --git a/tryton/modules/account_statement/view/statement_line_tree_editable.xml b/tryton/modules/account_statement/view/statement_line_tree_editable.xml
index eae041607a..f8fec861c2 100644
--- a/tryton/modules/account_statement/view/statement_line_tree_editable.xml
+++ b/tryton/modules/account_statement/view/statement_line_tree_editable.xml
@@ -6,6 +6,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="number"/>
<field name="date"/>
<field name="amount" sum="Amount"/>
+ <field name="amount_second_currency" optional="1"/>
<field name="party" expand="1"/>
<field name="related_to" expand="1"/>
<field name="account" expand="1"/>
diff --git a/tryton/modules/account_statement/view/statement_origin_form.xml b/tryton/modules/account_statement/view/statement_origin_form.xml
index 538487109b..e08d18bff8 100644
--- a/tryton/modules/account_statement/view/statement_origin_form.xml
+++ b/tryton/modules/account_statement/view/statement_origin_form.xml
@@ -6,20 +6,31 @@ this repository contains the full copyright notices and license terms. -->
<field name="statement"/>
<label name="company"/>
<field name="company"/>
+
<label name="number"/>
<field name="number"/>
<label name="date"/>
<field name="date"/>
+
<label name="amount"/>
<field name="amount"/>
<label name="pending_amount"/>
<field name="pending_amount"/>
+
+ <label name="amount_second_currency"/>
+ <field name="amount_second_currency"/>
+ <label name="second_currency"/>
+ <field name="second_currency"/>
+
<label name="party"/>
<field name="party"/>
<label name="account"/>
<field name="account"/>
+
<label name="description"/>
<field name="description" colspan="3"/>
+
<field name="information" colspan="4"/>
+
<field name="lines" colspan="4"/>
</form>
diff --git a/tryton/modules/account_statement/view/statement_origin_tree.xml b/tryton/modules/account_statement/view/statement_origin_tree.xml
index 4f53a009ae..d3c1707362 100644
--- a/tryton/modules/account_statement/view/statement_origin_tree.xml
+++ b/tryton/modules/account_statement/view/statement_origin_tree.xml
@@ -6,6 +6,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="number"/>
<field name="date"/>
<field name="amount" sum="Amount"/>
+ <field name="amount_second_currency" optional="1"/>
<field name="pending_amount"/>
<field name="party" expand="1"/>
<field name="account" expand="1"/>

View File

@ -1,24 +0,0 @@
diff -r 6c1f98f2f997 account.xml
--- a/tryton/modules/analytic_account/account.xml Sun Apr 07 19:50:02 2019 +0200
+++ b/tryton/modules/analytic_account/account.xml Fri Apr 12 21:23:20 2019 +0200
@@ -160,5 +160,20 @@
<field name="type">tree</field>
<field name="name">analytic_account_entry_tree</field>
</record>
+
+ <record model="ir.rule.group" id="rule_analytic_account">
+ <field name="name">User in company</field>
+ <field name="model"
+ search="[('model', '=', 'analytic_account.account')]"/>
+ <field name="global_p" eval="True"/>
+ </record>
+ <record model="ir.rule" id="rule_analytic_account1">
+ <field name="domain"
+ eval="[('company', 'in', Eval('user', {}).get('companies', []))]"
+ pyson="1"/>
+ <field name="rule_group" ref="rule_analytic_account"/>
+ </record>
+
+
</data>
</tryton>

68
issue12678.diff Normal file
View File

@ -0,0 +1,68 @@
diff --git a/tryton/modules/account_statement/message.xml b/tryton/modules/account_statement/message.xml
index d46ddec636..341ee11bc9 100644
--- a/tryton/modules/account_statement/message.xml
+++ b/tryton/modules/account_statement/message.xml
@@ -39,6 +39,12 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_line_amount_non_zero">
<field name="text">Statement line amount cannot be zero.</field>
</record>
+ <record model="ir.message" id="msg_statement_line_delete_cancel_draft">
+ <field name="text">To delete line "%(line)s" you must cancel or reset to draft statement "%(statement)s".</field>
+ </record>
+ <record model="ir.message" id="msg_statement_origin_delete_cancel_draft">
+ <field name="text">To delete origin "%(origin)s" you must cancel or reset to draft statement "%(statement)s".</field>
+ </record>
<record model="ir.message" id="msg_post_statement_move">
<field name="text">To post the move "%(move)s" you must post the statement "%(statement)s".</field>
</record>
diff --git a/tryton/modules/account_statement/statement.py b/tryton/modules/account_statement/statement.py
index d0b426bc4e..e874e24c4c 100644
--- a/tryton/modules/account_statement/statement.py
+++ b/tryton/modules/account_statement/statement.py
@@ -761,7 +761,7 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
states=_states,
context={'with_payment': False})
origin = fields.Many2One('account.statement.origin', 'Origin',
- readonly=True,
+ readonly=True, ondelete='RESTRICT',
states={
'invisible': ~Bool(Eval('origin')),
},
@@ -939,6 +939,18 @@ class Line(origin_mixin(_states), sequence_ordered(), ModelSQL, ModelView):
def search_rec_name(cls, name, clause):
return [('statement.rec_name',) + tuple(clause[1:])]
+ @classmethod
+ def delete(cls, lines):
+ for line in lines:
+ if line.statement_state not in {'cancelled', 'draft'}:
+ raise AccessError(
+ gettext(
+ 'account_statement.'
+ 'msg_statement_line_delete_cancel_draft',
+ line=line.rec_name,
+ sale=line.statement.rec_name))
+ super().delete(lines)
+
@classmethod
def copy(cls, lines, default=None):
if default is None:
@@ -1168,6 +1180,18 @@ class Origin(origin_mixin(_states), ModelSQL, ModelView):
group_by=table.id))
return [('id', 'in', query)]
+ @classmethod
+ def delete(cls, origins):
+ for origin in origins:
+ if origin.statement_state not in {'cancelled', 'draft'}:
+ raise AccessError(
+ gettext(
+ 'account_statement.'
+ 'msg_statement_origin_delete_cancel_draft',
+ origin=origin.rec_name,
+ sale=origin.statement.rec_name))
+ super().delete(origins)
+
@classmethod
def copy(cls, origins, default=None):
default = default.copy() if default is not None else {}

View File

@ -1,20 +0,0 @@
diff -r 27ef44e71712 inventory.xml
--- a/tryton/modules/stock/inventory.xml Thu Apr 04 17:02:50 2019 +0200
+++ b/tryton/modules/stock/inventory.xml Thu Apr 04 17:10:20 2019 +0200
@@ -60,6 +60,16 @@
<field name="name">inventory_line_tree</field>
</record>
+ <record model="ir.rule.group" id="rule_group_inventory">
+ <field name="name">Inventory Group</field>
+ <field name="model" search="[('model', '=', 'stock.inventory')]"/>
+ <field name="global_p" eval="True"/>
+ </record>
+ <record model="ir.rule" id="rule_inventory">
+ <field name="domain" eval="[('company', 'in', Eval('user', {}).get('companies', []))]" pyson="1"/>
+ <field name="rule_group" ref="rule_group_inventory"/>
+ </record>
+
<record model="ir.model.access" id="access_inventory">
<field name="model" search="[('model', '=', 'stock.inventory')]"/>
<field name="perm_read" eval="False"/>

22
issue7672.diff Normal file
View File

@ -0,0 +1,22 @@
diff --git a/tryton/modules/stock/product.py b/tryton/modules/stock/product.py
index 4ae0e95154..7e53384a3c 100644
--- a/tryton/modules/stock/product.py
+++ b/tryton/modules/stock/product.py
@@ -1153,6 +1153,8 @@ class ModifyCostPrice(Wizard):
def get_revision(self, Revision):
return Revision(
+ template=None,
+ product=None,
company=Transaction().context.get('company'),
date=self.start.date,
cost_price=self.start.cost_price,
@@ -1245,7 +1247,7 @@ class CostPriceRevision(ModelSQL, ModifyCostPriceStart):
raise ProductCostPriceError(
gettext('stock.msg_invalid_cost_price',
cost_price=self.cost_price,
- product=product.rec_name,
+ product=product.rec_name if product else '',
exception=exception)) from exception
if not isinstance(amount, Decimal):
raise ProductCostPriceError(

View File

@ -11,3 +11,29 @@ index 312c014d4e..4cfdd9b2c9 100644
msgctxt "model:ir.message,text:msg_erase_party_pending_invoice"
msgid ""
diff --git a/tryton/modules/project_invoice/locale/es.po b/tryton/modules/project_invoice/locale/es.po
index 2f3580e1cb..b60b878324 100644
--- a/tryton/modules/project_invoice/locale/es.po
+++ b/tryton/modules/project_invoice/locale/es.po
@@ -76,7 +76,7 @@ msgstr "No puede eliminar una línea facturada."
msgctxt "model:ir.message,text:msg_missing_account_revenue"
msgid "To invoice work \"%(work)s\" you must configure a default account revenue."
msgstr ""
-"Para facturar el trabajo \"%(works)\" debéis configurar una cuenta de "
+"Para facturar el trabajo \"%(work)s\" debéis configurar una cuenta de "
"ingressos por defecto."
msgctxt "model:ir.message,text:msg_missing_list_price"
diff --git a/tryton/modules/purchase/locale/ca.po b/tryton/modules/purchase/locale/ca.po
index d02f1a8a2f..129a59e3a7 100644
--- a/tryton/modules/purchase/locale/ca.po
+++ b/tryton/modules/purchase/locale/ca.po
@@ -716,7 +716,7 @@ msgid ""
"To invoice purchase \"%(purchase)s\" you must configure a default account "
"expense."
msgstr ""
-"Per facturar la compra \"%(purchase)\" heu de configurar un compte de "
+"Per facturar la compra \"%(purchase)s\" heu de configurar un compte de "
"despeses per defecte."
msgctxt "model:ir.message,text:msg_purchase_modify_header_draft"

35
sao_document_field.diff Normal file
View File

@ -0,0 +1,35 @@
--- a/sao/src/view/form.js
+++ b/sao/src/view/form.js
@@ -4415,15 +4418,20 @@ function eval_pyson(value){
this.el = jQuery('<div/>', {
'class': this.class_,
});
-
+ this.object = null;
+ },
+ create_object: function() {
+ if (this.object) {
+ this.object.remove();
+ }
this.object = jQuery('<object/>', {
'class': 'center-block',
}).appendTo(this.el);
- if (attributes.height) {
- this.object.css('height', parseInt(attributes.height, 10));
+ if (this.attributes.height) {
+ this.object.css('height', parseInt(this.attributes.height, 10));
}
- if (attributes.width) {
- this.object.css('width', parseInt(attributes.width, 10));
+ if (this.attributes.width) {
+ this.object.css('width', parseInt(this.attributes.width, 10));
}
},
display: function() {
@@ -4456,6 +4464,7 @@ function eval_pyson(value){
});
url = window.URL.createObjectURL(blob);
}
+ this.create_object();
this.object.attr('data', url);
this.object.get(0).onload = function() {

12
series
View File

@ -8,10 +8,8 @@ issue4506.diff # [account_invoice] Add credit invoices keyword from account.invo
issue8479.diff # [account_invoice] missing invoice payment method rule by company
issue8618.diff # [account_invoice] Allow changing amount in manual invoice taxes
issue4030.diff # [analytic_account] Not selected root accounts in analytic account lines
analitic_line_company_rules.diff # [analytic_account] Not selected root accounts in analytic account lines
sale_supply_supply_on_sale_multivalue.diff # [sale_supply] supply_on_sale field multvalue #035100
issue4482.diff # [stock] stock inventory misses company access rule
search_warehouse.diff # [stock] search function for warehouse
model.diff # [trytond] Allows dynamic fields in Model as required by the wizard in sale_pos_template_quantities
@ -54,6 +52,16 @@ merge_request779.diff # [account_payment] Warn when submitting, approving or pro
issue12576.diff # [account_stock_eu] Could not find the intrastat countries for moves
issue7672.diff # [stock] Always fill product and template of cost price revision
issue12678.diff # [account_statement] Not delete statement lines when statament is not draft state
account_statement_second_currency.diff # [account_statement] Support second currency on statement line
update_trees_chart_accounts.diff # [account_account] Update trees of chart of accounts with 2 passes
sao_document_field.diff # [sao] fix issue with loading of 'document' fields in sao
product_cost_price_migration.diff # [product] Add missing column in product_cost_price
table_rename.diff # [trytond] Add missing sequence rename in table_rename function

View File

@ -0,0 +1,151 @@
diff --git a/tryton/modules/account/account.py b/tryton/modules/account/account.py
index 05730d5b6e..c418aa0227 100644
--- a/tryton/modules/account/account.py
+++ b/tryton/modules/account/account.py
@@ -434,8 +434,11 @@ class Type(
if child.template:
if not child.template_override:
if child.template.parent:
+ # Fallback to current parent
+ # to keep under the same root
parent = template2type.get(
- child.template.parent.id)
+ child.template.parent.id,
+ child.parent)
else:
parent = None
old_parent = (
@@ -3309,6 +3312,8 @@ class UpdateChart(Wizard):
account.type.template.create_type(
company.id,
template2type=template2type)
+ # Update again to set new parent
+ account.type.update_type(template2type=template2type)
# Update accounts
template2account = {}
@@ -3333,6 +3338,11 @@ class UpdateChart(Wizard):
account.template.id, account.company.id,
template2account=template2account,
template2tax=template2tax)
+ # Update again to set new parent
+ Tax.update_tax(
+ company.id,
+ template2account=template2account,
+ template2tax=template2tax)
# Update tax codes
template2tax_code = {}
@@ -3344,6 +3354,10 @@ class UpdateChart(Wizard):
TaxCodeTemplate.create_tax_code(
account.template.id, company.id,
template2tax_code=template2tax_code)
+ # Update again to set new parent
+ TaxCode.update_tax_code(
+ company.id,
+ template2tax_code=template2tax_code)
# Update tax code lines
template2tax_code_line = {}
@@ -3360,7 +3374,7 @@ class UpdateChart(Wizard):
template2tax_code=template2tax_code,
template2tax_code_line=template2tax_code_line)
- # Update taxes and replaced_by on accounts
+ # Update parent, taxes and replaced_by on accounts
account.update_account2(template2account, template2tax)
# Update tax rules
diff --git a/tryton/modules/account/tax.py b/tryton/modules/account/tax.py
index 5c13e8e53e..4528d58aa0 100644
--- a/tryton/modules/account/tax.py
+++ b/tryton/modules/account/tax.py
@@ -292,8 +292,8 @@ class TaxCode(
if child.template:
if not child.template_override:
if child.template.parent:
- parent = template2tax_code[
- child.template.parent.id]
+ parent = template2tax_code.get(
+ child.template.parent.id)
else:
parent = None
old_parent = (
@@ -1172,7 +1172,7 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin):
if child.template:
if not child.template_override:
if child.template.parent:
- parent = template2tax[child.template.parent.id]
+ parent = template2tax.get(child.template.parent.id)
else:
parent = None
old_parent = (
diff --git a/tryton/modules/account/tests/test_module.py b/tryton/modules/account/tests/test_module.py
index 5ce6b9da79..56cd49fb5b 100644
--- a/tryton/modules/account/tests/test_module.py
+++ b/tryton/modules/account/tests/test_module.py
@@ -1861,5 +1861,64 @@ class AccountTestCase(
Account.search([('name', '=', 'Main Cash')], count=True),
1)
+ @with_transaction()
+ def test_update_chart_new_parent(self):
+ "Test update chart of accounts with new parent"
+ pool = Pool()
+ ModelData = pool.get('ir.model.data')
+ TypeTemplate = pool.get('account.account.type.template')
+ Type = pool.get('account.account.type')
+ AccountTemplate = pool.get('account.account.template')
+ Account = pool.get('account.account')
+ UpdateChart = pool.get('account.update_chart', type='wizard')
+
+ company = create_company()
+ with set_company(company):
+ create_chart(company, True)
+
+ with Transaction().set_user(0):
+ root_type_template = TypeTemplate(ModelData.get_id(
+ 'account', 'account_type_template_minimal_en'))
+
+ type_template, = TypeTemplate.search([
+ ('parent', '!=', None),
+ ('parent', 'child_of', [root_type_template.id]),
+ ], limit=1)
+ new_type_template, = TypeTemplate.copy([type_template])
+ type_template.parent = new_type_template
+ type_template.save()
+
+ root_template = AccountTemplate(ModelData.get_id(
+ 'account', 'account_template_root_en'))
+
+ account_template, = AccountTemplate.search([
+ ('parent', '!=', None),
+ ('parent', 'child_of', [root_template.id]),
+ ], limit=1)
+ new_account_template, = AccountTemplate.copy([account_template])
+ account_template.parent = new_account_template
+ account_template.save()
+
+ with set_company(company):
+ account, = Account.search([('parent', '=', None)])
+ session_id, _, _ = UpdateChart.create()
+ update_chart = UpdateChart(session_id)
+ update_chart.start.account = account
+ update_chart.transition_update()
+
+ new_type, = Type.search(
+ [('template', '=', new_type_template.id)])
+ type, = Type.search(
+ [('template', '=', type_template.id)])
+
+ self.assertEqual(type.parent, new_type)
+
+ new_account, = Account.search(
+ [('template', '=', new_account_template.id)])
+ account, = Account.search(
+ [('template', '=', account_template.id)])
+
+ self.assertEqual(account.parent, new_account)
+
del ModuleTestCase