# HG changeset patch # User Àngel Àlvarez # Make the analytic account entries read-only depending on the state of the source docume… # issue11294 # tryton-env: Make the analytic account entries read-only depending on the state of the source docume… # review398021002 Index: 6.0/trytond/trytond/modules/analytic_account/account.py =================================================================== --- 6.0.orig/trytond/trytond/modules/analytic_account/account.py +++ 6.0/trytond/trytond/modules/analytic_account/account.py @@ -437,6 +437,9 @@ class AnalyticAccountEntry(ModelView, Mo def _get_origin(cls): return ['analytic_account.rule'] + def _get_fields_readonly(self, name=None): + return False + @classmethod def get_origin(cls): Model = Pool().get('ir.model') Index: 6.0/trytond/trytond/modules/analytic_invoice/invoice.py =================================================================== --- 6.0.orig/trytond/trytond/modules/analytic_invoice/invoice.py +++ 6.0/trytond/trytond/modules/analytic_invoice/invoice.py @@ -61,6 +61,17 @@ class InvoiceLine(AnalyticMixin, metacla class AnalyticAccountEntry(metaclass=PoolMeta): __name__ = 'analytic.account.entry' + def _get_fields_readonly(self, name=None): + res = super()._get_fields_readonly(name) + InvoiceLine = Pool().get('account.invoice.line') + if isinstance(self.origin, InvoiceLine): + if (self.origin and self.origin.invoice + and self.origin.invoice.state == 'draft'): + return False + else: + return True + return res + @classmethod def _get_origin(cls): pool = Pool() Index: 6.0/trytond/trytond/modules/analytic_purchase/purchase.py =================================================================== --- 6.0.orig/trytond/trytond/modules/analytic_purchase/purchase.py +++ 6.0/trytond/trytond/modules/analytic_purchase/purchase.py @@ -64,3 +64,14 @@ class AnalyticAccountEntry(metaclass=Poo (('origin.purchase.' + clause[0],) + tuple(clause[1:3]) + ('purchase.line',) + tuple(clause[3:])), ] + + def _get_fields_readonly(self, name=None): + res = super()._get_fields_readonly(name) + PurchaseLine = Pool().get('purchase.line') + if isinstance(self.origin, PurchaseLine): + if (self.origin and self.origin.purchase + and self.origin.purchase.state == 'draft'): + return False + else: + return True + return res \ No newline at end of file Index: 6.0/trytond/trytond/modules/analytic_sale/sale.py =================================================================== --- 6.0.orig/trytond/trytond/modules/analytic_sale/sale.py +++ 6.0/trytond/trytond/modules/analytic_sale/sale.py @@ -64,3 +64,14 @@ class AnalyticAccountEntry(metaclass=Poo (('origin.sale.' + clause[0],) + tuple(clause[1:3]) + ('sale.line',) + tuple(clause[3:])), ] + + def _get_fields_readonly(self, name=None): + res = super()._get_fields_readonly(name) + SaleLine = Pool().get('sale.line') + if isinstance(self.origin, SaleLine): + if (self.origin and self.origin.sale + and self.origin.sale.state == 'draft'): + return False + else: + return True + return res \ No newline at end of file