first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

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.

Binary file not shown.

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Revisió"
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Revisió"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Version"
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Version"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Revisión"
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Revisión"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Révision"
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Révision"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,21 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Revisi"
#, fuzzy
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Revisi"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
#, fuzzy
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Revisione"
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Revisione"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Herziening"
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Revisie"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,21 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Wersja"
#, fuzzy
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Wersja"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
#, fuzzy
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,20 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Revisão"
#, fuzzy
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Revisão"
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr "Revizuire"
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr "Revizie"
msgctxt "view:sale.sale:"
msgid "/"
msgstr "/"
msgctxt "view:sale.subscription:"
msgid "/"
msgstr "/"

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,19 @@
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "field:sale.sale,revision:"
msgid "Revision"
msgstr ""
msgctxt "field:sale.subscription,revision:"
msgid "Revision"
msgstr ""
msgctxt "view:sale.sale:"
msgid "/"
msgstr ""
msgctxt "view:sale.subscription:"
msgid "/"
msgstr ""

View File

@@ -0,0 +1,77 @@
# 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 ModelView, Workflow, fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval
from trytond.tools import grouped_slice, reduce_ids
from trytond.transaction import Transaction
class RevisionMixin:
__slots__ = ()
revision = fields.Integer(
"Revision", required=True, readonly=True,
states={
'invisible': Eval('revision', 0) == 0,
})
@classmethod
def default_revision(cls):
return 0
@property
def full_number(self):
number = super().full_number
if number is not None and self.revision:
number += '/%d' % self.revision
return number
@classmethod
def copy(cls, records, default=None):
default = default.copy() if default is not None else {}
default.setdefault('revision', cls.default_revision())
return super().copy(records, default=default)
@classmethod
@ModelView.button
@Workflow.transition('draft')
def draft(cls, records):
cursor = Transaction().connection.cursor()
table = cls.__table__()
# Use SQL and before super to avoid two history entries
for sub_records in grouped_slice(records):
cursor.execute(*table.update(
[table.revision],
[table.revision + 1],
where=reduce_ids(table.id, sub_records)))
super().draft(records)
class Sale(RevisionMixin, metaclass=PoolMeta):
__name__ = 'sale.sale'
_history = True
class Line(metaclass=PoolMeta):
__name__ = 'sale.line'
_history = True
class LineTax(metaclass=PoolMeta):
__name__ = 'sale.line-account.tax'
_history = True
class Subscription(RevisionMixin, metaclass=PoolMeta):
__name__ = 'sale.subscription'
_history = True
class SubscriptionLine(metaclass=PoolMeta):
__name__ = 'sale.subscription.line'
_history = True
# TODO: add rental

View File

@@ -0,0 +1,30 @@
<?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="sale_view_form">
<field name="model">sale.sale</field>
<field name="inherit" ref="sale.sale_view_form"/>
<field name="name">sale_form</field>
</record>
<record model="ir.ui.view" id="sale_view_tree">
<field name="model">sale.sale</field>
<field name="inherit" ref="sale.sale_view_tree"/>
<field name="name">sale_tree</field>
</record>
</data>
<data depends="sale_subscription">
<record model="ir.ui.view" id="subscription_view_form">
<field name="model">sale.subscription</field>
<field name="inherit" ref="sale_subscription.subscription_view_form"/>
<field name="name">sale_form</field>
</record>
<record model="ir.ui.view" id="subscription_view_list">
<field name="model">sale.subscription</field>
<field name="inherit" ref="sale_subscription.subscription_view_list"/>
<field name="name">sale_tree</field>
</record>
</data>
</tryton>

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,42 @@
=====================
Sale History Scenario
=====================
Imports::
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('sale_history', create_company)
Create customer::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.save()
Create a sale::
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = customer
>>> sale.click('quote')
>>> sale.number
'1'
>>> sale.revision
0
>>> sale.rec_name
'1'
Reset to draft increases revision::
>>> sale.click('draft')
>>> sale.revision
1
>>> sale.rec_name
'1/1'

View File

@@ -0,0 +1,13 @@
# 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.tests.test_tryton import ModuleTestCase
class SaleHistoryTestCase(ModuleTestCase):
'Test Sale History module'
module = 'sale_history'
extras = ['sale_subscription']
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# 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.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)

View File

@@ -0,0 +1,20 @@
[tryton]
version=7.8.0
depends:
ir
sale
extras_depend:
sale_subscription
xml:
sale.xml
[register]
model:
sale.Sale
sale.Line
sale.LineTax
[register sale_subscription]
model:
sale.Subscription
sale.SubscriptionLine

View File

@@ -0,0 +1,12 @@
<?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='number']" position="replace">
<group id="number">
<field name="number"/>
<label name="revision" string="/"/>
<field name="revision"/>
</group>
</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="//field[@name='number']" position="after">
<field name="revision"/>
</xpath>
</data>