Release v6.0
This commit is contained in:
parent
3c501b2bad
commit
6aacff6aa4
23
__init__.py
23
__init__.py
|
@ -1,23 +1,20 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of this
|
||||
#repository contains the full copyright notices and license terms.
|
||||
# repository contains the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .purchase import (Purchase, PurchaseLine, PurchaseDetailedReport,
|
||||
PurchaseAnalyticStart, PurchaseAnalytic, PurchaseAnalyticReport,
|
||||
PurchaseForceCancel) #, PurchaseHistoricByProduct)
|
||||
from . import purchase
|
||||
|
||||
|
||||
def register():
|
||||
|
||||
Pool.register(
|
||||
Purchase,
|
||||
PurchaseLine,
|
||||
PurchaseAnalyticStart,
|
||||
purchase.Purchase,
|
||||
purchase.PurchaseLine,
|
||||
purchase.PurchaseAnalyticStart,
|
||||
module='purchase_report', type_='model')
|
||||
Pool.register(
|
||||
PurchaseAnalytic,
|
||||
PurchaseForceCancel,
|
||||
#PurchaseHistoricByProduct,
|
||||
purchase.PurchaseAnalytic,
|
||||
purchase.PurchaseForceCancel,
|
||||
module='purchase_report', type_='wizard')
|
||||
Pool.register(
|
||||
PurchaseDetailedReport,
|
||||
PurchaseAnalyticReport,
|
||||
purchase.PurchaseDetailedReport,
|
||||
purchase.PurchaseAnalyticReport,
|
||||
module='purchase_report', type_='report')
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?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 grouped="1">
|
||||
<record model="ir.message" id="msg_duplicate_purchase">
|
||||
<field name="text">Purchase Duplicate! already exists other purchase with reference"%s".</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
58
purchase.py
58
purchase.py
|
@ -9,12 +9,8 @@ from trytond.pool import PoolMeta, Pool
|
|||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
|
||||
from trytond.pyson import Eval
|
||||
|
||||
__all__ = [
|
||||
'Purchase', 'PurchaseLine', 'PurchaseDetailedReport', 'Purchase',
|
||||
'PurchaseAnalyticStart', 'PurchaseAnalytic', 'PurchaseAnalyticReport',
|
||||
'PurchaseForceCancel',
|
||||
]
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.i18n import gettext
|
||||
|
||||
_STATES = {
|
||||
'readonly': Eval('state') != 'draft',
|
||||
|
@ -27,9 +23,6 @@ class Purchase(metaclass=PoolMeta):
|
|||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Purchase, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'duplicate_purchase': ('Purchase Duplicate! already exists other purchase with reference"%s".'),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def confirm(cls, purchases):
|
||||
|
@ -40,7 +33,7 @@ class Purchase(metaclass=PoolMeta):
|
|||
('purchase_date', '=', purchase.purchase_date),
|
||||
], fields_names=['reference'])
|
||||
if len(duplicates) >= 2:
|
||||
cls.raise_user_error('duplicate_purchase', purchase.reference)
|
||||
raise AccessError(gettext('purchase_report.msg_duplicate_purchase', s=purchase.reference))
|
||||
super(Purchase, cls).confirm(purchases)
|
||||
|
||||
@classmethod
|
||||
|
@ -121,9 +114,8 @@ class PurchaseDetailedReport(Report):
|
|||
__name__ = 'purchase_report.detailed'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(PurchaseDetailedReport, cls).get_context(
|
||||
records, data)
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
user = Pool().get('res.user')(Transaction().user)
|
||||
report_context['company'] = user.company
|
||||
|
||||
|
@ -181,8 +173,8 @@ class PurchaseAnalyticReport(Report):
|
|||
return sum([t['amount'] for t in tax_list], Decimal('0.0'))
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(PurchaseAnalyticReport, cls).get_context(records, data)
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
|
@ -231,14 +223,6 @@ class PurchaseForceCancel(Wizard):
|
|||
start_state = 'force_cancel'
|
||||
force_cancel = StateTransition()
|
||||
|
||||
# @classmethod
|
||||
# def __setup__(cls):
|
||||
# super(PurchaseForceCancel, cls).__setup__()
|
||||
# cls._error_messages.update({
|
||||
# 'error_cancel_purchase_invoice': ('You can not cancel the purchase because I have already generated the invoice number "%s".'),
|
||||
# 'error_cancel_purchase_shipment': ('You can not cancel the purchase "%s" because I have already generated the shipping number "%s".'),
|
||||
# })
|
||||
|
||||
def transition_force_cancel(self):
|
||||
pool = Pool()
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
|
@ -254,9 +238,6 @@ class PurchaseForceCancel(Wizard):
|
|||
number_invoices = []
|
||||
if purchase.invoices:
|
||||
Invoice.cancel(purchase.invoices)
|
||||
# number_invoices = [invoice.number for invoice in purchase.invoices if invoice.number]
|
||||
# self.raise_user_error('error_cancel_purchase_invoice', (number_invoices,))
|
||||
# return
|
||||
if purchase.shipments:
|
||||
for s in purchase.shipments:
|
||||
cursor.execute("UPDATE stock_shipment_in SET state='draft' WHERE id in (%s)" % (s.id))
|
||||
|
@ -270,30 +251,5 @@ class PurchaseForceCancel(Wizard):
|
|||
Move.cancel(s.incoming_moves)
|
||||
Move.cancel(s.inventory_moves)
|
||||
ShipmentIn.cancel(purchase.shipments)
|
||||
# number_ship = [shipment.number for shipment in purchase.shipments if shipment.number]
|
||||
# self.raise_user_error('error_cancel_purchase_shipment', (number_ship,))
|
||||
# return
|
||||
Purchase.write([purchase], {'state': 'cancel'})
|
||||
return 'end'
|
||||
|
||||
|
||||
# class PurchaseHistoricByProduct(Wizard):
|
||||
# 'Purchase Historic By Product'
|
||||
# __name__ = 'purchase_report.historic_by_product'
|
||||
# start = StateView('purchase_report.analytic.start',
|
||||
# 'purchase_report.purchase_analytic_start_view_form', [
|
||||
# Button('Cancel', 'end', 'tryton-cancel'),
|
||||
# Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
# ])
|
||||
# print_ = StateReport('purchase_report.analytic.report')
|
||||
#
|
||||
# def do_print_(self, action):
|
||||
# data = {
|
||||
# 'company': self.start.company.id,
|
||||
# 'start_date': self.start.start_date,
|
||||
# 'end_date': self.start.end_date,
|
||||
# }
|
||||
# return action, data
|
||||
#
|
||||
# def transition_print_(self):
|
||||
# return 'end'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=5.0.0
|
||||
version=6.0.0
|
||||
depends:
|
||||
purchase
|
||||
xml:
|
||||
|
|
Loading…
Reference in New Issue