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.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,64 @@
# 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 Purchase(metaclass=PoolMeta):
__name__ = 'purchase.purchase'
_history = True
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, purchases, default=None):
if default is None:
default = {}
else:
default = default.copy()
default.setdefault('revision', cls.default_revision())
return super().copy(purchases, default=default)
@classmethod
@ModelView.button
@Workflow.transition('draft')
def draft(cls, purchases):
cursor = Transaction().connection.cursor()
table = cls.__table__()
# Use SQL and before super to avoid two history entries
for sub_purchases in grouped_slice(purchases):
cursor.execute(*table.update(
[table.revision],
[table.revision + 1],
where=reduce_ids(table.id, sub_purchases)))
super().draft(purchases)
class Line(metaclass=PoolMeta):
__name__ = 'purchase.line'
_history = True
class LineTax(metaclass=PoolMeta):
__name__ = 'purchase.line-account.tax'
_history = True

View File

@@ -0,0 +1,17 @@
<?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="purchase_view_form">
<field name="model">purchase.purchase</field>
<field name="inherit" ref="purchase.purchase_view_form"/>
<field name="name">purchase_form</field>
</record>
<record model="ir.ui.view" id="purchase_view_tree">
<field name="model">purchase.purchase</field>
<field name="inherit" ref="purchase.purchase_view_tree"/>
<field name="name">purchase_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 @@
=========================
Purchase 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('purchase_history', create_company)
Create supplier::
>>> Party = Model.get('party.party')
>>> supplier = Party(name='Supplier')
>>> supplier.save()
Create a purchase::
>>> Purchase = Model.get('purchase.purchase')
>>> purchase = Purchase()
>>> purchase.party = supplier
>>> purchase.click('quote')
>>> purchase.number
'1'
>>> purchase.revision
0
>>> purchase.rec_name
'1'
Reset to draft increases revision::
>>> purchase.click('draft')
>>> purchase.revision
1
>>> purchase.rec_name
'1/1'

View File

@@ -0,0 +1,12 @@
# 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 PurchaseHistoryTestCase(ModuleTestCase):
'Test Purchase History module'
module = 'purchase_history'
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,13 @@
[tryton]
version=7.8.0
depends:
ir
purchase
xml:
purchase.xml
[register]
model:
purchase.Purchase
purchase.Line
purchase.LineTax

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>