Initial import from Docker volume

This commit is contained in:
root
2025-12-26 13:11:43 +00:00
commit 4998dc066a
13336 changed files with 1767801 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
# 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.pool import Pool
from . import product, purchase, sale
__all__ = ['register']
def register():
Pool.register(
product.PriceList,
product.PriceListLine,
product.PriceListLineContext,
module='product_price_list_dates', type_='model')
Pool.register(
product.PriceListCache,
module='product_price_list_dates', type_='model',
depends=['product_price_list_cache'])
Pool.register(
sale.Line,
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'])

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Data final"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Data inicial"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Data"
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Data"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Línies"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Obre línies"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Context de la línia de tarifa"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Enddatum"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Startdatum"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Datum"
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Datum"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Positionen"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Positionen öffnen"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Preisliste Position Kontext"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Fecha fin"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Fecha inicial"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Líneas"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Abrir lineas"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Contexto de la línea de tarifa"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr ""
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr ""
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,32 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Lõppkuupäev"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Alguskuupäev"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Kuupäev"
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Kuupäev"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Read"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Avatud read"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Hinnakirja rea sisu"

View File

@@ -0,0 +1,32 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "تاریخ پایان"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "تاریخ شروع"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "تاریخ"
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "تاریخ"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "خطوط"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "مفاد خط لیست قیمت"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Date de fin"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Date de début"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Date"
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Date"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lignes"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Ouvrir les lignes"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Contexte de ligne de liste de prix"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,32 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Tanggal Akhir"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Tanggal Awal"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Tanggal"
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Tanggal"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Baris"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr ""
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Data fine"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Data inizio"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Data"
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Data"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Righe"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Righe aperte"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Contesto della riga del listino prezzi"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "ວັນທີສິ້ນສຸດ"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "ວັນທີເລີ່ມ"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "ວັນທີ"
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "ວັນທີ"
#, fuzzy
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "ບໍລິບົດລາຍການບັນຊີລາຄາ"

View File

@@ -0,0 +1,32 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Pabaigos data"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Pradžios data"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Pabaigos data"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Eind datum"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Start datum"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Datum"
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Datum"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Regels"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open posities"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Prijslijst regelcontext"

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Data ukończenia"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Data rozpoczęcia"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Data"
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Data"
#, fuzzy
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,32 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Data de término"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Data de início"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Data"
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Data"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Linhas"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Contexto das linhas de Preço de Tabela"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Data de încheiere"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Data de început"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Data"
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Data"
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Rânduri"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Rânduri Deschide"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Contextul rândului de prețuri"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,33 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr "Konec veljavnosti"
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr "Pričetek veljavnosti"
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr "Datum"
#, fuzzy
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr "Datum"
#, fuzzy
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr "Kontekst postavke cenika"

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr ""
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr ""
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,31 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:product.price_list.line,end_date:"
msgid "End Date"
msgstr ""
msgctxt "field:product.price_list.line,start_date:"
msgid "Start Date"
msgstr ""
msgctxt "field:product.price_list.line.context,date:"
msgid "Date"
msgstr ""
msgctxt "field:product.sale.context,date:"
msgid "Date"
msgstr ""
msgctxt "model:ir.action,name:act_price_list_line_form"
msgid "Lines"
msgstr "Lines"
msgctxt "model:ir.model.button,string:price_list_open_lines_button"
msgid "Open Lines"
msgstr "Open Lines"
msgctxt "model:product.price_list.line.context,name:"
msgid "Price List Line Context"
msgstr ""

View File

@@ -0,0 +1,118 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import datetime as dt
from trytond.config import config
from trytond.model import ModelView, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, If
from trytond.transaction import Transaction
_cache_days = config.getint(
'product_price_list_dates', 'cache_days', default=2)
class PriceList(metaclass=PoolMeta):
__name__ = 'product.price_list'
@classmethod
def __setup__(cls):
super(PriceList, cls).__setup__()
cls._buttons.update({
'open_lines': {},
})
@classmethod
@ModelView.button_action(
'product_price_list_dates.act_price_list_line_form')
def open_lines(cls, price_lists):
pass
def compute(self, product, quantity, uom, pattern=None):
context = Transaction().context
pattern = pattern.copy() if pattern is not None else {}
pattern.setdefault('date', context.get('date'))
return super().compute(product, quantity, uom, pattern=pattern)
class PriceListCache(metaclass=PoolMeta):
__name__ = 'product.price_list.cache'
@classmethod
def patterns(cls, price_list, product):
pool = Pool()
Date = pool.get('ir.date')
today = Date.today()
for pattern in super().patterns(price_list, product):
if pattern is None:
pattern = {}
for days in range(_cache_days):
pattern['date'] = today + dt.timedelta(days=days)
yield pattern
@classmethod
def get(cls, price_list, product, pattern=None):
pool = Pool()
Date = pool.get('ir.date')
context = Transaction().context
today = Date.today()
pattern = pattern.copy() if pattern else {}
pattern['date'] = pattern.get('date', context.get('date')) or today
return super().get(price_list, product, pattern=pattern)
class PriceListLine(metaclass=PoolMeta):
__name__ = 'product.price_list.line'
start_date = fields.Date(
"Start Date",
domain=[
If(Eval('start_date') & Eval('end_date'),
('start_date', '<=', Eval('end_date')),
()),
])
end_date = fields.Date(
"End Date",
domain=[
If(Eval('start_date') & Eval('end_date'),
('end_date', '>=', Eval('start_date')),
()),
])
def match(self, pattern):
pool = Pool()
Date = pool.get('ir.date')
pattern = pattern.copy()
date = pattern.pop('date', None) or Date.today()
if self.start_date and self.start_date > date:
return False
if self.end_date and self.end_date < date:
return False
return super(PriceListLine, self).match(pattern)
class PriceListLineContext(ModelView):
"Price List Line Context"
__name__ = 'product.price_list.line.context'
date = fields.Date("Date")
@classmethod
def default_date(cls):
pool = Pool()
Date = pool.get('ir.date')
return Date.today()
class SaleContext(metaclass=PoolMeta):
__name__ = 'product.sale.context'
date = fields.Function(
fields.Date("Date"),
'on_change_with_date')
@fields.depends('sale_date')
def on_change_with_date(self, name=None):
return self.sale_date

View File

@@ -0,0 +1,79 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="price_list_view_form">
<field name="model">product.price_list</field>
<field name="inherit"
ref="product_price_list.price_list_view_form"/>
<field name="name">price_list_form</field>
</record>
<record model="ir.model.button" id="price_list_open_lines_button">
<field name="model">product.price_list</field>
<field name="name">open_lines</field>
<field name="string">Open Lines</field>
</record>
<record model="ir.ui.view" id="price_list_line_view_form">
<field name="model">product.price_list.line</field>
<field name="inherit"
ref="product_price_list.price_list_line_view_form"/>
<field name="name">price_list_line_form</field>
</record>
<record model="ir.ui.view" id="price_list_line_view_tree">
<field name="model">product.price_list.line</field>
<field name="inherit"
ref="product_price_list.price_list_line_view_tree"/>
<field name="name">price_list_line_tree</field>
</record>
<record model="ir.ui.view" id="price_list_line_view_tree_sequence">
<field name="model">product.price_list.line</field>
<field name="inherit"
ref="product_price_list.price_list_line_view_tree_sequence"/>
<field name="name">price_list_line_tree_sequence</field>
</record>
<record model="ir.action.act_window" id="act_price_list_line_form">
<field name="name">Lines</field>
<field name="res_model">product.price_list.line</field>
<field name="context_model">product.price_list.line.context</field>
<field name="domain"
eval="[('price_list', '=', Eval('active_id'))]"
pyson="1"/>
<field name="context_domain"
eval="[['OR', ('start_date', '=', None), ('start_date', '&lt;=', Eval('date', Date()))], ['OR', ('end_date', '=', None), ('end_date', '&gt;=', Eval('date', Date()))]]"
pyson="1"/>
</record>
<record model="ir.action.act_window.view"
id="act_price_list_line_form_view1">
<field name="sequence" eval="10"/>
<field name="view"
ref="product_price_list.price_list_line_view_tree_sequence"/>
<field name="act_window" ref="act_price_list_line_form"/>
</record>
<record model="ir.action.act_window.view"
id="act_price_list_line_form_view2">
<field name="sequence" eval="20"/>
<field name="view"
ref="product_price_list.price_list_line_view_form"/>
<field name="act_window" ref="act_price_list_line_form"/>
</record>
<record model="ir.ui.view" id="price_list_line_context_view_form">
<field name="model">product.price_list.line.context</field>
<field name="type">form</field>
<field name="name">price_list_line_context_form</field>
</record>
</data>
<data depends="sale_price_list">
<record model="ir.ui.view" id="product_sale_context_view_form">
<field name="model">product.sale.context</field>
<field name="inherit" ref="sale.product_sale_context_view_form"/>
<field name="name">product_sale_context_form</field>
</record>
</data>
</tryton>

View File

@@ -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

View File

@@ -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__ = '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

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,153 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import datetime
from decimal import Decimal
from trytond.modules.company.tests import (
CompanyTestMixin, create_company, set_company)
from trytond.pool import Pool
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.transaction import Transaction
class ProductPriceListDatesTestCase(CompanyTestMixin, ModuleTestCase):
'Test Product Price List Dates module'
module = 'product_price_list_dates'
extras = [
'product_price_list_cache', 'sale_price_list', 'purchase_price_list']
def create_price_list(self, field, date):
pool = Pool()
PriceList = pool.get('product.price_list')
price_list, = PriceList.create([{
'name': "Price List",
'price': 'list_price',
'lines': [('create', [{
field: date,
'formula': 'unit_price * 0.9',
}, {
'formula': 'unit_price',
}])],
}])
return price_list
def create_product(self, list_price=Decimal(10)):
pool = Pool()
Product = pool.get('product.product')
Template = pool.get('product.template')
Uom = pool.get('product.uom')
unit, = Uom.search([('name', '=', "Unit")])
template = Template(
name="Template", list_price=list_price, default_uom=unit)
template.save()
product = Product(template=template)
product.save()
return product
@with_transaction()
def test_price_list_start_date(self):
"Test price list with start date"
pool = Pool()
Date = pool.get('ir.date')
today = Date.today()
tomorrow = today + datetime.timedelta(days=1)
company = create_company()
with set_company(company):
product = self.create_product()
uom = product.default_uom
price_list = self.create_price_list('start_date', tomorrow)
self.assertEqual(
price_list.compute(
product, 1, uom, pattern={'date': today}),
Decimal(10))
self.assertEqual(
price_list.compute(
product, 1, uom, pattern={'date': tomorrow}),
Decimal(9))
@with_transaction()
def test_price_list_end_date(self):
"Test price list with end date"
pool = Pool()
Date = pool.get('ir.date')
today = Date.today()
yesterday = today - datetime.timedelta(days=1)
company = create_company()
with set_company(company):
product = self.create_product()
uom = product.default_uom
price_list = self.create_price_list('end_date', yesterday)
self.assertEqual(
price_list.compute(
product, 1, uom, pattern={'date': today}),
Decimal(10))
self.assertEqual(
price_list.compute(
product, 1, uom, pattern={'date': yesterday}),
Decimal(9))
@with_transaction()
def test_price_list_with_context_date(self):
"Test price list with context date"
pool = Pool()
Date = pool.get('ir.date')
today = Date.today()
tomorrow = today + datetime.timedelta(days=1)
company = create_company()
with set_company(company):
product = self.create_product()
uom = product.default_uom
price_list = self.create_price_list('start_date', tomorrow)
with Transaction().set_context(date=today):
self.assertEqual(
price_list.compute(product, 1, uom),
Decimal(10))
with Transaction().set_context(date=tomorrow):
self.assertEqual(
price_list.compute(product, 1, uom),
Decimal(9))
@with_transaction()
def test_price_list_cache(self):
"Test price list cache"
pool = Pool()
Cache = pool.get('product.price_list.cache')
Date = pool.get('ir.date')
today = Date.today()
tomorrow = today + datetime.timedelta(days=1)
company = create_company()
with set_company(company):
product = self.create_product()
uom = product.default_uom
price_list = self.create_price_list('start_date', tomorrow)
price_list.fill_cache()
caches = Cache.search([])
self.assertEqual(len(caches), 2)
for date, result in [
(today, Decimal(10)),
(tomorrow, Decimal(9)),
]:
with self.subTest(date=date):
with Transaction().set_context(date=date):
cache = Cache.get(price_list, product)
self.assertEqual(cache.get_unit_price(1, uom), result)
del ModuleTestCase

View File

@@ -0,0 +1,10 @@
[tryton]
version=7.2.0
depends:
ir
product_price_list
extras_depend:
product_price_list_cache
sale_price_list
xml:
product.xml

View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//field[@name='lines']" position="after">
<button name="open_lines" colspan="4"/>
</xpath>
</data>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="date"/>
<field name="date"/>
</form>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='sequence']" position="after">
<label name="start_date"/>
<group id="start_end_date" col="3">
<field name="start_date"/>
<label name="end_date"/>
<field name="end_date"/>
</group>
</xpath>
</data>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='sequence']" position="after">
<field name="start_date"/>
<field name="end_date"/>
</xpath>
</data>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='category']" position="before">
<field name="start_date"/>
<field name="end_date"/>
</xpath>
</data>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form" position="inside">
<field name="date" invisible="1" colspan="4"/>
</xpath>
</data>