Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. # The COPYRIGHT file at the top level of this repository contains the full
  2. # copyright notices and license terms.
  3. from trytond.model import fields
  4. from trytond.pool import PoolMeta
  5. from trytond.pyson import Eval, In
  6. from trytond.modules.product import price_digits
  7.  
  8. __all__ = ['SaleOpportunity', 'SaleOpportunityLine']
  9.  
  10. _STATES_STOP = {
  11.     'readonly': In(Eval('state'), ['converted', 'won', 'lost', 'cancelled']),
  12. }
  13. _DEPENDS_STOP = ['state']
  14.  
  15.  
  16. class SaleOpportunity(metaclass=PoolMeta):
  17.     __name__ = "sale.opportunity"
  18.  
  19.     customer_comment = fields.Char('Customer Comment', states=_STATES_STOP,
  20.         depends=_DEPENDS_STOP)
  21.     payment_term_comment = fields.Char('Payment Term Comment',
  22.         states=_STATES_STOP, depends=_DEPENDS_STOP)
  23.  
  24.  
  25. class SaleOpportunityLine(metaclass=PoolMeta):
  26.     __name__ = "sale.opportunity.line"
  27.  
  28.     customer_comment = fields.Char('Customer Comment',
  29.         states={
  30.             'readonly': ~Eval('opportunity_state').in_(['lead', 'opportunity'])
  31.             }, depends=['opportunity_state'])
  32.     lead_time = fields.Char('Lead Time',
  33.         states={
  34.             'readonly': ~Eval('opportunity_state').in_(['lead', 'opportunity'])
  35.             }, depends=['opportunity_state'], help='Time needed to supply')
  36.     validity_period = fields.Char('Validity Period',
  37.         states={
  38.             'readonly': ~Eval('opportunity_state').in_(['lead', 'opportunity'])
  39.             }, depends=['opportunity_state'])
  40.     sale_price = fields.Numeric('Sale Price', digits=price_digits,
  41.         states={
  42.             'readonly': ~Eval('opportunity_state').in_(['lead', 'opportunity'])
  43.             }, depends=['opportunity_state'])
  44.     currency = fields.Function(fields.Many2One('currency.currency',
  45.         'Currency'), 'on_change_with_currency')
  46.  
  47.  
  48. @classmethod
  49. def __setup__(cls):
  50.     super(SaleOpportunityLine, cls).__setup__()
  51.     clause = ('salable', '=', True)
  52.     if clause in cls.product.domain:
  53.         cls.product.domain.remove(clause)
  54.  
  55.  
  56. @fields.depends('opportunity', '_parent_opportunity.currency')
  57. def on_change_with_currency(self, name=None):
  58.     if self.opportunity:
  59.         return self.opportunity.currency.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement