-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmove.py
41 lines (32 loc) · 1.45 KB
/
move.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
# This file is part account_invoice_posted2draft module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
class Move(metaclass=PoolMeta):
__name__ = 'account.move'
@classmethod
def check_modify(cls, *args, **kwargs):
# As now the moves related to an invoice are not delete when 'draft'
# the invoice, is needed to modify some restricted fields when the
# move is in post state
if Transaction().context.get('invoice_posted2draft', False):
return
return super().check_modify(*args, **kwargs)
def get_allow_draft(self, name):
Invoice = Pool().get('account.invoice')
Move = Pool().get('account.move')
result = super().get_allow_draft(name)
if self.origin and isinstance(self.origin, (Invoice, Move)):
return True
return result
class Line(metaclass=PoolMeta):
__name__ = 'account.move.line'
@classmethod
def check_modify(cls, lines, modified_fields=None):
# As now the moves related to an invoice are not delete when 'draft'
# the invoice, is needed to modify some restricted fields when the
# move is in post state
if Transaction().context.get('invoice_posted2draft', False):
return
return super().check_modify(lines, modified_fields)