-
Notifications
You must be signed in to change notification settings - Fork 1
/
line.py
43 lines (36 loc) · 1.53 KB
/
line.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta
class Line(metaclass=PoolMeta):
__name__ = 'analytic_account.line'
party = fields.Function(fields.Many2One('party.party', 'Party'),
'get_party', searcher='search_party')
invoice = fields.Function(fields.Many2One('account.invoice', 'Invoice'),
'get_invoice', searcher='search_invoice')
@classmethod
def get_party(self, lines, name=None):
parties = {}
for line in lines:
party = None
if (line.move_line and line.move_line.origin
and line.move_line.origin.__name__ == 'account.invoice'):
party = line.move_line.origin.party.id
parties[line.id] = party
return parties
@classmethod
def search_party(cls, name, clause):
return [('move_line.origin.party', clause[1], clause[2], 'account.invoice')]
@classmethod
def get_invoice(self, lines, name=None):
invoices = {}
for line in lines:
invoice = None
if (line.move_line and line.move_line.origin
and line.move_line.origin.__name__ == 'account.invoice'):
invoice = line.move_line.origin.id
invoices[line.id] = invoice
return invoices
@classmethod
def search_invoice(cls, name, clause):
return [('move_line.origin.rec_name', clause[1], clause[2], 'account.invoice')]