Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
sinergia | d76b7ac665 | |
sinergia | 16ba7a72a3 | |
Rodia | 0cc68ace9e | |
sinergia | 34be4741fd | |
Cosmos | 2ac26aeb52 | |
yo | 4dc77893fd | |
raskolnikov1984 | 30289c1667 | |
espurio | fa1b020775 | |
onecluster | c06ba9875e |
14
__init__.py
14
__init__.py
|
@ -2,17 +2,17 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from .purchase import *
|
||||
from . import purchase
|
||||
__all__ = ['register']
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Configuration,
|
||||
Purchase,
|
||||
module='one_click_for_purchase', type_='model')
|
||||
purchase.Configuration,
|
||||
purchase.Purchase,
|
||||
module='purchase_one_click', type_='model')
|
||||
Pool.register(
|
||||
OneClickForPurchase,
|
||||
module='one_click_for_purchase', type_='wizard')
|
||||
purchase.OneClickForPurchase,
|
||||
module='purchase_one_click', type_='wizard')
|
||||
Pool.register(
|
||||
module='one_click_for_purchase', type_='report')
|
||||
module='purchase_one_click', type_='report')
|
||||
|
|
109
purchase.py
109
purchase.py
|
@ -1,58 +1,54 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from trytond.wizard import Wizard, StateAction, StateView, StateTransition, \
|
||||
Button
|
||||
from trytond.wizard import Wizard, StateTransition
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
import logging
|
||||
from trytond.model import (ModelView, ModelSQL, ModelSingleton, ValueMixin,
|
||||
fields)
|
||||
from trytond.modules.company.model import (
|
||||
CompanyMultiValueMixin, CompanyValueMixin)
|
||||
from trytond.model.workflow import Workflow
|
||||
from trytond.modules.account.tax import TaxableMixin
|
||||
from trytond.model import (
|
||||
ModelView, fields)
|
||||
from trytond.pyson import Eval
|
||||
from .exceptions import ErroresGenerales
|
||||
from trytond.i18n import gettext
|
||||
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__all__ = ['OneClickForPurchase','Configuration','Purchase']
|
||||
__all__ = ['OneClickForPurchase', 'Configuration', 'Purchase']
|
||||
|
||||
|
||||
class Configuration(metaclass=PoolMeta):
|
||||
'Purchase Configuration'
|
||||
|
||||
|
||||
__name__ = 'purchase.configuration'
|
||||
|
||||
one_click_to_location = fields.Many2One('stock.location', 'Destino de Compra',
|
||||
domain=[('active','=',True),('type','=','storage')],
|
||||
help='Destino de Compra para el modulo one_click_for_purchase'
|
||||
)
|
||||
|
||||
one_click_to_location = fields.Many2One(
|
||||
'stock.location', 'Destino de Compra',
|
||||
domain=[('active', '=', True), ('type', '=', 'storage')],
|
||||
help='Destino de Compra para el modulo purchase_one_click'
|
||||
)
|
||||
|
||||
|
||||
class Purchase(metaclass=PoolMeta):
|
||||
'Purchase'
|
||||
|
||||
|
||||
__name__ = 'purchase.purchase'
|
||||
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Purchase, cls).__setup__()
|
||||
cls._buttons.update({
|
||||
'draft_to_done': {
|
||||
'invisible': ~Eval('state').in_(['draft']),
|
||||
'readonly': ~Eval('lines', []),
|
||||
},
|
||||
'draft_to_done': {
|
||||
'invisible': ~Eval('state').in_(['draft']),
|
||||
'readonly': ~Eval('lines', []),
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def draft_to_done(cls,purchases):
|
||||
'''Lleva las compras (ids) desde el estado borrador hasta finalizados aprobando
|
||||
las facturas y movimientos necesarios.'''
|
||||
|
||||
def draft_to_done(cls, purchases):
|
||||
'''Lleva las compras (ids) desde el estado borrador hasta finalizados
|
||||
aprobando las facturas y movimientos necesarios.'''
|
||||
|
||||
Invoice = Pool().get('account.invoice')
|
||||
Move = Pool().get('stock.move')
|
||||
Configuration = Pool().get('purchase.configuration')
|
||||
|
@ -61,25 +57,40 @@ class Purchase(metaclass=PoolMeta):
|
|||
if purchases:
|
||||
for purchase in purchases:
|
||||
if purchase.state != 'draft' or len(purchase.lines) < 1:
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_noborrador_sinlineas').format(s=purchase.number))
|
||||
raise ErroresGenerales(
|
||||
gettext(
|
||||
'purchase_one_click.msg_noborrador_sinlineas'
|
||||
).format(
|
||||
s=purchase.number))
|
||||
return
|
||||
if not purchase.invoice_address:
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_error_direccion').format(p=purchase.id))
|
||||
raise ErroresGenerales(
|
||||
gettext(
|
||||
'purchase_one_click.msg_error_direccion'
|
||||
).format(
|
||||
p=purchase.id))
|
||||
return
|
||||
else:
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_error_ventanas'))
|
||||
raise ErroresGenerales(
|
||||
gettext('purchase_one_click.msg_error_ventanas'))
|
||||
return
|
||||
|
||||
cls.set_purchase_date(purchases)#pone fecha de compra a los registros que no lo tienen
|
||||
# pone fecha de compra a los registros que no lo tienen
|
||||
cls.set_purchase_date(purchases)
|
||||
cls.quote(purchases)
|
||||
cls.confirm(purchases)
|
||||
cls.process(purchases)
|
||||
Transaction().commit()#se graba la informacion para poder acceder a las facturas y los movimientos
|
||||
purchases = cls.browse([x.id for x in purchases])#se vuelve a leer para cargar informacion de la base de datos, verificar si es necesario.
|
||||
purchases = [x for x in purchases if (x.state == 'processing' and len(x.lines) > 0) ]
|
||||
if len(purchases) <= 0 :
|
||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_fallo_finalizacion'))
|
||||
return
|
||||
# se graba la informacion para poder acceder a las facturas y
|
||||
# los movimientos
|
||||
Transaction().commit()
|
||||
# se vuelve a leer para cargar informacion de la base de datos,
|
||||
# verificar si es necesario.
|
||||
purchases = cls.browse([x.id for x in purchases])
|
||||
purchases = [x for x in purchases if (
|
||||
x.state == 'processing' and len(x.lines) > 0)]
|
||||
if len(purchases) <= 0:
|
||||
raise ErroresGenerales(
|
||||
gettext('one_click_for_purchase.msg_fallo_finalizacion'))
|
||||
for purchase in purchases:
|
||||
invoices = purchase.invoices
|
||||
if invoices:
|
||||
|
@ -89,24 +100,25 @@ class Purchase(metaclass=PoolMeta):
|
|||
Invoice.save([invoice])
|
||||
Invoice.validate_invoice(invoices)
|
||||
Invoice.post(invoices)
|
||||
|
||||
shipment_returns = purchase.shipment_returns
|
||||
|
||||
if shipment_returns:
|
||||
print("shipment_returns")
|
||||
for shipment_return in shipment_returns:
|
||||
if shipment_return.from_location != configuration.one_click_to_location:
|
||||
shipment_return.from_location = configuration.one_click_to_location
|
||||
one_click_to_location = configuration.one_click_to_location
|
||||
if shipment_return.from_location != one_click_to_location:
|
||||
shipment_return.from_location = one_click_to_location
|
||||
shipment_return.effective_date = purchase.purchase_date
|
||||
shipment_return.assign_force([shipment_return])
|
||||
shipment_return.wait([shipment_return])
|
||||
shipment_return.assign_try([shipment_return])
|
||||
shipment_return.done([shipment_return])
|
||||
shipment_return.save()
|
||||
#assert not purchase.shipments
|
||||
moves = purchase.moves
|
||||
if moves:
|
||||
for move in moves:
|
||||
if move.shipment:
|
||||
continue
|
||||
if move.to_location != configuration.one_click_to_location:
|
||||
if configuration.one_click_to_location is not None:
|
||||
move.to_location = configuration.one_click_to_location
|
||||
move.effective_date = purchase.purchase_date
|
||||
Move.save([move])
|
||||
|
@ -116,16 +128,17 @@ class Purchase(metaclass=PoolMeta):
|
|||
|
||||
class OneClickForPurchase(Wizard):
|
||||
'''Compra en un click.
|
||||
|
||||
|
||||
Procesa una compra en estado de borrador llevandola al estado "procesada",
|
||||
creando las Facturas y Movimientos de Stock, además contabiliza la factura
|
||||
y cambia el movimiento de stock de la entrada al almacenamiento y finaliza los movimientos de stock.
|
||||
y cambia el movimiento de stock de la entrada al almacenamiento y finaliza
|
||||
los movimientos de stock.
|
||||
'''
|
||||
|
||||
|
||||
__name__ = 'purchase.one_click_for_purchase'
|
||||
|
||||
|
||||
start = StateTransition()
|
||||
|
||||
|
||||
def transition_start(self):
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
purchases = Purchase.browse(Transaction().context['active_ids'])
|
||||
|
|
35
setup.py
35
setup.py
|
@ -24,9 +24,10 @@ def get_require_version(name):
|
|||
else:
|
||||
require = '%s >= %s.%s, < %s.%s'
|
||||
require %= (name, major_version, minor_version,
|
||||
major_version, minor_version + 1)
|
||||
major_version, minor_version + 1)
|
||||
return require
|
||||
|
||||
|
||||
config = ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
|
@ -37,7 +38,7 @@ version = info.get('version', '0.0.1')
|
|||
major_version, minor_version, _ = version.split('.', 2)
|
||||
major_version = int(major_version)
|
||||
minor_version = int(minor_version)
|
||||
name = 'trytond_one_click_for_purchase'
|
||||
name = 'trytond_purchase_one_click'
|
||||
|
||||
download_url = 'http://downloads.tryton.org/%s.%s/' % (
|
||||
major_version, minor_version)
|
||||
|
@ -58,33 +59,35 @@ dependency_links = []
|
|||
if minor_version % 2:
|
||||
dependency_links.append('https://trydevpi.tryton.org/')
|
||||
|
||||
setup(name=name,
|
||||
setup(
|
||||
name=name,
|
||||
version=version,
|
||||
description='The one_click_for_purchase module for Tryton ERP',
|
||||
description='The purchase_one_click module for Tryton ERP',
|
||||
long_description=read('README'),
|
||||
author='Tryton',
|
||||
author_email='issue_tracker@tryton.org',
|
||||
url='http://www.tryton.org/',
|
||||
download_url=download_url,
|
||||
keywords='purchase, simplify, trytond, trytond_purchase',
|
||||
package_dir={'trytond.modules.one_click_for_purchase': '.'},
|
||||
package_dir={'trytond.modules.purchase_one_click': '.'},
|
||||
packages=(
|
||||
['trytond.modules.one_click_for_purchase'] +
|
||||
['trytond.modules.one_click_for_purchase.%s' % p for p in find_packages()]
|
||||
),
|
||||
['trytond.modules.purchase_one_click'] +
|
||||
['trytond.modules.purchase_one_click.%s' % p for p in find_packages()]
|
||||
),
|
||||
package_data={
|
||||
'trytond.modules.one_click_for_purchase': (info.get('xml', [])
|
||||
'trytond.modules.purchase_one_click': (
|
||||
info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
|
||||
'icons/*.svg', 'tests/*.rst']),
|
||||
},
|
||||
'icons/*.svg', 'tests/*.rst']),
|
||||
},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Plugins',
|
||||
'Framework :: Tryton',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Financial and Insurance Industry',
|
||||
'Intended Audience :: Legal Industry',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||
'Intended Audience :: Legal Industry', 'License:: OSI Approved::\
|
||||
GNU General Public License v3 or later (GPLv3 +)',
|
||||
'Natural Language :: Bulgarian',
|
||||
'Natural Language :: Catalan',
|
||||
'Natural Language :: Chinese (Simplified)',
|
||||
|
@ -109,17 +112,17 @@ setup(name=name,
|
|||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Topic :: Office/Business',
|
||||
],
|
||||
],
|
||||
license='GPL-3',
|
||||
install_requires=requires,
|
||||
dependency_links=dependency_links,
|
||||
zip_safe=False,
|
||||
entry_points="""
|
||||
[trytond.modules]
|
||||
one_click_for_purchase = trytond.modules.one_click_for_purchase
|
||||
purchase_one_click = trytond.modules.purchase_one_click
|
||||
""",
|
||||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
use_2to3=True,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,9 +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.
|
||||
|
||||
try:
|
||||
from trytond.modules.one_click_for_purchase.tests.test_one_click_for_purchase import suite
|
||||
except ImportError:
|
||||
from .test_one_click_for_purchase import suite
|
||||
|
||||
__all__ = ['suite']
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
# 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 unittest
|
||||
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
from trytond.tests.test_tryton import suite as test_suite
|
||||
|
||||
|
||||
class OneClickForPurchaseTestCase(ModuleTestCase):
|
||||
class PurchaseOneClickTestCase(ModuleTestCase):
|
||||
'Test One Click For Purchase module'
|
||||
module = 'one_click_for_purchase'
|
||||
module = 'purchase_one_click'
|
||||
|
||||
|
||||
def suite():
|
||||
suite = test_suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||
OneClickForPurchaseTestCase))
|
||||
return suite
|
||||
del ModuleTestCase
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[tryton]
|
||||
version=6.0.0
|
||||
version=6.8.0
|
||||
depends:
|
||||
ir
|
||||
purchase
|
||||
xml:
|
||||
purchase.xml
|
||||
message.xml
|
||||
purchase.xml
|
||||
message.xml
|
Loading…
Reference in New Issue