File: sale.py

package info (click to toggle)
tryton-modules-product-price-list-dates 7.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 380 kB
  • sloc: python: 456; xml: 114; makefile: 11; sh: 3
file content (22 lines) | stat: -rw-r--r-- 743 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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 Line(metaclass=PoolMeta):
    __name__ = 'sale.line'

    @classmethod
    def __setup__(cls):
        super(Line, cls).__setup__()
        cls.product.search_context['date'] = Eval(
            '_parent_sale', {}).get('sale_date')

    @fields.depends('sale', '_parent_sale.sale_date')
    def _get_context_sale_price(self):
        context = super(Line, self)._get_context_sale_price()
        if self.sale:
            context.setdefault('date', self.sale.sale_date)
        return context