-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathanalytic_account.py
31 lines (27 loc) · 1.06 KB
/
analytic_account.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
# This file is part of Tryton. 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
from trytond.pyson import Eval
class Rule(metaclass=PoolMeta):
__name__ = 'analytic_account.rule'
product = fields.Many2One(
'product.product', "Product", ondelete='CASCADE',
context={
'company': Eval('company', -1),
},
depends={'company'})
product_category = fields.Many2One(
'product.category', "Product Category", ondelete='CASCADE',
context={
'company': Eval('company', -1),
},
depends={'company'})
def match(self, pattern):
if 'product_categories' in pattern:
pattern = pattern.copy()
categories = pattern.pop('product_categories')
if (self.product_category is not None
and self.product_category.id not in categories):
return False
return super().match(pattern)