mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
Updated analytic_account/invoice/purchase/sale to commited version
This commit is contained in:
parent
763dedd41c
commit
75921cd589
|
@ -7,12 +7,9 @@ issue5104
|
||||||
|
|
||||||
review19141003
|
review19141003
|
||||||
|
|
||||||
Index: trytond/trytond/modules/analytic_account/account.py
|
diff -r 4563c00a165b account.py
|
||||||
===================================================================
|
--- a/trytond/trytond/modules/analytic_account/account.py Mon Nov 02 15:30:50 2015 +0100
|
||||||
|
+++ b/trytond/trytond/modules/analytic_account/account.py Wed Sep 28 17:02:53 2016 +0200
|
||||||
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 @@
|
@@ -8,7 +8,7 @@
|
||||||
from trytond import backend
|
from trytond import backend
|
||||||
from trytond.model import ModelView, ModelSQL, fields, Unique
|
from trytond.model import ModelView, ModelSQL, fields, Unique
|
||||||
|
@ -21,7 +18,7 @@ diff -r 0cd556f1c82c account.py
|
||||||
+from trytond.pyson import Eval, If, PYSONEncoder, PYSONDecoder
|
+from trytond.pyson import Eval, If, PYSONEncoder, PYSONDecoder
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
@@ -22,7 +22,7 @@
|
||||||
name = fields.Char('Name', required=True, translate=True, select=True)
|
name = fields.Char('Name', required=True, translate=True, select=True)
|
||||||
code = fields.Char('Code', select=True)
|
code = fields.Char('Code', select=True)
|
||||||
|
@ -35,36 +32,53 @@ diff -r 0cd556f1c82c account.py
|
||||||
], 'Type', required=True)
|
], 'Type', required=True)
|
||||||
root = fields.Many2One('analytic_account.account', 'Root', select=True,
|
root = fields.Many2One('analytic_account.account', 'Root', select=True,
|
||||||
domain=[
|
domain=[
|
||||||
+ ('company', '=', Eval('company')),
|
+ ('company', '=', Eval('company', -1)),
|
||||||
('parent', '=', None),
|
('parent', '=', None),
|
||||||
('type', '=', 'root'),
|
('type', '=', 'root'),
|
||||||
],
|
],
|
||||||
@@ -40,7 +41,7 @@
|
@@ -40,15 +41,22 @@
|
||||||
'invisible': Eval('type') == 'root',
|
'invisible': Eval('type') == 'root',
|
||||||
'required': Eval('type') != 'root',
|
'required': Eval('type') != 'root',
|
||||||
},
|
},
|
||||||
- depends=['type'])
|
- depends=['type'])
|
||||||
+ depends=['company', 'type'])
|
+ depends=['company', 'type'])
|
||||||
parent = fields.Many2One('analytic_account.account', 'Parent', select=True,
|
parent = fields.Many2One('analytic_account.account', 'Parent', select=True,
|
||||||
domain=[('parent', 'child_of', Eval('root'))],
|
- domain=[('parent', 'child_of', Eval('root'))],
|
||||||
|
+ domain=['OR',
|
||||||
|
+ ('root', '=', Eval('root', -1)),
|
||||||
|
+ ('parent', '=', None),
|
||||||
|
+ ],
|
||||||
states={
|
states={
|
||||||
@@ -311,19 +312,26 @@
|
'invisible': Eval('type') == 'root',
|
||||||
|
'required': Eval('type') != 'root',
|
||||||
|
},
|
||||||
|
depends=['root', 'type'])
|
||||||
|
- childs = fields.One2Many('analytic_account.account', 'parent', 'Children')
|
||||||
|
+ childs = fields.One2Many('analytic_account.account', 'parent', 'Children',
|
||||||
|
+ domain=[
|
||||||
|
+ ('company', '=', Eval('company', -1)),
|
||||||
|
+ ],
|
||||||
|
+ depends=['company'])
|
||||||
|
balance = fields.Function(fields.Numeric('Balance',
|
||||||
|
digits=(16, Eval('currency_digits', 1)), depends=['currency_digits']),
|
||||||
|
'get_balance')
|
||||||
|
@@ -311,7 +319,14 @@
|
||||||
__name__ = 'analytic.account.entry'
|
__name__ = 'analytic.account.entry'
|
||||||
origin = fields.Reference('Origin', selection='get_origin', select=True)
|
origin = fields.Reference('Origin', selection='get_origin', select=True)
|
||||||
root = fields.Many2One('analytic_account.account', 'Root Analytic',
|
root = fields.Many2One('analytic_account.account', 'Root Analytic',
|
||||||
- domain=[('type', '=', 'root')])
|
- domain=[('type', '=', 'root')])
|
||||||
+ domain=[
|
+ domain=[
|
||||||
+ ('company', '=', Eval('company')),
|
+ If(~Eval('company'),
|
||||||
|
+ # No constraint if the origin is not set
|
||||||
|
+ (),
|
||||||
|
+ ('company', '=', Eval('company', -1))),
|
||||||
+ ('type', '=', 'root'),
|
+ ('type', '=', 'root'),
|
||||||
+ ],
|
+ ],
|
||||||
+ depends=['company'])
|
+ depends=['company'])
|
||||||
account = fields.Many2One('analytic_account.account', 'Account',
|
account = fields.Many2One('analytic_account.account', 'Account',
|
||||||
ondelete='RESTRICT',
|
ondelete='RESTRICT',
|
||||||
states={
|
states={
|
||||||
'required': Eval('required', False),
|
@@ -321,9 +336,11 @@
|
||||||
},
|
|
||||||
domain=[
|
|
||||||
+ ('company', '=', Eval('company')),
|
|
||||||
('root', '=', Eval('root')),
|
('root', '=', Eval('root')),
|
||||||
('type', '=', 'normal'),
|
('type', '=', 'normal'),
|
||||||
],
|
],
|
||||||
|
@ -74,53 +88,41 @@ diff -r 0cd556f1c82c account.py
|
||||||
'on_change_with_required')
|
'on_change_with_required')
|
||||||
+ company = fields.Function(fields.Many2One('company.company', 'Company'),
|
+ company = fields.Function(fields.Many2One('company.company', 'Company'),
|
||||||
+ 'on_change_with_company', searcher='search_company')
|
+ 'on_change_with_company', searcher='search_company')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __register__(cls, module_name):
|
def __register__(cls, module_name):
|
||||||
@@ -386,12 +394,27 @@
|
@@ -386,6 +403,13 @@
|
||||||
return self.root.mandatory
|
return self.root.mandatory
|
||||||
return False
|
return False
|
||||||
|
|
||||||
+ @classmethod
|
|
||||||
+ def default_company(cls):
|
|
||||||
+ return Transaction().context.get('company')
|
|
||||||
+
|
|
||||||
+ def on_change_with_company(self, name=None):
|
+ def on_change_with_company(self, name=None):
|
||||||
+ return Transaction().context.get('company')
|
+ return None
|
||||||
+
|
+
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
+ def search_company(cls, name, clause):
|
+ def search_company(cls, name, clause):
|
||||||
+ raise NotImplementedError()
|
+ return []
|
||||||
+
|
+
|
||||||
|
|
||||||
class AnalyticMixin(ModelSQL):
|
class AnalyticMixin(ModelSQL):
|
||||||
|
|
||||||
analytic_accounts = fields.One2Many('analytic.account.entry', 'origin',
|
@@ -427,13 +451,21 @@
|
||||||
'Analytic Accounts',
|
|
||||||
size=Eval('analytic_accounts_size', 0),
|
|
||||||
+ domain=[
|
|
||||||
+ ('company', If(Eval('context', {}).contains('company'), '=', '!='),
|
|
||||||
+ Eval('context', {}).get('company', -1)),
|
|
||||||
+ ],
|
|
||||||
depends=['analytic_accounts_size'])
|
|
||||||
analytic_accounts_size = fields.Function(fields.Integer(
|
|
||||||
'Analytic Accounts Size'), 'get_analytic_accounts_size')
|
|
||||||
@@ -427,13 +450,19 @@
|
|
||||||
where=entry.selection == selection_id))
|
where=entry.selection == selection_id))
|
||||||
handler.drop_column('analytic_accounts')
|
handler.drop_column('analytic_accounts')
|
||||||
|
|
||||||
- @staticmethod
|
- @staticmethod
|
||||||
- def default_analytic_accounts():
|
- def default_analytic_accounts():
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
+ def analytic_accounts_domain(cls):
|
+ def analytic_accounts_domain(cls):
|
||||||
+ return PYSONDecoder(Transaction().context).decode(
|
+ context = Transaction().context.copy()
|
||||||
|
+ context['context'] = context
|
||||||
|
+ return PYSONDecoder(context).decode(
|
||||||
+ PYSONEncoder().encode(cls.analytic_accounts.domain))
|
+ PYSONEncoder().encode(cls.analytic_accounts.domain))
|
||||||
+
|
+
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
+ def default_analytic_accounts(cls):
|
+ def default_analytic_accounts(cls):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
AnalyticAccount = pool.get('analytic_account.account')
|
AnalyticAccount = pool.get('analytic_account.account')
|
||||||
|
|
||||||
accounts = []
|
accounts = []
|
||||||
- root_accounts = AnalyticAccount.search([
|
- root_accounts = AnalyticAccount.search([
|
||||||
+ root_accounts = AnalyticAccount.search(
|
+ root_accounts = AnalyticAccount.search(
|
||||||
|
@ -128,10 +130,10 @@ diff -r 0cd556f1c82c account.py
|
||||||
('parent', '=', None),
|
('parent', '=', None),
|
||||||
])
|
])
|
||||||
for account in root_accounts:
|
for account in root_accounts:
|
||||||
@@ -443,11 +472,14 @@
|
@@ -443,11 +475,14 @@
|
||||||
})
|
})
|
||||||
return accounts
|
return accounts
|
||||||
|
|
||||||
- @staticmethod
|
- @staticmethod
|
||||||
- def default_analytic_accounts_size():
|
- def default_analytic_accounts_size():
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
|
@ -143,10 +145,10 @@ diff -r 0cd556f1c82c account.py
|
||||||
+ cls.analytic_accounts_domain() + [
|
+ cls.analytic_accounts_domain() + [
|
||||||
+ ('type', '=', 'root'),
|
+ ('type', '=', 'root'),
|
||||||
+ ]))
|
+ ]))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_analytic_accounts_size(cls, records, name):
|
def get_analytic_accounts_size(cls, records, name):
|
||||||
@@ -464,12 +496,17 @@
|
@@ -464,12 +499,17 @@
|
||||||
"Check that all mandatory root entries are defined in entries"
|
"Check that all mandatory root entries are defined in entries"
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Account = pool.get('analytic_account.account')
|
Account = pool.get('analytic_account.account')
|
||||||
|
@ -165,41 +167,10 @@ diff -r 0cd556f1c82c account.py
|
||||||
if not mandatory_roots <= analytic_roots:
|
if not mandatory_roots <= analytic_roots:
|
||||||
cls.raise_user_error('root_account', {
|
cls.raise_user_error('root_account', {
|
||||||
'name': analytic.rec_name,
|
'name': analytic.rec_name,
|
||||||
diff -r 0cd556f1c82c account.xml
|
diff -r 4563c00a165b line.py
|
||||||
--- a/trytond/trytond/modules/analytic_account/account.xml Sun Mar 13 16:19:22 2016 +0100
|
--- a/trytond/trytond/modules/analytic_account/line.py Mon Nov 02 15:30:50 2015 +0100
|
||||||
+++ b/trytond/trytond/modules/analytic_account/account.xml Tue Apr 26 18:24:04 2016 +0200
|
+++ b/trytond/trytond/modules/analytic_account/line.py Wed Sep 28 17:02:53 2016 +0200
|
||||||
@@ -124,5 +124,27 @@
|
@@ -25,7 +25,7 @@
|
||||||
<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'),
|
currency_digits = fields.Function(fields.Integer('Currency Digits'),
|
||||||
'on_change_with_currency_digits')
|
'on_change_with_currency_digits')
|
||||||
company = fields.Function(fields.Many2One('company.company', 'Company'),
|
company = fields.Function(fields.Many2One('company.company', 'Company'),
|
||||||
|
@ -208,10 +179,10 @@ diff -r 0cd556f1c82c line.py
|
||||||
account = fields.Many2One('analytic_account.account', 'Account',
|
account = fields.Many2One('analytic_account.account', 'Account',
|
||||||
required=True, select=True, domain=[
|
required=True, select=True, domain=[
|
||||||
('type', '!=', 'view'),
|
('type', '!=', 'view'),
|
||||||
@@ -104,6 +104,10 @@
|
@@ -106,6 +106,10 @@
|
||||||
if self.move_line:
|
if self.move_line:
|
||||||
return self.move_line.account.company.id
|
return self.move_line.account.company.id
|
||||||
|
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
+ def search_company(cls, name, clause):
|
+ def search_company(cls, name, clause):
|
||||||
+ return [('move_line.account.company',) + tuple(clause[1:])]
|
+ return [('move_line.account.company',) + tuple(clause[1:])]
|
||||||
|
@ -219,22 +190,3 @@ diff -r 0cd556f1c82c line.py
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def query_get(table):
|
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>
|
|
||||||
|
|
|
@ -8,19 +8,36 @@ issue5104
|
||||||
|
|
||||||
review24081002
|
review24081002
|
||||||
|
|
||||||
Index: trytond/trytond/modules/analytic_invoice/invoice.py
|
diff -r a840721ef787 invoice.py
|
||||||
===================================================================
|
--- a/trytond/trytond/modules/analytic_invoice/invoice.py Mon Nov 02 15:31:51 2015 +0100
|
||||||
|
+++ b/trytond/trytond/modules/analytic_invoice/invoice.py Wed Sep 28 17:04:21 2016 +0200
|
||||||
--- a/trytond/trytond/modules/analytic_invoice/invoice.py
|
@@ -1,6 +1,8 @@
|
||||||
+++ b/trytond/trytond/modules/analytic_invoice/invoice.py
|
|
||||||
@@ -1,5 +1,6 @@
|
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
+from trytond.model import fields
|
+from trytond.model import fields
|
||||||
from trytond.pool import PoolMeta, Pool
|
from trytond.pool import PoolMeta, Pool
|
||||||
|
+from trytond.pyson import Eval, If
|
||||||
|
|
||||||
from trytond.modules.analytic_account import AnalyticMixin
|
from trytond.modules.analytic_account import AnalyticMixin
|
||||||
@@ -61,3 +62,24 @@
|
|
||||||
|
@@ -11,6 +13,16 @@
|
||||||
|
class InvoiceLine(AnalyticMixin):
|
||||||
|
__name__ = 'account.invoice.line'
|
||||||
|
|
||||||
|
+ @classmethod
|
||||||
|
+ def __setup__(cls):
|
||||||
|
+ super(InvoiceLine, cls).__setup__()
|
||||||
|
+ cls.analytic_accounts.domain = [
|
||||||
|
+ ('company', '=', If(~Eval('company'),
|
||||||
|
+ Eval('context', {}).get('company', -1),
|
||||||
|
+ Eval('company', -1))),
|
||||||
|
+ ]
|
||||||
|
+ cls.analytic_accounts.depends.append('company')
|
||||||
|
+
|
||||||
|
def _credit(self):
|
||||||
|
pool = Pool()
|
||||||
|
AnalyticAccountEntry = pool.get('analytic.account.entry')
|
||||||
|
@@ -61,3 +73,22 @@
|
||||||
def _get_origin(cls):
|
def _get_origin(cls):
|
||||||
origins = super(AnalyticAccountEntry, cls)._get_origin()
|
origins = super(AnalyticAccountEntry, cls)._get_origin()
|
||||||
return origins + ['account.invoice.line']
|
return origins + ['account.invoice.line']
|
||||||
|
@ -32,17 +49,14 @@ Index: trytond/trytond/modules/analytic_invoice/invoice.py
|
||||||
+ company = super(AnalyticAccountEntry, self).on_change_with_company(
|
+ company = super(AnalyticAccountEntry, self).on_change_with_company(
|
||||||
+ name)
|
+ name)
|
||||||
+ if isinstance(self.origin, InvoiceLine):
|
+ if isinstance(self.origin, InvoiceLine):
|
||||||
+ if self.origin.invoice:
|
+ company = self.origin.company.id
|
||||||
+ return self.origin.invoice.company.id
|
|
||||||
+ elif self.origin.company:
|
|
||||||
+ return self.origin.company.id
|
|
||||||
+ return company
|
+ return company
|
||||||
+
|
+
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
+ def search_company(cls, name, clause):
|
+ def search_company(cls, name, clause):
|
||||||
|
+ domain = super(AnalyticAccountEntry, cls).search_company(name, clause),
|
||||||
+ return ['OR',
|
+ return ['OR',
|
||||||
+ [('origin.company',) + tuple(clause[1:]) +
|
+ domain,
|
||||||
+ tuple(('account.invoice.line',))],
|
+ (('origin.company',) + tuple(clause[1:]) +
|
||||||
+ [('origin.invoice.company',) + tuple(clause[1:]) +
|
+ ('account.invoice.line',)),
|
||||||
+ tuple(('account.invoice.line',))]]
|
+ ]
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,38 @@
|
||||||
# User Sergi Almacellas Abellana <sergi@koolpi.com>
|
# User Sergi Almacellas Abellana <sergi@koolpi.com>
|
||||||
Add company domain on analytic entries
|
Add company domain on analytic entries
|
||||||
|
|
||||||
issue5104
|
issue5104
|
||||||
|
|
||||||
review17201002
|
review17201002
|
||||||
|
|
||||||
Index: trytond/trytond/modules/analytic_purchase/purchase.py
|
diff -r 2ce8025167de purchase.py
|
||||||
===================================================================
|
--- a/trytond/trytond/modules/analytic_purchase/purchase.py Mon Nov 02 15:33:03 2015 +0100
|
||||||
|
+++ b/trytond/trytond/modules/analytic_purchase/purchase.py Wed Sep 28 17:09:30 2016 +0200
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
from trytond.model import fields
|
||||||
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
+from trytond.pyson import Eval, If
|
||||||
|
|
||||||
--- a/trytond/trytond/modules/analytic_purchase/purchase.py
|
from trytond.modules.analytic_account import AnalyticMixin
|
||||||
+++ b/trytond/trytond/modules/analytic_purchase/purchase.py
|
|
||||||
@@ -79,3 +79,22 @@
|
@@ -46,6 +47,15 @@
|
||||||
|
class PurchaseLine(AnalyticMixin):
|
||||||
|
__name__ = 'purchase.line'
|
||||||
|
|
||||||
|
+ @classmethod
|
||||||
|
+ def __setup__(cls):
|
||||||
|
+ super(PurchaseLine, cls).__setup__()
|
||||||
|
+ cls.analytic_accounts.domain = [
|
||||||
|
+ ('company', '=', If(~Eval('_parent_purchase'),
|
||||||
|
+ Eval('context', {}).get('company', -1),
|
||||||
|
+ Eval('_parent_purchase', {}).get('company', -1))),
|
||||||
|
+ ]
|
||||||
|
+
|
||||||
|
def get_invoice_line(self, invoice_type):
|
||||||
|
pool = Pool()
|
||||||
|
AnalyticAccountEntry = pool.get('analytic.account.entry')
|
||||||
|
@@ -79,3 +89,22 @@
|
||||||
and self.origin.purchase.state in ['cancel', 'draft']):
|
and self.origin.purchase.state in ['cancel', 'draft']):
|
||||||
return False
|
return False
|
||||||
return required
|
return required
|
||||||
|
@ -22,9 +44,8 @@ Index: trytond/trytond/modules/analytic_purchase/purchase.py
|
||||||
+ PurchaseLine = pool.get('purchase.line')
|
+ PurchaseLine = pool.get('purchase.line')
|
||||||
+ company = super(AnalyticAccountEntry, self).on_change_with_company(
|
+ company = super(AnalyticAccountEntry, self).on_change_with_company(
|
||||||
+ name)
|
+ name)
|
||||||
+ if isinstance(self.origin, PurchaseLine):
|
+ if isinstance(self.origin, PurchaseLine) and self.origin.purchase:
|
||||||
+ if self.origin.purchase:
|
+ company = self.origin.purchase.company.id
|
||||||
+ return self.origin.purchase.company.id
|
|
||||||
+ return company
|
+ return company
|
||||||
+
|
+
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
|
@ -32,6 +53,6 @@ Index: trytond/trytond/modules/analytic_purchase/purchase.py
|
||||||
+ domain = super(AnalyticAccountEntry, cls).search_company(name, clause)
|
+ domain = super(AnalyticAccountEntry, cls).search_company(name, clause)
|
||||||
+ return ['OR',
|
+ return ['OR',
|
||||||
+ domain,
|
+ domain,
|
||||||
+ [('origin.purchase.company',) + tuple(clause[1:]) +
|
+ (('origin.purchase.company',) + tuple(clause[1:])
|
||||||
+ tuple(('purchase.line',))]]
|
+ + ('purchase.line',)),
|
||||||
|
+ ]
|
||||||
|
|
|
@ -7,19 +7,35 @@ issue5104
|
||||||
|
|
||||||
review17991002
|
review17991002
|
||||||
|
|
||||||
Index: trytond/trytond/modules/analytic_sale/sale.py
|
diff -r cb4e222d5c45 sale.py
|
||||||
===================================================================
|
--- a/trytond/trytond/modules/analytic_sale/sale.py Mon Nov 02 15:34:18 2015 +0100
|
||||||
|
+++ b/trytond/trytond/modules/analytic_sale/sale.py Wed Sep 28 17:06:51 2016 +0200
|
||||||
--- a/trytond/trytond/modules/analytic_sale/sale.py
|
@@ -1,6 +1,8 @@
|
||||||
+++ b/trytond/trytond/modules/analytic_sale/sale.py
|
|
||||||
@@ -1,5 +1,6 @@
|
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
+from trytond.model import fields
|
+from trytond.model import fields
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
+from trytond.pyson import Eval, If
|
||||||
|
|
||||||
from trytond.modules.analytic_account import AnalyticMixin
|
from trytond.modules.analytic_account import AnalyticMixin
|
||||||
@@ -32,3 +33,22 @@
|
|
||||||
|
@@ -11,6 +13,15 @@
|
||||||
|
class SaleLine(AnalyticMixin):
|
||||||
|
__name__ = 'sale.line'
|
||||||
|
|
||||||
|
+ @classmethod
|
||||||
|
+ def __setup__(cls):
|
||||||
|
+ super(SaleLine, cls).__setup__()
|
||||||
|
+ cls.analytic_accounts.domain = [
|
||||||
|
+ ('company', '=', If(~Eval('_parent_sale', {}),
|
||||||
|
+ Eval('context', {}).get('company', -1),
|
||||||
|
+ Eval('_parent_sale', {}).get('company', -1))),
|
||||||
|
+ ]
|
||||||
|
+
|
||||||
|
def get_invoice_line(self, invoice_type):
|
||||||
|
pool = Pool()
|
||||||
|
AnalyticAccountEntry = pool.get('analytic.account.entry')
|
||||||
|
@@ -32,3 +43,21 @@
|
||||||
def _get_origin(cls):
|
def _get_origin(cls):
|
||||||
origins = super(AnalyticAccountEntry, cls)._get_origin()
|
origins = super(AnalyticAccountEntry, cls)._get_origin()
|
||||||
return origins + ['sale.line']
|
return origins + ['sale.line']
|
||||||
|
@ -30,16 +46,14 @@ Index: trytond/trytond/modules/analytic_sale/sale.py
|
||||||
+ SaleLine = pool.get('sale.line')
|
+ SaleLine = pool.get('sale.line')
|
||||||
+ company = super(AnalyticAccountEntry, self).on_change_with_company(
|
+ company = super(AnalyticAccountEntry, self).on_change_with_company(
|
||||||
+ name)
|
+ name)
|
||||||
+ if isinstance(self.origin, SaleLine):
|
+ if isinstance(self.origin, SaleLine) and self.origin.sale:
|
||||||
+ if self.origin.sale:
|
+ company = self.origin.sale.company.id
|
||||||
+ return self.origin.sale.company.id
|
|
||||||
+ return company
|
+ return company
|
||||||
+
|
+
|
||||||
+ @classmethod
|
+ @classmethod
|
||||||
+ def search_company(cls, name, clause):
|
+ def search_company(cls, name, clause):
|
||||||
+ domain = super(AnalyticAccountEntry, cls).search_company(name, clause)
|
+ domain = super(AnalyticAccountEntry, cls).search_company(name, clause),
|
||||||
+ return ['OR',
|
+ return ['OR',
|
||||||
+ domain,
|
+ domain,
|
||||||
+ [('origin.sale.company',) + tuple(clause[1:]) +
|
+ ('origin.sale.company',) + tuple(clause[1:]) + ('sale.line',),
|
||||||
+ tuple(('sale.line',))]]
|
+ ]
|
||||||
|
|
||||||
|
|
8
series
8
series
|
@ -1,4 +1,8 @@
|
||||||
account_move_line_rule.diff
|
account_move_line_rule.diff
|
||||||
|
analytic_account.diff
|
||||||
|
analytic_invoice.diff
|
||||||
|
analytic_sale.diff
|
||||||
|
analytic_purchase.diff
|
||||||
issue154_316.diff
|
issue154_316.diff
|
||||||
issue10467.diff
|
issue10467.diff
|
||||||
issue130_392_10919.diff
|
issue130_392_10919.diff
|
||||||
|
@ -33,10 +37,6 @@ issue23901002_1.diff
|
||||||
issue17881002_1.diff
|
issue17881002_1.diff
|
||||||
workflow-performance.diff
|
workflow-performance.diff
|
||||||
account_chart_speedup.diff
|
account_chart_speedup.diff
|
||||||
analytic_account.diff
|
|
||||||
analytic_invoice.diff
|
|
||||||
analytic_sale.diff
|
|
||||||
analytic_purchase.diff
|
|
||||||
tax_active_invisible.diff
|
tax_active_invisible.diff
|
||||||
account_product_rules.diff
|
account_product_rules.diff
|
||||||
issue5558.diff
|
issue5558.diff
|
||||||
|
|
Loading…
Reference in a new issue