@@ -3,7 +3,7 @@
|
||||
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import product, sale
|
||||
from . import product, purchase, sale
|
||||
|
||||
__all__ = ['register']
|
||||
|
||||
@@ -19,3 +19,7 @@ def register():
|
||||
product.SaleContext,
|
||||
module='product_price_list_dates', type_='model',
|
||||
depends=['sale_price_list'])
|
||||
Pool.register(
|
||||
purchase.Line,
|
||||
module='product_price_list_dates', type_='model',
|
||||
depends=['purchase_price_list'])
|
||||
|
||||
@@ -0,0 +1,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__ = 'purchase.line'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls.product.search_context['date'] = Eval(
|
||||
'_parent_purchase', {}).get('purchase_date')
|
||||
|
||||
@fields.depends('purchase', '_parent_purchase.purchase_date')
|
||||
def _get_context_purchase_price(self):
|
||||
context = super()._get_context_purchase_price()
|
||||
if self.purchase:
|
||||
context.setdefault('date', self.purchase.purchase_date)
|
||||
return context
|
||||
@@ -47,7 +47,10 @@ for dep in info.get('depends', []):
|
||||
requires.append(get_require_version('trytond_%s' % dep))
|
||||
requires.append(get_require_version('trytond'))
|
||||
|
||||
tests_require = [get_require_version('trytond_sale_price_list')]
|
||||
tests_require = [
|
||||
get_require_version('trytond_purchase_price_list'),
|
||||
get_require_version('trytond_sale_price_list'),
|
||||
]
|
||||
|
||||
setup(name=name,
|
||||
version=version,
|
||||
|
||||
@@ -14,7 +14,7 @@ from trytond.transaction import Transaction
|
||||
class ProductPriceListDatesTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test Product Price List Dates module'
|
||||
module = 'product_price_list_dates'
|
||||
extras = ['sale_price_list']
|
||||
extras = ['sale_price_list', 'purchase_price_list']
|
||||
|
||||
def create_price_list(self, field, date):
|
||||
pool = Pool()
|
||||
|
||||
Reference in New Issue
Block a user