Improve analytic_account.diff with company rules.
(grafted from 04b15e82e472c97cbde62d9f04e20d895eb9e511)
This commit is contained in:
parent
5045c5ca09
commit
33a82e2a22
|
@ -10,8 +10,9 @@ review19141003
|
|||
Index: trytond/trytond/modules/analytic_account/account.py
|
||||
===================================================================
|
||||
|
||||
--- a/trytond/trytond/modules/analytic_account/account.py
|
||||
+++ b/trytond/trytond/modules/analytic_account/account.py
|
||||
diff -r 0cd556f1c82c account.py
|
||||
--- a/trytond/trytond/modules/analytic_account/account.py Sun Mar 13 16:19:22 2016 +0100
|
||||
+++ b/trytond/trytond/modules/analytic_account/account.py Tue Apr 26 18:24:04 2016 +0200
|
||||
@@ -8,7 +8,7 @@
|
||||
from trytond import backend
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique
|
||||
|
@ -20,7 +21,7 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
+from trytond.pyson import Eval, If, PYSONEncoder, PYSONDecoder
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
name = fields.Char('Name', required=True, translate=True, select=True)
|
||||
code = fields.Char('Code', select=True)
|
||||
|
@ -30,7 +31,24 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
currency = fields.Many2One('currency.currency', 'Currency', required=True)
|
||||
currency_digits = fields.Function(fields.Integer('Currency Digits'),
|
||||
'on_change_with_currency_digits')
|
||||
@@ -311,19 +311,26 @@
|
||||
@@ -33,6 +33,7 @@
|
||||
], 'Type', required=True)
|
||||
root = fields.Many2One('analytic_account.account', 'Root', select=True,
|
||||
domain=[
|
||||
+ ('company', '=', Eval('company')),
|
||||
('parent', '=', None),
|
||||
('type', '=', 'root'),
|
||||
],
|
||||
@@ -40,7 +41,7 @@
|
||||
'invisible': Eval('type') == 'root',
|
||||
'required': Eval('type') != 'root',
|
||||
},
|
||||
- depends=['type'])
|
||||
+ depends=['company', 'type'])
|
||||
parent = fields.Many2One('analytic_account.account', 'Parent', select=True,
|
||||
domain=[('parent', 'child_of', Eval('root'))],
|
||||
states={
|
||||
@@ -311,19 +312,26 @@
|
||||
__name__ = 'analytic.account.entry'
|
||||
origin = fields.Reference('Origin', selection='get_origin', select=True)
|
||||
root = fields.Many2One('analytic_account.account', 'Root Analytic',
|
||||
|
@ -56,13 +74,13 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
'on_change_with_required')
|
||||
+ company = fields.Function(fields.Many2One('company.company', 'Company'),
|
||||
+ 'on_change_with_company', searcher='search_company')
|
||||
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
@@ -386,12 +393,27 @@
|
||||
@@ -386,12 +394,27 @@
|
||||
return self.root.mandatory
|
||||
return False
|
||||
|
||||
|
||||
+ @classmethod
|
||||
+ def default_company(cls):
|
||||
+ return Transaction().context.get('company')
|
||||
|
@ -74,9 +92,9 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
+ def search_company(cls, name, clause):
|
||||
+ raise NotImplementedError()
|
||||
+
|
||||
|
||||
|
||||
class AnalyticMixin(ModelSQL):
|
||||
|
||||
|
||||
analytic_accounts = fields.One2Many('analytic.account.entry', 'origin',
|
||||
'Analytic Accounts',
|
||||
size=Eval('analytic_accounts_size', 0),
|
||||
|
@ -87,10 +105,10 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
depends=['analytic_accounts_size'])
|
||||
analytic_accounts_size = fields.Function(fields.Integer(
|
||||
'Analytic Accounts Size'), 'get_analytic_accounts_size')
|
||||
@@ -427,13 +449,19 @@
|
||||
@@ -427,13 +450,19 @@
|
||||
where=entry.selection == selection_id))
|
||||
handler.drop_column('analytic_accounts')
|
||||
|
||||
|
||||
- @staticmethod
|
||||
- def default_analytic_accounts():
|
||||
+ @classmethod
|
||||
|
@ -102,7 +120,7 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
+ def default_analytic_accounts(cls):
|
||||
pool = Pool()
|
||||
AnalyticAccount = pool.get('analytic_account.account')
|
||||
|
||||
|
||||
accounts = []
|
||||
- root_accounts = AnalyticAccount.search([
|
||||
+ root_accounts = AnalyticAccount.search(
|
||||
|
@ -110,10 +128,10 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
('parent', '=', None),
|
||||
])
|
||||
for account in root_accounts:
|
||||
@@ -443,11 +471,14 @@
|
||||
@@ -443,11 +472,14 @@
|
||||
})
|
||||
return accounts
|
||||
|
||||
|
||||
- @staticmethod
|
||||
- def default_analytic_accounts_size():
|
||||
+ @classmethod
|
||||
|
@ -125,10 +143,10 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
+ cls.analytic_accounts_domain() + [
|
||||
+ ('type', '=', 'root'),
|
||||
+ ]))
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_analytic_accounts_size(cls, records, name):
|
||||
@@ -464,12 +495,17 @@
|
||||
@@ -464,12 +496,17 @@
|
||||
"Check that all mandatory root entries are defined in entries"
|
||||
pool = Pool()
|
||||
Account = pool.get('analytic_account.account')
|
||||
|
@ -147,4 +165,76 @@ Index: trytond/trytond/modules/analytic_account/account.py
|
|||
if not mandatory_roots <= analytic_roots:
|
||||
cls.raise_user_error('root_account', {
|
||||
'name': analytic.rec_name,
|
||||
diff -r 0cd556f1c82c account.xml
|
||||
--- a/trytond/trytond/modules/analytic_account/account.xml Sun Mar 13 16:19:22 2016 +0100
|
||||
+++ b/trytond/trytond/modules/analytic_account/account.xml Tue Apr 26 18:24:04 2016 +0200
|
||||
@@ -124,5 +124,27 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="name">analytic_account_entry_tree</field>
|
||||
</record>
|
||||
+
|
||||
+ <record model="ir.rule.group" id="rule_group_account">
|
||||
+ <field name="model" search="[('model', '=', 'analytic_account.account')]"/>
|
||||
+ <field name="global_p" eval="True"/>
|
||||
+ </record>
|
||||
+ <record model="ir.rule" id="rule_account1">
|
||||
+ <field name="domain"
|
||||
+ eval="[('company', '=', Eval('user', {}).get('company', None))]"
|
||||
+ pyson="1"/>
|
||||
+ <field name="rule_group" ref="rule_group_account"/>
|
||||
+ </record>
|
||||
+
|
||||
+ <record model="ir.rule.group" id="rule_group_account_entry">
|
||||
+ <field name="model" search="[('model', '=', 'analytic.account.entry')]"/>
|
||||
+ <field name="global_p" eval="True"/>
|
||||
+ </record>
|
||||
+ <record model="ir.rule" id="rule_account_entry1">
|
||||
+ <field name="domain"
|
||||
+ eval="[('company', '=', Eval('user', {}).get('company', None))]"
|
||||
+ pyson="1"/>
|
||||
+ <field name="rule_group" ref="rule_group_account_entry"/>
|
||||
+ </record>
|
||||
</data>
|
||||
</tryton>
|
||||
diff -r 0cd556f1c82c line.py
|
||||
--- a/trytond/trytond/modules/analytic_account/line.py Sun Mar 13 16:19:22 2016 +0100
|
||||
+++ b/trytond/trytond/modules/analytic_account/line.py Tue Apr 26 18:24:04 2016 +0200
|
||||
@@ -24,7 +24,7 @@
|
||||
currency_digits = fields.Function(fields.Integer('Currency Digits'),
|
||||
'on_change_with_currency_digits')
|
||||
company = fields.Function(fields.Many2One('company.company', 'Company'),
|
||||
- 'on_change_with_company')
|
||||
+ 'on_change_with_company', searcher='search_company')
|
||||
account = fields.Many2One('analytic_account.account', 'Account',
|
||||
required=True, select=True, domain=[
|
||||
('type', '!=', 'view'),
|
||||
@@ -104,6 +104,10 @@
|
||||
if self.move_line:
|
||||
return self.move_line.account.company.id
|
||||
|
||||
+ @classmethod
|
||||
+ def search_company(cls, name, clause):
|
||||
+ return [('move_line.account.company',) + tuple(clause[1:])]
|
||||
+
|
||||
@staticmethod
|
||||
def query_get(table):
|
||||
'''
|
||||
diff -r 0cd556f1c82c line.xml
|
||||
--- a/trytond/trytond/modules/analytic_account/line.xml Sun Mar 13 16:19:22 2016 +0100
|
||||
+++ b/trytond/trytond/modules/analytic_account/line.xml Tue Apr 26 18:24:04 2016 +0200
|
||||
@@ -67,5 +67,15 @@
|
||||
<field name="name">move_line_form</field>
|
||||
</record>
|
||||
|
||||
+ <record model="ir.rule.group" id="rule_group_account_line">
|
||||
+ <field name="model" search="[('model', '=', 'analytic_account.line')]"/>
|
||||
+ <field name="global_p" eval="True"/>
|
||||
+ </record>
|
||||
+ <record model="ir.rule" id="rule_account_line1">
|
||||
+ <field name="domain"
|
||||
+ eval="[('company', '=', Eval('user', {}).get('company', None))]"
|
||||
+ pyson="1"/>
|
||||
+ <field name="rule_group" ref="rule_group_account_line"/>
|
||||
+ </record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
Loading…
Reference in New Issue